Skip to content

Commit

Permalink
[Fix] Add workaround for ENOBUFS error on sending
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Nov 21, 2022
1 parent b831103 commit afcda99
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/libserver/rspamd_control.c
Expand Up @@ -925,6 +925,8 @@ rspamd_srv_handler (EV_P_ ev_io *w, int revents)
* Usually this means that a worker is dead, so do not try to read
* anything
*/
msg_err ("cannot read from worker's srv pipe connection closed; command = %s",
rspamd_srv_command_to_string(cmd.type));
ev_io_stop (EV_A_ w);
}
else if (r != sizeof (cmd)) {
Expand Down Expand Up @@ -1144,6 +1146,16 @@ rspamd_srv_request_handler (EV_P_ ev_io *w, int revents)
r = sendmsg (w->fd, &msg, 0);

if (r == -1) {
if (r == ENOBUFS) {
/* On BSD derived systems we can have this error when trying to send
* requests too fast.
* It might be good to retry...
*/
msg_info ("cannot write to server pipe: %s; command = %s; retrying sending",
strerror (errno),
rspamd_srv_command_to_string(rd->cmd.type));
return;
}
msg_err ("cannot write to server pipe: %s; command = %s", strerror (errno),
rspamd_srv_command_to_string(rd->cmd.type));
goto cleanup;
Expand Down Expand Up @@ -1185,17 +1197,18 @@ rspamd_srv_request_handler (EV_P_ ev_io *w, int revents)
rfd = *(int *) CMSG_DATA(CMSG_FIRSTHDR (&msg));
}

/* Reply has been received */
if (rd->handler) {
rd->handler (rd->worker, &rd->rep, rfd, rd->ud);
}

goto cleanup;
}

return;

cleanup:

if (rd->handler) {
rd->handler (rd->worker, &rd->rep, rfd, rd->ud);
}

cleanup:
ev_io_stop (EV_A_ w);
g_free (rd);
}
Expand Down

0 comments on commit afcda99

Please sign in to comment.