- console.log("Rereading " + json_filename);
- fs.open(json_filename, 'r+', function(err, fd) {
+ if (json_lock == 1) {
+ // Already processing; wait a bit.
+ json_lock = 2;
+ setTimeout(function() { json_lock = 1; reread_file(event, filename); }, 100);
+ return;
+ }
+ json_lock = 1;
+
+ console.log("Rereading " + JSON_FILENAME);
+ fs.open(JSON_FILENAME, 'r+', function(err, fd) {