Nothing to see here, move along...

This commit is contained in:
2016-09-17 15:02:58 +03:00
parent 1c2473505d
commit 95a6f1fe97
8 changed files with 54 additions and 15 deletions

22
rmps.c
View File

@@ -2,6 +2,7 @@
#include "confparser.h"
#include "agent_pool.h"
#include "client_pool.h"
#include "job_queue.h"
#include "rmps.h"
#include <pthread.h>
#include <unistd.h>
@@ -172,25 +173,24 @@ static int open_listener(int port)
sd = socket(addr.sin_family, SOCK_STREAM, 0);
if (sd < 0) {
log(ERROR, "Failed to create socket");
log(INFO, "RMPS failed to start, shutting down...");
atexit(cleanup);
goto exit;
}
if (set_reuse_addr(sd) < 0) {
log(ERROR, "Failed to set reuse on address - Aborting...", port);
log(INFO, "RMPS failed to start, shutting down...");
atexit(cleanup);
goto exit;
}
if (bind(sd, (struct sockaddr*)&addr, sizeof(addr)) != 0) {
log(ERROR, "Failed to bind on port: %d - Aborting...", port);
log(INFO, "RMPS failed to start, shutting down...");
atexit(cleanup);
goto exit;
}
if (listen(sd, 10) != 0) {
log(ERROR, "Failed to start listener on port %d - Aborting...", port);
log(INFO, "RMPS failed to start, shutting down...");
atexit(cleanup);
goto exit;
}
return sd;
exit:
log(INFO, "RMPS failed to start, shutting down...");
atexit(cleanup);
}
/* Init server and create context */
@@ -296,7 +296,11 @@ void launch_rmps(struct conf_table *conf, int fork_flag)
pool_args[1].size = conf->rmps.client_poolsize;
log(VERBOSE, "Creating client thread pool (mutex).");
pthread_create(&pool[1], NULL, client_pool, &pool_args[1]);
if (start_job_queue(conf->rmps.agent_poolsize) == FAIL) {
log(ERROR, "On start_job_queue(), RMPS failed to start, shutting down...");
atexit(cleanup);
return;
}
pthread_join(pool[0], NULL);
pthread_join(pool[1], NULL);
}