diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-01-07 00:52:45 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-01-07 00:52:45 +0100 |
commit | 2d585e7c7da4b9e6a53cb795f1af5fb43105c94e (patch) | |
tree | fec0d5579c67301a3d832d4a8b83bebc089ce486 | |
parent | 6607f16375b26b588c148e0b5bfd61bc37696a7e (diff) | |
download | rvnit-2d585e7c7da4b9e6a53cb795f1af5fb43105c94e.tar.gz rvnit-2d585e7c7da4b9e6a53cb795f1af5fb43105c94e.tar.xz rvnit-2d585e7c7da4b9e6a53cb795f1af5fb43105c94e.zip |
socket thread: only write data on success
-rw-r--r-- | rvnit.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/rvnit.c b/rvnit.c index fa15889..021ad42 100644 --- a/rvnit.c +++ b/rvnit.c @@ -212,12 +212,11 @@ socket_loop(void* ignored) char buf[63]; - int rd = read(connfd, buf, sizeof buf); + int rd = read(connfd, buf, sizeof buf - 1); if (rd <= 0) { close(connfd); continue; } - write(connfd, "ok\n", 3); char cmd = buf[0]; @@ -248,6 +247,7 @@ socket_loop(void* ignored) pthread_mutex_lock(&services_lock); for (int i = 0; i < MAX_SV; i++) { if (strcmp(services[i].name, buf+1) == 0) { + write(connfd, "ok\n", 3); if (cmd == 'd') { printf("setting %s down\n", services[i].name); @@ -270,16 +270,19 @@ socket_loop(void* ignored) } if (cmd == 'r') { + write(connfd, "ok\n", 3); want_rescandir = 1; want_rescan = 1; pthread_kill(main_thread, SIGCONT); } if (cmd == 'X') { + write(connfd, "ok\n", 3); want_shutdown = 1; pthread_kill(main_thread, SIGCONT); } if (cmd == 'R') { + write(connfd, "ok\n", 3); want_shutdown = 1; want_reboot = 1; pthread_kill(main_thread, SIGCONT); |