From 3709d6c86c3e9ffe9676dd40d322e557b304f16c Mon Sep 17 00:00:00 2001 From: jesperpedersen Date: Tue, 7 Jan 2020 07:47:19 -0500 Subject: [PATCH] Use WORKER_SHUTDOWN for shutdown --- src/include/worker.h | 7 ++++--- src/libpgagroal/pipeline_perf.c | 10 +++++----- src/libpgagroal/worker.c | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/include/worker.h b/src/include/worker.h index 436f71d6..fd0f0d46 100644 --- a/src/include/worker.h +++ b/src/include/worker.h @@ -38,9 +38,10 @@ extern "C" { #define WORKER_SUCCESS 0 #define WORKER_FAILURE 1 -#define WORKER_CLIENT_FAILURE 2 -#define WORKER_SERVER_FAILURE 3 -#define WORKER_SERVER_FATAL 4 +#define WORKER_SHUTDOWN 2 +#define WORKER_CLIENT_FAILURE 3 +#define WORKER_SERVER_FAILURE 4 +#define WORKER_SERVER_FATAL 5 /** @struct * The worker structure for each IO event diff --git a/src/libpgagroal/pipeline_perf.c b/src/libpgagroal/pipeline_perf.c index 2ebd3ef0..e88891c4 100644 --- a/src/libpgagroal/pipeline_perf.c +++ b/src/libpgagroal/pipeline_perf.c @@ -122,17 +122,17 @@ performance_client(struct ev_loop *loop, struct ev_io *watcher, int revents) client_error: ZF_LOGD("client_fd %d - %s (%d)", wi->client_fd, strerror(errno), status); - ev_break (loop, EVBREAK_ONE); exit_code = WORKER_CLIENT_FAILURE; running = 0; + ev_break(loop, EVBREAK_ALL); return; server_error: ZF_LOGD("server_fd %d - %s (%d)", wi->server_fd, strerror(errno), status); - ev_break (loop, EVBREAK_ONE); exit_code = WORKER_SERVER_FAILURE; running = 0; + ev_break(loop, EVBREAK_ALL); return; } @@ -177,22 +177,22 @@ performance_server(struct ev_loop *loop, struct ev_io *watcher, int revents) /* We don't need to "free" the memory for the message */ /* pgagroal_free_message(msg); */ - ev_break (loop, EVBREAK_ONE); + ev_break(loop, EVBREAK_ONE); return; client_error: ZF_LOGD("client_fd %d - %s (%d)", wi->client_fd, strerror(errno), status); - ev_break (loop, EVBREAK_ONE); exit_code = WORKER_CLIENT_FAILURE; running = 0; + ev_break(loop, EVBREAK_ALL); return; server_error: ZF_LOGD("server_fd %d - %s (%d)", wi->server_fd, strerror(errno), status); - ev_break (loop, EVBREAK_ONE); exit_code = WORKER_SERVER_FAILURE; running = 0; + ev_break(loop, EVBREAK_ALL); return; } diff --git a/src/libpgagroal/worker.c b/src/libpgagroal/worker.c index 5df8df55..90c5cc8e 100644 --- a/src/libpgagroal/worker.c +++ b/src/libpgagroal/worker.c @@ -144,7 +144,7 @@ pgagroal_worker(int client_fd, char* address, void* shmem, void* pipeline_shmem) p.stop(&client_io); } - if (exit_code == WORKER_SUCCESS || exit_code == WORKER_CLIENT_FAILURE || config->connections[slot].has_security != SECURITY_INVALID) + if (exit_code == WORKER_SUCCESS || exit_code == WORKER_CLIENT_FAILURE) { pgagroal_return_connection(shmem, slot); } @@ -189,7 +189,7 @@ signal_cb(struct ev_loop *loop, ev_signal *w, int revents) ZF_LOGD("pgagroal: signal for slot %d", si->slot); - exit_code = WORKER_FAILURE; + exit_code = WORKER_SHUTDOWN; running = 0; ev_break(loop, EVBREAK_ALL); }