summaryrefslogtreecommitdiffstats
path: root/src/worker/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/worker/main.cpp')
-rw-r--r--src/worker/main.cpp19
1 files changed, 15 insertions, 4 deletions
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