X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=server.c;h=db9d8594c8b84c59003cf0d58270bbca197c8fb5;hp=e6c49cc88abfeee02a5aa9163fc89166d43a10fe;hb=5fd0acbd212296542d396b07e1873b9e3093b76f;hpb=ea5aa1be68de71f9f02eb3d6f4db726adcafb40a diff --git a/server.c b/server.c index e6c49cc8..db9d8594 100644 --- a/server.c +++ b/server.c @@ -77,6 +77,8 @@ int fio_send_data(int sk, const void *p, unsigned int len) break; else if (errno == EAGAIN || errno == EINTR) continue; + else + break; } while (!exit_backend); if (!len) @@ -100,6 +102,8 @@ int fio_recv_data(int sk, void *p, unsigned int len) break; else if (errno == EAGAIN || errno == EINTR) continue; + else + break; } while (!exit_backend); if (!len) @@ -965,25 +969,14 @@ static int fio_server(void) return ret; } -static void sig_int(int sig) -{ - fio_terminate_threads(TERMINATE_ALL); - exit_backend = 1; -} - -static void server_signal_handler(void) +void fio_server_got_signal(int signal) { - struct sigaction act; - - memset(&act, 0, sizeof(act)); - act.sa_handler = sig_int; - act.sa_flags = SA_RESTART; - sigaction(SIGINT, &act, NULL); - - memset(&act, 0, sizeof(act)); - act.sa_handler = sig_int; - act.sa_flags = SA_RESTART; - sigaction(SIGTERM, &act, NULL); + if (signal == SIGPIPE) + server_fd = -1; + else { + log_info("\nfio: terminating on signal %d\n", signal); + exit_backend = 1; + } } static int check_existing_pidfile(const char *pidfile) @@ -1036,8 +1029,6 @@ int fio_start_server(char *pidfile) pid_t pid; int ret; - server_signal_handler(); - if (!pidfile) return fio_server();