Skip to content

Commit

Permalink
properly close serial client without unnecessary errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Sep 16, 2024
1 parent c16b9f5 commit c965de1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,13 @@ static void modesCloseClient(struct client *c) {
}

epoll_ctl(Modes.net_epfd, EPOLL_CTL_DEL, c->fd, &c->epollEvent);
anetCloseSocket(c->fd);
if (c->serial) {
if (close(c->fd) < 0) {
fprintf(stderr, "Serial client close error: %s\n", strerror(errno));
}
} else {
anetCloseSocket(c->fd);
}
c->service->connections--;
Modes.modesClientCount--;
if (c->service->writer) {
Expand Down Expand Up @@ -5428,7 +5434,7 @@ void modesNetPeriodicWork(void) {
Modes.services_in.event_progress = 0;
Modes.services_out.event_progress = 0;

if (Modes.debug_serial && Modes.net_event_count > -1) {
if (Modes.debug_serial && Modes.net_event_count > 0) {
fprintTimePrecise(stderr, mstime()); fprintf(stderr, " event count %d wait_ms %d\n", Modes.net_event_count, (int) wait_ms);
}

Expand Down

0 comments on commit c965de1

Please sign in to comment.