(db, method)
| 88 | var FORKCALLBACKS; |
| 89 | |
| 90 | function clusterlock(db, method) { |
| 91 | Fs.open(db.filenameLock, 'wx', function(err, fd) { |
| 92 | |
| 93 | if (err) { |
| 94 | setTimeout(clusterlock, 100, db, method); |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | Fs.write(fd, F.id.toString(), function(err) { |
| 99 | err && F.error('NoSQLStream.lock.write()', err); |
| 100 | Fs.close(fd, function(err) { |
| 101 | err && F.error('NoSQLStream.lock.close()', err); |
| 102 | db.locked = true; |
| 103 | db[method](); |
| 104 | }); |
| 105 | }); |
| 106 | }); |
| 107 | } |
| 108 | |
| 109 | function clusterunlock(db) { |
| 110 | if (db.locked) { |