server: error handling fixes
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/server.c b/server.c
index e6c49cc..db9d859 100644
--- a/server.c
+++ b/server.c
@@ -77,6 +77,8 @@
break;
else if (errno == EAGAIN || errno == EINTR)
continue;
+ else
+ break;
} while (!exit_backend);
if (!len)
@@ -100,6 +102,8 @@
break;
else if (errno == EAGAIN || errno == EINTR)
continue;
+ else
+ break;
} while (!exit_backend);
if (!len)
@@ -965,25 +969,14 @@
return ret;
}
-static void sig_int(int sig)
+void fio_server_got_signal(int signal)
{
- fio_terminate_threads(TERMINATE_ALL);
- exit_backend = 1;
-}
-
-static void server_signal_handler(void)
-{
- 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 @@
pid_t pid;
int ret;
- server_signal_handler();
-
if (!pidfile)
return fio_server();