Ignore:
Timestamp:
2011-12-01T12:18:32+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/db2txtl-src/db2txtl.cpp

    r24621 r24835  
    3737#include <stdlib.h>
    3838#include <fcntl.h>
     39#include <string.h>
     40#include <sys/stat.h>
    3941
    4042#if defined(GSDL_USE_OBJECTSPACE)
     
    6163// lock a file on linux
    6264// [hs, 2 july 2010]
    63 int lock ( char *filename )
     65// - modified to create a locl file local to the collection [jmt12]
     66int lock ()
    6467{
    65   int fd2 = open (filename, O_CREAT|O_RDWR, 00644);
     68  string file_path ("");
     69  char *collect_dir = getenv ("GSDLCOLLECTDIR");
     70  if (collect_dir != NULL)
     71  {
     72    file_path += collect_dir;
     73  }
     74  file_path += "/tmp";
     75  if ( access( file_path.c_str(), 00 ) != 0 )
     76  {
     77    mkdir(file_path.c_str(), 00777);
     78  }
     79  file_path += "/gdb.lock";
     80  ///out << "txt2dbl::lock(" << file_path << ") => ";
     81  int fd2 = open (file_path.c_str(), O_CREAT|O_RDWR, 00644);
    6682  close (fd2);
    67   int fd = open (filename, O_RDWR);
    68   flock lock = {F_RDLCK, SEEK_SET, 0, 0, 0};
     83  int fd = open (file_path.c_str(), O_RDWR);
     84  flock lock = {F_WRLCK, SEEK_SET, 0, 0, 0};
    6985  fcntl (fd, F_SETLKW, &lock);
     86  ///out << "locked!" << endl;
    7087  return fd;
    7188}
     
    93110  // open the database
    94111  // - acquire a lock over the database so we can read from it.
    95   int thelock = lock ("gdb.lock");
     112  int thelock = lock();
    96113#ifdef __WIN32__
    97114  dbf = gdbm_open (argv[1], block_size, GDBM_READER, 00664, NULL, 0);
Note: See TracChangeset for help on using the changeset viewer.