diff options
author | Johann Latocha | 2011-07-14 19:05:05 +0200 |
---|---|---|
committer | Johann Latocha | 2011-07-14 19:05:05 +0200 |
commit | d5df4b979045fa94a45bfa3b2b820285bdc5de12 (patch) | |
tree | 68dd204f6a3a563d26a25ce8d99dd77dc8ee69da | |
parent | Ignore eclipse project files (diff) | |
download | nbd-broker-d5df4b979045fa94a45bfa3b2b820285bdc5de12.tar.gz nbd-broker-d5df4b979045fa94a45bfa3b2b820285bdc5de12.tar.xz nbd-broker-d5df4b979045fa94a45bfa3b2b820285bdc5de12.zip |
-rw-r--r-- | src/client/main.cpp | 2 | ||||
-rw-r--r-- | src/worker/main.cpp | 19 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/client/main.cpp b/src/client/main.cpp index dfec059..10a497b 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) } else if (ret == GEARMAN_WORK_FAIL) { - cerr << "[ERROR] " << msg << endl; + cerr << "[REMOTE ERROR] " << msg << endl; cerr << "[ERROR] Work failed" << endl; free(result); } diff --git a/src/worker/main.cpp b/src/worker/main.cpp index ff97041..a0d6cb4 100644 --- a/src/worker/main.cpp +++ b/src/worker/main.cpp @@ -70,11 +70,22 @@ static void *start_nbd_server(gearman_job_st *job, void *context, stringstream command; command << "nbd-server " << _nbd_server_port << " " << *image; cout << "[DEBUG] " << "Running command: " << command.str() << endl; - system(command.str().c_str()); + int ret = system(command.str().c_str()); + if (ret == 0) + { + current_port = _nbd_server_port; + _map[*image] = _nbd_server_port; + _nbd_server_port++; + } + else + { + cerr << "[ERROR] Command execution failed, aborting!" << endl; + char msg[] = "Couldn't start nbd-server"; + gearman_job_send_data(job, msg, sizeof(msg)); + *ret_ptr = GEARMAN_WORK_FAIL; + return NULL; + } - current_port = _nbd_server_port; - _map[*image] = _nbd_server_port; - _nbd_server_port++; } // send port number to client |