From 710ba20acc39ff031b347e212a2215b30f8e21a8 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 27 Dec 2016 13:08:04 +0100 Subject: [PATCH] Add 1ms delay as a workaround for "faster" requests than facade update in osrm-routed --- features/lib/osrm_loader.js | 6 +++++- include/engine/data_watchdog.hpp | 4 ++-- src/storage/storage.cpp | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/features/lib/osrm_loader.js b/features/lib/osrm_loader.js index 197e4b5a2..09b92811a 100644 --- a/features/lib/osrm_loader.js +++ b/features/lib/osrm_loader.js @@ -99,6 +99,7 @@ class OSRMDatastoreLoader extends OSRMBaseLoader { if (err) return callback(err); if (!this.osrmIsRunning()) this.launch(callback); else { + // some osrm-routed output prior this line can appear in the prevoius log file this.scope.setupOutputLog(this.child, fs.createWriteStream(this.scope.scenarioLogFile, {'flags': 'a'})); callback(); } @@ -108,7 +109,10 @@ class OSRMDatastoreLoader extends OSRMBaseLoader { loadData (callback) { this.scope.runBin('osrm-datastore', this.inputFile, this.scope.environment, (err) => { if (err) return callback(new Error('*** osrm-datastore exited with ' + err.code + ': ' + err)); - callback(); + // in case of false positive results with a dummy 1ms delay an stdout monitor + // this.child.stdout.on('data', facade_monitor) must be added and wait for + // "updated facade to region" in stdout + setTimeout(callback, 1); }); } diff --git a/include/engine/data_watchdog.hpp b/include/engine/data_watchdog.hpp index a22e23038..595ca4d92 100644 --- a/include/engine/data_watchdog.hpp +++ b/include/engine/data_watchdog.hpp @@ -65,10 +65,10 @@ class DataWatchdog { if (timestamp != current->timestamp) { - util::Log() << "updating facade to region " << storage::regionToString(current->region) - << " with timestamp " << current->timestamp; facade = std::make_shared(current->region); timestamp = current->timestamp; + util::Log() << "updated facade to region " << storage::regionToString(current->region) + << " with timestamp " << current->timestamp; } barrier.region_condition.wait(current_region_lock); diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index f4ad41fa0..2b36c377f 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -100,6 +100,8 @@ int Storage::Run() storage::SharedMemory::Remove(next_region); } + util::Log() << "Loading data into " << regionToString(next_region) << " timestamp " << next_timestamp; + // Populate a memory layout into stack memory DataLayout layout; PopulateLayout(layout);