Loading lib/communication.h +0 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #ifndef __DAEMON_COMMUNICATION_H__ #define __DAEMON_COMMUNICATION_H__ #include "nornsctl.h" #include "requests.h" #pragma GCC visibility push(hidden) Loading lib/norns.c +22 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include "communication.h" #define LIBNORNS_LOG_PREFIX "libnorns" #define MIN_WAIT_TIME ((useconds_t) 250*1e3) __attribute__((constructor)) static void Loading Loading @@ -101,13 +102,30 @@ norns_status(norns_iotask_t* task, norns_stat_t* stats) { norns_error_t norns_wait(norns_iotask_t* task) { norns_error_t rv; norns_stat_t stats; if(task == NULL) { ERR("invalid arguments"); return NORNS_EBADARGS; } ///TODO while(1) { do { rv = send_status_request(task, &stats); if(rv != NORNS_SUCCESS) { ERR("error waiting for request: %s", norns_strerror(rv)); return rv; } return send_status_request(task, NULL); if(stats.st_status == NORNS_EFINISHED) { return NORNS_SUCCESS; } // wait for 250 milliseconds // before retrying usleep(MIN_WAIT_TIME); } while(true); return NORNS_SUCCESS; } tests/api-copy-local-data.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -130,7 +130,9 @@ struct test_env { } } #ifndef USE_REAL_DAEMON fake_daemon m_td; #endif std::set<std::string> m_backends; std::unordered_map<std::string, bfs::path> m_dirs; }; Loading Loading @@ -180,8 +182,11 @@ SCENARIO("copy local data", "[api::norns_submit_copy_local]") { } // wait until the task completes // TODO: replace with norns_wait() once it's available //sleep(15); rv = norns_wait(&task); THEN("NORNS_SUCCESS is returned") { REQUIRE(rv == NORNS_SUCCESS); } } Loading Loading
lib/communication.h +0 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #ifndef __DAEMON_COMMUNICATION_H__ #define __DAEMON_COMMUNICATION_H__ #include "nornsctl.h" #include "requests.h" #pragma GCC visibility push(hidden) Loading
lib/norns.c +22 −4 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ #include "communication.h" #define LIBNORNS_LOG_PREFIX "libnorns" #define MIN_WAIT_TIME ((useconds_t) 250*1e3) __attribute__((constructor)) static void Loading Loading @@ -101,13 +102,30 @@ norns_status(norns_iotask_t* task, norns_stat_t* stats) { norns_error_t norns_wait(norns_iotask_t* task) { norns_error_t rv; norns_stat_t stats; if(task == NULL) { ERR("invalid arguments"); return NORNS_EBADARGS; } ///TODO while(1) { do { rv = send_status_request(task, &stats); if(rv != NORNS_SUCCESS) { ERR("error waiting for request: %s", norns_strerror(rv)); return rv; } return send_status_request(task, NULL); if(stats.st_status == NORNS_EFINISHED) { return NORNS_SUCCESS; } // wait for 250 milliseconds // before retrying usleep(MIN_WAIT_TIME); } while(true); return NORNS_SUCCESS; }
tests/api-copy-local-data.cpp +7 −2 Original line number Diff line number Diff line Loading @@ -130,7 +130,9 @@ struct test_env { } } #ifndef USE_REAL_DAEMON fake_daemon m_td; #endif std::set<std::string> m_backends; std::unordered_map<std::string, bfs::path> m_dirs; }; Loading Loading @@ -180,8 +182,11 @@ SCENARIO("copy local data", "[api::norns_submit_copy_local]") { } // wait until the task completes // TODO: replace with norns_wait() once it's available //sleep(15); rv = norns_wait(&task); THEN("NORNS_SUCCESS is returned") { REQUIRE(rv == NORNS_SUCCESS); } } Loading