aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-18 12:08:55 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-18 12:08:55 +0100
commitb07f3cc2e4fa873590d6d028c9ce03ecc926d9f4 (patch)
tree93e39b1e0edcce9d6fe3de8e2e5fd4f73716b1da /src/lua
parentcc5a2dab9bba0aecf1fbc51877d63a0f4b1fc890 (diff)
downloadrspamd-b07f3cc2e4fa873590d6d028c9ce03ecc926d9f4.tar.gz
rspamd-b07f3cc2e4fa873590d6d028c9ce03ecc926d9f4.zip
[Fix] Lua_tcp: Make write errors fatal and rework error handlers
Issue: #3097
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_tcp.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index 379d3d807..335d770d5 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -535,6 +535,7 @@ lua_tcp_push_error (struct lua_tcp_cbdata *cbd, gboolean is_fatal,
gint cbref, top;
struct lua_callback_state cbs;
lua_State *L;
+ gboolean callback_called = FALSE;
if (cbd->thread) {
va_start (ap, err);
@@ -591,11 +592,19 @@ lua_tcp_push_error (struct lua_tcp_cbdata *cbd, gboolean is_fatal,
lua_settop (L, top);
TCP_RELEASE (cbd);
+
+ callback_called = TRUE;
}
if (!is_fatal) {
- /* Stop on the first callback found */
- break;
+ if (callback_called) {
+ /* Stop on the first callback found */
+ break;
+ }
+ else {
+ /* Shift to another callback to inform about fatal error */
+ continue;
+ }
}
else {
lua_tcp_shift_handler (cbd);
@@ -841,14 +850,12 @@ lua_tcp_write_helper (struct lua_tcp_cbdata *cbd)
if (r == -1) {
if (!(cbd->ssl_conn)) {
- lua_tcp_push_error (cbd, FALSE,
+ lua_tcp_push_error (cbd, TRUE,
"IO write error while trying to write %d bytes: %s",
(gint) remain, strerror (errno));
- if (!IS_SYNC (cbd)) {
- /* sync connection methods perform this inside */
- lua_tcp_shift_handler (cbd);
- lua_tcp_plan_handler_event (cbd, TRUE, FALSE);
- }
+
+ msg_debug_tcp ("write error, terminate connection");
+ TCP_RELEASE (cbd);
}
return;