Ignore:
Timestamp:
2011-12-01T12:19:00+13:00 (12 years ago)
Author:
jmt12
Message:

Altered lockfile generation so that it occurs in specific collections tmp directory instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/parallel-building/trunk/src/src/txt2dbl-src/txt2dbl.cpp

    r24618 r24836  
    4040#include <cstring>
    4141#include <fcntl.h>
     42#include <string.h>
     43#include <sys/stat.h>
    4244
    4345#if defined(GSDL_USE_OBJECTSPACE)
     
    6264// lock a file on linux
    6365// [hs, 2 july 2010]
    64 int lock ( char *filename )
     66// - modified to create a locl file local to the collection [jmt12]
     67int lock ()
    6568{
    66   ///out << "txt2dbl::lock(" << filename << ") => ";
    67   int fd2 = open (filename, O_CREAT|O_RDWR, 00644);
     69  string file_path ("");
     70  char *collect_dir = getenv ("GSDLCOLLECTDIR");
     71  if (collect_dir != NULL)
     72  {
     73    file_path += collect_dir;
     74  }
     75  file_path += "/tmp";
     76  if ( access( file_path.c_str(), 00 ) != 0 )
     77  {
     78    mkdir(file_path.c_str(), 00777);
     79  }
     80  file_path += "/gdb.lock";
     81  ///out << "txt2dbl::lock(" << file_path << ") => ";
     82  int fd2 = open (file_path.c_str(), O_CREAT|O_RDWR, 00644);
    6883  close (fd2);
    69   int fd = open (filename, O_RDWR);
     84  int fd = open (file_path.c_str(), O_RDWR);
    7085  flock lock = {F_WRLCK, SEEK_SET, 0, 0, 0};
    7186  fcntl (fd, F_SETLKW, &lock);
     
    216231      // and lock before the operation
    217232      // [hs, 2 july 2010]
    218       int thelock = lock ("gdb.lock");
     233      int thelock = lock ();
    219234#ifdef __WIN32__
    220235      dbf = gdbm_open (dbname, block_size, read_write, 00664, NULL, 1);
Note: See TracChangeset for help on using the changeset viewer.