summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohann Latocha2011-07-14 19:05:05 +0200
committerJohann Latocha2011-07-14 19:05:05 +0200
commitd5df4b979045fa94a45bfa3b2b820285bdc5de12 (patch)
tree68dd204f6a3a563d26a25ce8d99dd77dc8ee69da
parentIgnore eclipse project files (diff)
downloadnbd-broker-master.tar.gz
nbd-broker-master.tar.xz
nbd-broker-master.zip
Handle nbd-server startup errorHEADmaster
-rw-r--r--src/client/main.cpp2
-rw-r--r--src/worker/main.cpp19
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