diff options
| author | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-09 14:17:16 +0200 |
|---|---|---|
| committer | Mikhail Burakov <mburakov@mailbox.org> | 2023-04-09 14:17:16 +0200 |
| commit | 3956ac7d094c3824bb18c9a2b49fd156533dd2ef (patch) | |
| tree | 5004f95cc9708d33d1bb9845a3799c0f990fff4d | |
| parent | 3e3ff72e71e7ba1f8c8d37c47a0f1e10db7aa96f (diff) | |
Fix occasional issues appearing on client disconnection
| -rw-r--r-- | main.c | 12 | ||||
| m--------- | toolbox | 0 |
2 files changed, 6 insertions, 6 deletions
@@ -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; } diff --git a/toolbox b/toolbox -Subproject c5ca05dd86910984cb3ab7e3a17718f7be6ba27 +Subproject c5334a46523b9ac959c002fbc23a25eeccf6359 |
