]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Lua_tcp: Deal with temporary fails on write
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Oct 2019 12:56:17 +0000 (13:56 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Oct 2019 12:56:17 +0000 (13:56 +0100)
Issue: #3097

src/lua/lua_tcp.c

index 335d770d5bf65e5a31ff2413f6a1f2985643ad94..09d572199d59f68bc21fd0271aeeb35c94352b75 100644 (file)
@@ -850,12 +850,19 @@ lua_tcp_write_helper (struct lua_tcp_cbdata *cbd)
 
        if (r == -1) {
                if (!(cbd->ssl_conn)) {
-                       lua_tcp_push_error (cbd, TRUE,
-                                       "IO write error while trying to write %d bytes: %s",
-                                       (gint) remain, strerror (errno));
+                       if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
+                               msg_debug_tcp ("got temporary failure, retry write");
+                               lua_tcp_plan_handler_event (cbd, TRUE, TRUE);
+                               return;
+                       }
+                       else {
+                               lua_tcp_push_error (cbd, TRUE,
+                                               "IO write error while trying to write %d bytes: %s",
+                                               (gint) remain, strerror (errno));
 
-                       msg_debug_tcp ("write error, terminate connection");
-                       TCP_RELEASE (cbd);
+                               msg_debug_tcp ("write error, terminate connection");
+                               TCP_RELEASE (cbd);
+                       }
                }
 
                return;