refactor: remove sideeffects from udp_timedout

This commit is contained in:
yrutschle 2021-07-18 21:50:40 +02:00
parent c43882c85f
commit 7fb65ad0ac
2 changed files with 2 additions and 2 deletions

View File

@ -468,6 +468,7 @@ void udp_timeouts(struct select_info* fd_info)
if (FD_ISSET(i, &fd_info->fds_r) || FD_ISSET(i, &fd_info->fds_w)) {
struct connection* cnx = collection_get_cnx_from_fd(fd_info->collection, i);
if (cnx && udp_timedout(cnx)) {
close(cnx->target_sock);
FD_CLR(i, &fd_info->fds_r);
FD_CLR(i, &fd_info->fds_w);
collection_remove_cnx(fd_info->collection, cnx);

View File

@ -137,9 +137,8 @@ int udp_timedout(struct connection* cnx)
if (cnx->type != SOCK_DGRAM) return 0; /* Not a UDP connection */
if ((now - cnx->last_active > cnx->proto->udp_timeout)) {
close(cnx->target_sock);
if (cfg.verbose > 3)
fprintf(stderr, "disconnect timed out UDP %d\n", cnx->target_sock);
fprintf(stderr, "timed out UDP %d\n", cnx->target_sock);
return 1;
}
return 0;