summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMikhail Burakov <mburakov@mailbox.org>2023-04-09 14:17:16 +0200
committerMikhail Burakov <mburakov@mailbox.org>2023-04-09 14:17:16 +0200
commit3956ac7d094c3824bb18c9a2b49fd156533dd2ef (patch)
tree5004f95cc9708d33d1bb9845a3799c0f990fff4d /main.c
parent3e3ff72e71e7ba1f8c8d37c47a0f1e10db7aa96f (diff)
Fix occasional issues appearing on client disconnection
Diffstat (limited to 'main.c')
-rw-r--r--main.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/main.c b/main.c
index 121085a..1b27a0d 100644
--- a/main.c
+++ b/main.c
@@ -108,10 +108,6 @@ static void MaybeDropClient(struct Contexts* contexts) {
close(contexts->client_fd);
contexts->client_fd = -1;
}
- if (timerfd_settime(contexts->timer_fd, 0, &spec, NULL)) {
- LOG("Failed to disarm timer (%s)", strerror(errno));
- g_signal = SIGABRT;
- }
}
static void OnTimerExpire(void* user) {
@@ -130,8 +126,12 @@ static void OnTimerExpire(void* user) {
return;
}
if (contexts->client_fd == -1) {
- // TODO(mburakov): Is this actually possible?
- LOG("Timer expired with disconnected client");
+ // mburakov: Timer must disarm itself AFTER reading.
+ static const struct itimerspec spec = {0};
+ if (timerfd_settime(contexts->timer_fd, 0, &spec, NULL)) {
+ LOG("Failed to disarm timer (%s)", strerror(errno));
+ g_signal = SIGABRT;
+ }
return;
}