Skip to content

Commit

Permalink
Use WORKER_SHUTDOWN for shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperpedersen committed Jan 7, 2020
1 parent 7f01b29 commit 3709d6c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/include/worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/libpgagroal/pipeline_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions src/libpgagroal/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

0 comments on commit 3709d6c

Please sign in to comment.