Changeset 24835 for gs2-extensions/parallel-building/trunk/src
- Timestamp:
- 2011-12-01T12:18:32+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/parallel-building/trunk/src/src/db2txtl-src/db2txtl.cpp
r24621 r24835 37 37 #include <stdlib.h> 38 38 #include <fcntl.h> 39 #include <string.h> 40 #include <sys/stat.h> 39 41 40 42 #if defined(GSDL_USE_OBJECTSPACE) … … 61 63 // lock a file on linux 62 64 // [hs, 2 july 2010] 63 int lock ( char *filename ) 65 // - modified to create a locl file local to the collection [jmt12] 66 int lock () 64 67 { 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); 66 82 close (fd2); 67 int fd = open (file name, 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}; 69 85 fcntl (fd, F_SETLKW, &lock); 86 ///out << "locked!" << endl; 70 87 return fd; 71 88 } … … 93 110 // open the database 94 111 // - acquire a lock over the database so we can read from it. 95 int thelock = lock ("gdb.lock");112 int thelock = lock(); 96 113 #ifdef __WIN32__ 97 114 dbf = gdbm_open (argv[1], block_size, GDBM_READER, 00664, NULL, 0);
Note:
See TracChangeset
for help on using the changeset viewer.