diff options
-rw-r--r-- | src/client/rspamdclient.c | 11 | ||||
-rw-r--r-- | src/controller.c | 19 | ||||
-rw-r--r-- | src/fuzzy_storage.c | 20 | ||||
-rw-r--r-- | src/libserver/protocol.c | 2 | ||||
-rw-r--r-- | src/libserver/rspamd_control.c | 13 | ||||
-rw-r--r-- | src/libserver/worker_util.c | 12 | ||||
-rw-r--r-- | src/libutil/http_connection.c | 75 | ||||
-rw-r--r-- | src/libutil/http_connection.h | 32 | ||||
-rw-r--r-- | src/libutil/http_router.c | 16 | ||||
-rw-r--r-- | src/libutil/map.c | 6 | ||||
-rw-r--r-- | src/lua/lua_http.c | 6 | ||||
-rw-r--r-- | src/plugins/surbl.c | 3 | ||||
-rw-r--r-- | src/rspamadm/control.c | 5 | ||||
-rw-r--r-- | src/rspamd_proxy.c | 31 | ||||
-rw-r--r-- | src/worker.c | 9 |
15 files changed, 113 insertions, 147 deletions
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c index 54cd490e6..a2ff85458 100644 --- a/src/client/rspamdclient.c +++ b/src/client/rspamdclient.c @@ -118,9 +118,7 @@ rspamd_client_finish_handler (struct rspamd_http_connection *conn, rspamd_http_connection_reset (c->http_conn); rspamd_http_connection_read_message (c->http_conn, c->req, - c->fd, - &c->timeout, - c->ev_base); + &c->timeout); return 0; } else { @@ -258,6 +256,7 @@ rspamd_client_init (struct rspamd_http_context *http_ctx, conn->fd = fd; conn->req_sent = FALSE; conn->http_conn = rspamd_http_connection_new (http_ctx, + fd, rspamd_client_body_handler, rspamd_client_error_handler, rspamd_client_finish_handler, @@ -443,12 +442,12 @@ rspamd_client_command (struct rspamd_client_connection *conn, if (compressed) { rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL, - "application/x-compressed", req, conn->fd, - &conn->timeout, conn->ev_base); + "application/x-compressed", req, + &conn->timeout); } else { rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL, - "text/plain", req, conn->fd, &conn->timeout, conn->ev_base); + "text/plain", req, &conn->timeout); } return TRUE; diff --git a/src/controller.c b/src/controller.c index a6214655a..350745f3c 100644 --- a/src/controller.c +++ b/src/controller.c @@ -1078,8 +1078,8 @@ rspamd_controller_handle_get_map (struct rspamd_http_connection_entry *conn_ent, rspamd_http_connection_reset (conn_ent->conn); rspamd_http_router_insert_headers (conn_ent->rt, reply); rspamd_http_connection_write_message (conn_ent->conn, reply, NULL, - "text/plain", conn_ent, conn_ent->conn->fd, - conn_ent->rt->ptv, conn_ent->rt->ev_base); + "text/plain", conn_ent, + conn_ent->rt->ptv); conn_ent->is_reply = TRUE; return 0; @@ -1942,8 +1942,7 @@ rspamd_controller_scan_reply (struct rspamd_task *task) rspamd_http_connection_reset (conn_ent->conn); rspamd_http_router_insert_headers (conn_ent->rt, msg); rspamd_http_connection_write_message (conn_ent->conn, msg, NULL, - "application/json", conn_ent, conn_ent->conn->fd, conn_ent->rt->ptv, - conn_ent->rt->ev_base); + "application/json", conn_ent, conn_ent->rt->ptv); conn_ent->is_reply = TRUE; } @@ -2911,9 +2910,7 @@ rspamd_controller_handle_ping (struct rspamd_http_connection_entry *conn_ent, NULL, "text/plain", conn_ent, - conn_ent->conn->fd, - conn_ent->rt->ptv, - conn_ent->rt->ev_base); + conn_ent->rt->ptv); conn_ent->is_reply = TRUE; return 0; @@ -2947,9 +2944,7 @@ rspamd_controller_handle_unknown (struct rspamd_http_connection_entry *conn_ent, NULL, "text/plain", conn_ent, - conn_ent->conn->fd, - conn_ent->rt->ptv, - conn_ent->rt->ev_base); + conn_ent->rt->ptv); conn_ent->is_reply = TRUE; } else { @@ -2965,9 +2960,7 @@ rspamd_controller_handle_unknown (struct rspamd_http_connection_entry *conn_ent, NULL, "text/plain", conn_ent, - conn_ent->conn->fd, - conn_ent->rt->ptv, - conn_ent->rt->ev_base); + conn_ent->rt->ptv); conn_ent->is_reply = TRUE; } diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index a02db290b..8dae4fb4b 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -531,8 +531,7 @@ fuzzy_mirror_updates_version_cb (guint64 rev64, void *ud) double_to_tv (ctx->sync_timeout, &tv); rspamd_http_connection_write_message (conn->http_conn, msg, NULL, NULL, conn, - conn->sock, - &tv, ctx->ev_base); + &tv); msg_info ("send update request to %s", m->name); g_array_free (cbdata->updates_pending, TRUE); @@ -619,6 +618,7 @@ rspamd_fuzzy_send_update_mirror (struct rspamd_fuzzy_storage_ctx *ctx, conn->http_conn = rspamd_http_connection_new ( ctx->http_ctx, + conn->sock, NULL, fuzzy_mirror_error_handler, fuzzy_mirror_finish_handler, @@ -1570,8 +1570,7 @@ rspamd_fuzzy_mirror_send_reply (struct fuzzy_master_update_session *session, rspamd_http_connection_reset (session->conn); rspamd_http_connection_write_message (session->conn, msg, NULL, "text/plain", - session, session->sock, &session->ctx->master_io_tv, - session->ctx->ev_base); + session, &session->ctx->master_io_tv); } static void @@ -1712,9 +1711,7 @@ rspamd_fuzzy_collection_send_error (struct rspamd_http_connection_entry *entry, NULL, "text/plain", entry, - entry->conn->fd, - entry->rt->ptv, - entry->rt->ev_base); + entry->rt->ptv); entry->is_reply = TRUE; } @@ -1739,9 +1736,7 @@ rspamd_fuzzy_collection_send_fstring (struct rspamd_http_connection_entry *entry NULL, "application/octet-stream", entry, - entry->conn->fd, - entry->rt->ptv, - entry->rt->ev_base); + entry->rt->ptv); entry->is_reply = TRUE; } @@ -1997,6 +1992,7 @@ accept_fuzzy_mirror_socket (gint fd, short what, void *arg) session->uid[sizeof (session->uid) - 1] = '\0'; http_conn = rspamd_http_connection_new ( ctx->http_ctx, + nfd, NULL, rspamd_fuzzy_mirror_error_handler, rspamd_fuzzy_mirror_finish_handler, @@ -2011,9 +2007,7 @@ accept_fuzzy_mirror_socket (gint fd, short what, void *arg) rspamd_http_connection_read_message (http_conn, session, - nfd, - &ctx->master_io_tv, - ctx->ev_base); + &ctx->master_io_tv); } /* diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 5bcfbc37a..2a9cc605a 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -1737,7 +1737,7 @@ rspamd_protocol_write_reply (struct rspamd_task *task) rspamd_http_connection_reset (task->http_conn); rspamd_http_connection_write_message (task->http_conn, msg, NULL, - ctype, task, task->sock, &task->tv, task->ev_base); + ctype, task, &task->tv); task->processed_stages |= RSPAMD_TASK_STAGE_REPLIED; } diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index fb0fc22b6..7131993ce 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -129,9 +129,7 @@ rspamd_control_send_error (struct rspamd_control_session *session, NULL, "application/json", session, - session->fd, - &io_timeout, - session->rspamd_main->ev_base); + &io_timeout); } static void @@ -154,9 +152,7 @@ rspamd_control_send_ucl (struct rspamd_control_session *session, NULL, "application/json", session, - session->fd, - &io_timeout, - session->rspamd_main->ev_base); + &io_timeout); } static void @@ -512,14 +508,15 @@ rspamd_control_process_client_socket (struct rspamd_main *rspamd_main, session->fd = fd; session->conn = rspamd_http_connection_new (rspamd_main->http_ctx, + fd, NULL, rspamd_control_error_handler, rspamd_control_finish_handler, 0, RSPAMD_HTTP_SERVER); session->rspamd_main = rspamd_main; - rspamd_http_connection_read_message (session->conn, session, session->fd, - &io_timeout, rspamd_main->ev_base); + rspamd_http_connection_read_message (session->conn, session, + &io_timeout); } struct rspamd_worker_control_data { diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index a52dd3ccb..06296bba2 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -435,9 +435,7 @@ rspamd_controller_send_error (struct rspamd_http_connection_entry *entry, NULL, "application/json", entry, - entry->conn->fd, - entry->rt->ptv, - entry->rt->ev_base); + entry->rt->ptv); entry->is_reply = TRUE; } @@ -469,9 +467,7 @@ rspamd_controller_send_string (struct rspamd_http_connection_entry *entry, NULL, "application/json", entry, - entry->conn->fd, - entry->rt->ptv, - entry->rt->ev_base); + entry->rt->ptv); entry->is_reply = TRUE; } @@ -497,9 +493,7 @@ rspamd_controller_send_ucl (struct rspamd_http_connection_entry *entry, NULL, "application/json", entry, - entry->conn->fd, - entry->rt->ptv, - entry->rt->ev_base); + entry->rt->ptv); entry->is_reply = TRUE; } diff --git a/src/libutil/http_connection.c b/src/libutil/http_connection.c index fd052951b..1c4bec380 100644 --- a/src/libutil/http_connection.c +++ b/src/libutil/http_connection.c @@ -687,13 +687,11 @@ rspamd_http_on_message_complete (http_parser * parser) static void rspamd_http_simple_client_helper (struct rspamd_http_connection *conn) { - struct event_base *base; struct rspamd_http_connection_private *priv; gpointer ssl; gint request_method; priv = conn->priv; - base = conn->priv->ev.ev_base; ssl = priv->ssl; priv->ssl = NULL; request_method = priv->msg->method; @@ -702,12 +700,12 @@ rspamd_http_simple_client_helper (struct rspamd_http_connection *conn) /* Plan read message */ if (conn->opts & RSPAMD_HTTP_CLIENT_SHARED) { - rspamd_http_connection_read_message_shared (conn, conn->ud, conn->fd, - conn->priv->ptv, base); + rspamd_http_connection_read_message_shared (conn, conn->ud, + conn->priv->ptv); } else { - rspamd_http_connection_read_message (conn, conn->ud, conn->fd, - conn->priv->ptv, base); + rspamd_http_connection_read_message (conn, conn->ud, + conn->priv->ptv); } priv->msg->method = request_method; @@ -1036,6 +1034,7 @@ rspamd_http_parser_reset (struct rspamd_http_connection *conn) struct rspamd_http_connection * rspamd_http_connection_new ( struct rspamd_http_context *ctx, + gint fd, rspamd_http_body_handler_t body_handler, rspamd_http_error_handler_t error_handler, rspamd_http_finish_handler_t finish_handler, @@ -1055,7 +1054,7 @@ rspamd_http_connection_new ( conn->body_handler = body_handler; conn->error_handler = error_handler; conn->finish_handler = finish_handler; - conn->fd = -1; + conn->fd = fd; conn->ref = 1; conn->finished = FALSE; @@ -1303,13 +1302,12 @@ rspamd_http_connection_free (struct rspamd_http_connection *conn) static void rspamd_http_connection_read_message_common (struct rspamd_http_connection *conn, - gpointer ud, gint fd, struct timeval *timeout, struct event_base *base, + gpointer ud, struct timeval *timeout, gint flags) { struct rspamd_http_connection_private *priv = conn->priv; struct rspamd_http_message *req; - conn->fd = fd; conn->ud = ud; req = rspamd_http_new_message ( conn->type == RSPAMD_HTTP_SERVER ? HTTP_REQUEST : HTTP_RESPONSE); @@ -1341,13 +1339,12 @@ rspamd_http_connection_read_message_common (struct rspamd_http_connection *conn, priv->flags |= RSPAMD_HTTP_CONN_FLAG_NEW_HEADER; event_set (&priv->ev, - fd, + conn->fd, EV_READ | EV_PERSIST, rspamd_http_event_handler, conn); - if (base != NULL) { - event_base_set (base, &priv->ev); - } + + event_base_set (priv->ctx->ev_base, &priv->ev); priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_RESETED; event_add (&priv->ev, priv->ptv); @@ -1355,16 +1352,16 @@ rspamd_http_connection_read_message_common (struct rspamd_http_connection *conn, void rspamd_http_connection_read_message (struct rspamd_http_connection *conn, - gpointer ud, gint fd, struct timeval *timeout, struct event_base *base) + gpointer ud, struct timeval *timeout) { - rspamd_http_connection_read_message_common (conn, ud, fd, timeout, base, 0); + rspamd_http_connection_read_message_common (conn, ud, timeout, 0); } void rspamd_http_connection_read_message_shared (struct rspamd_http_connection *conn, - gpointer ud, gint fd, struct timeval *timeout, struct event_base *base) + gpointer ud, struct timeval *timeout) { - rspamd_http_connection_read_message_common (conn, ud, fd, timeout, base, + rspamd_http_connection_read_message_common (conn, ud, timeout, RSPAMD_HTTP_FLAG_SHMEM); } @@ -1720,9 +1717,12 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted, static void rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn, - struct rspamd_http_message *msg, const gchar *host, const gchar *mime_type, - gpointer ud, gint fd, struct timeval *timeout, struct event_base *base, - gboolean allow_shared) + struct rspamd_http_message *msg, + const gchar *host, + const gchar *mime_type, + gpointer ud, + struct timeval *timeout, + gboolean allow_shared) { struct rspamd_http_connection_private *priv = conn->priv; struct rspamd_http_header *hdr, *htmp, *hcur; @@ -1737,7 +1737,6 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn enum rspamd_cryptobox_mode mode; GError *err; - conn->fd = fd; conn->ud = ud; priv->msg = msg; @@ -2043,9 +2042,7 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn gpointer ssl_ctx = (msg->flags & RSPAMD_HTTP_FLAG_SSL_NOVERIFY) ? priv->ctx->ssl_ctx_noverify : priv->ctx->ssl_ctx; - if (base != NULL) { - event_base_set (base, &priv->ev); - } + event_base_set (priv->ctx->ev_base, &priv->ev); if (!ssl_ctx) { err = g_error_new (HTTP_ERROR, errno, "ssl message requested " @@ -2062,11 +2059,11 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn rspamd_ssl_connection_free (priv->ssl); } - priv->ssl = rspamd_ssl_connection_new (ssl_ctx, base, + priv->ssl = rspamd_ssl_connection_new (ssl_ctx, priv->ctx->ev_base, !(msg->flags & RSPAMD_HTTP_FLAG_SSL_NOVERIFY)); g_assert (priv->ssl != NULL); - if (!rspamd_ssl_connect_fd (priv->ssl, fd, host, &priv->ev, + if (!rspamd_ssl_connect_fd (priv->ssl, conn->fd, host, &priv->ev, priv->ptv, rspamd_http_event_handler, rspamd_http_ssl_err_handler, conn)) { @@ -2083,11 +2080,8 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn } } else { - event_set (&priv->ev, fd, EV_WRITE, rspamd_http_event_handler, conn); - - if (base != NULL) { - event_base_set (base, &priv->ev); - } + event_set (&priv->ev, conn->fd, EV_WRITE, rspamd_http_event_handler, conn); + event_base_set (priv->ctx->ev_base, &priv->ev); event_add (&priv->ev, priv->ptv); } @@ -2095,20 +2089,26 @@ rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn void rspamd_http_connection_write_message (struct rspamd_http_connection *conn, - struct rspamd_http_message *msg, const gchar *host, const gchar *mime_type, - gpointer ud, gint fd, struct timeval *timeout, struct event_base *base) + struct rspamd_http_message *msg, + const gchar *host, + const gchar *mime_type, + gpointer ud, + struct timeval *timeout) { rspamd_http_connection_write_message_common (conn, msg, host, mime_type, - ud, fd, timeout, base, FALSE); + ud, timeout, FALSE); } void rspamd_http_connection_write_message_shared (struct rspamd_http_connection *conn, - struct rspamd_http_message *msg, const gchar *host, const gchar *mime_type, - gpointer ud, gint fd, struct timeval *timeout, struct event_base *base) + struct rspamd_http_message *msg, + const gchar *host, + const gchar *mime_type, + gpointer ud, + struct timeval *timeout) { rspamd_http_connection_write_message_common (conn, msg, host, mime_type, - ud, fd, timeout, base, TRUE); + ud, timeout, TRUE); } @@ -2134,7 +2134,6 @@ rspamd_http_message_free (struct rspamd_http_message *msg) } } - rspamd_http_message_storage_cleanup (msg); if (msg->url != NULL) { diff --git a/src/libutil/http_connection.h b/src/libutil/http_connection.h index 4e9f9f800..5fadf4509 100644 --- a/src/libutil/http_connection.h +++ b/src/libutil/http_connection.h @@ -74,14 +74,19 @@ struct rspamd_storage_shmem { */ #define RSPAMD_HTTP_FLAG_SSL_NOVERIFY (1 << 6) /** + * Do not verify server's certificate + */ +#define RSPAMD_HTTP_FLAG_KEEPALIVE (1 << 7) +/** * Options for HTTP connection */ enum rspamd_http_options { - RSPAMD_HTTP_BODY_PARTIAL = 0x1, /**< Call body handler on all body data portions *///!< RSPAMD_HTTP_BODY_PARTIAL - RSPAMD_HTTP_CLIENT_SIMPLE = 0x1u << 1, /**< Read HTTP client reply automatically */ //!< RSPAMD_HTTP_CLIENT_SIMPLE - RSPAMD_HTTP_CLIENT_ENCRYPTED = 0x1u << 2, /**< Encrypt data for client */ //!< RSPAMD_HTTP_CLIENT_ENCRYPTED - RSPAMD_HTTP_CLIENT_SHARED = 0x1u << 3, /**< Store reply in shared memory */ //!< RSPAMD_HTTP_CLIENT_SHARED - RSPAMD_HTTP_REQUIRE_ENCRYPTION = 0x1u << 4 + RSPAMD_HTTP_BODY_PARTIAL = 1, /**< Call body handler on all body data portions */ + RSPAMD_HTTP_CLIENT_SIMPLE = 1u << 1, /**< Read HTTP client reply automatically */ + RSPAMD_HTTP_CLIENT_ENCRYPTED = 1u << 2, /**< Encrypt data for client */ + RSPAMD_HTTP_CLIENT_SHARED = 1u << 3, /**< Store reply in shared memory */ + RSPAMD_HTTP_REQUIRE_ENCRYPTION = 1u << 4, + RSPAMD_HTTP_CLIENT_KEEP_ALIVE = 1u << 5, }; typedef int (*rspamd_http_body_handler_t) (struct rspamd_http_connection *conn, @@ -120,6 +125,7 @@ struct rspamd_http_connection { */ struct rspamd_http_connection *rspamd_http_connection_new ( struct rspamd_http_context *ctx, + gint fd, rspamd_http_body_handler_t body_handler, rspamd_http_error_handler_t error_handler, rspamd_http_finish_handler_t finish_handler, @@ -159,16 +165,12 @@ gboolean rspamd_http_connection_is_encrypted (struct rspamd_http_connection *con void rspamd_http_connection_read_message ( struct rspamd_http_connection *conn, gpointer ud, - gint fd, - struct timeval *timeout, - struct event_base *base); + struct timeval *timeout); void rspamd_http_connection_read_message_shared ( struct rspamd_http_connection *conn, gpointer ud, - gint fd, - struct timeval *timeout, - struct event_base *base); + struct timeval *timeout); /** * Send reply using initialised connection @@ -183,9 +185,7 @@ void rspamd_http_connection_write_message ( const gchar *host, const gchar *mime_type, gpointer ud, - gint fd, - struct timeval *timeout, - struct event_base *base); + struct timeval *timeout); void rspamd_http_connection_write_message_shared ( struct rspamd_http_connection *conn, @@ -193,9 +193,7 @@ void rspamd_http_connection_write_message_shared ( const gchar *host, const gchar *mime_type, gpointer ud, - gint fd, - struct timeval *timeout, - struct event_base *base); + struct timeval *timeout); /** * Free connection structure diff --git a/src/libutil/http_router.c b/src/libutil/http_router.c index e9dc48962..570d3d5c6 100644 --- a/src/libutil/http_router.c +++ b/src/libutil/http_router.c @@ -92,9 +92,7 @@ rspamd_http_router_error_handler (struct rspamd_http_connection *conn, NULL, "text/plain", entry, - entry->conn->fd, - entry->rt->ptv, - entry->rt->ev_base); + entry->rt->ptv); entry->is_reply = TRUE; } } @@ -211,8 +209,8 @@ rspamd_http_router_try_file (struct rspamd_http_connection_entry *entry, msg_debug ("requested file %s", realbuf); rspamd_http_connection_write_message (entry->conn, reply_msg, NULL, - rspamd_http_router_detect_ct (realbuf), entry, entry->conn->fd, - entry->rt->ptv, entry->rt->ev_base); + rspamd_http_router_detect_ct (realbuf), entry, + entry->rt->ptv); return TRUE; } @@ -237,9 +235,7 @@ rspamd_http_router_send_error (GError *err, NULL, "text/plain", entry, - entry->conn->fd, - entry->rt->ptv, - entry->rt->ev_base); + entry->rt->ptv); } @@ -511,6 +507,7 @@ rspamd_http_router_handle_socket (struct rspamd_http_connection_router *router, conn->is_reply = FALSE; conn->conn = rspamd_http_connection_new (router->ctx, + fd, NULL, rspamd_http_router_error_handler, rspamd_http_router_finish_handler, @@ -521,8 +518,7 @@ rspamd_http_router_handle_socket (struct rspamd_http_connection_router *router, rspamd_http_connection_set_key (conn->conn, router->key); } - rspamd_http_connection_read_message (conn->conn, conn, fd, router->ptv, - router->ev_base); + rspamd_http_connection_read_message (conn->conn, conn, router->ptv); DL_PREPEND (router->conns, conn); } diff --git a/src/libutil/map.c b/src/libutil/map.c index 1413b2953..eca45599e 100644 --- a/src/libutil/map.c +++ b/src/libutil/map.c @@ -138,9 +138,7 @@ write_http_request (struct http_callback_data *cbd) cbd->data->host, NULL, cbd, - cbd->fd, - &cbd->tv, - cbd->ev_base); + &cbd->tv); } else { msg_err_map ("cannot connect to %s: %s", cbd->data->host, @@ -1277,6 +1275,7 @@ rspamd_map_dns_callback (struct rdns_reply *reply, void *arg) if (cbd->fd != -1) { cbd->stage = map_load_file; cbd->conn = rspamd_http_connection_new (NULL, + cbd->fd, NULL, http_map_error, http_map_finish, @@ -1651,6 +1650,7 @@ check: cbd->conn = rspamd_http_connection_new ( NULL, NULL, + cbd->fd, http_map_error, http_map_finish, flags, diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 8c3dfb929..a8616e82a 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -381,6 +381,7 @@ lua_http_make_connection (struct lua_http_cbdata *cbd) if (cbd->cfg) { cbd->conn = rspamd_http_connection_new ( NULL, + fd, NULL, lua_http_error_handler, lua_http_finish_handler, @@ -390,6 +391,7 @@ lua_http_make_connection (struct lua_http_cbdata *cbd) else { cbd->conn = rspamd_http_connection_new ( NULL, + fd, NULL, lua_http_error_handler, lua_http_finish_handler, @@ -436,8 +438,8 @@ lua_http_make_connection (struct lua_http_cbdata *cbd) cbd->msg = NULL; rspamd_http_connection_write_message (cbd->conn, msg, - cbd->host, cbd->mime_type, cbd, fd, - &cbd->tv, cbd->ev_base); + cbd->host, cbd->mime_type, cbd, + &cbd->tv); return TRUE; } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 22088c2e5..842071afb 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -1734,6 +1734,7 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task, param->url = url; param->task = task; param->conn = rspamd_http_connection_new (NULL, + s, NULL, surbl_redirector_error, surbl_redirector_finish, @@ -1757,7 +1758,7 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task, } rspamd_http_connection_write_message (param->conn, msg, NULL, - NULL, param, s, timeout, task->ev_base); + NULL, param, timeout); msg_info_surbl ( "<%s> registered redirector call for %*s to %s, according to rule: %s", diff --git a/src/rspamadm/control.c b/src/rspamadm/control.c index c030907f6..26a769134 100644 --- a/src/rspamadm/control.c +++ b/src/rspamadm/control.c @@ -236,6 +236,7 @@ rspamadm_control (gint argc, gchar **argv, const struct rspamadm_command *_cmd) conn = rspamd_http_connection_new ( NULL, /* Default context */ + sock, NULL, rspamd_control_error_handler, rspamd_control_finish_handler, @@ -249,8 +250,8 @@ rspamadm_control (gint argc, gchar **argv, const struct rspamadm_command *_cmd) cbdata.argv = argv; cbdata.path = path; - rspamd_http_connection_write_message (conn, msg, NULL, NULL, &cbdata, sock, - &tv, ev_base); + rspamd_http_connection_write_message (conn, msg, NULL, NULL, &cbdata, + &tv); event_base_loop (ev_base, 0); diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index 4ecbcf54b..e25a66caf 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -1406,6 +1406,7 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session) bk_conn->backend_conn = rspamd_http_connection_new ( session->ctx->http_ctx, + bk_conn->backend_sock, NULL, proxy_backend_mirror_error_handler, proxy_backend_mirror_finish_handler, @@ -1427,8 +1428,7 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session) msg->method = HTTP_GET; rspamd_http_connection_write_message_shared (bk_conn->backend_conn, msg, NULL, NULL, bk_conn, - bk_conn->backend_sock, - bk_conn->io_tv, session->ctx->ev_base); + bk_conn->io_tv); } else { if (session->fname) { @@ -1455,8 +1455,7 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session) rspamd_http_connection_write_message (bk_conn->backend_conn, msg, NULL, NULL, bk_conn, - bk_conn->backend_sock, - bk_conn->io_tv, session->ctx->ev_base); + bk_conn->io_tv); } g_ptr_array_add (session->mirror_conns, bk_conn); @@ -1481,8 +1480,8 @@ proxy_client_write_error (struct rspamd_proxy_session *session, gint code, reply->code = code; reply->status = rspamd_fstring_new_init (status, strlen (status)); rspamd_http_connection_write_message (session->client_conn, - reply, NULL, NULL, session, session->client_sock, - &session->ctx->io_tv, session->ctx->ev_base); + reply, NULL, NULL, session, + &session->ctx->io_tv); } } @@ -1579,8 +1578,8 @@ proxy_backend_master_finish_handler (struct rspamd_http_connection *conn, } else { rspamd_http_connection_write_message (session->client_conn, - msg, NULL, NULL, session, session->client_sock, - bk_conn->io_tv, session->ctx->ev_base); + msg, NULL, NULL, session, + bk_conn->io_tv); } return 0; @@ -1639,9 +1638,7 @@ rspamd_proxy_scan_self_reply (struct rspamd_task *task) NULL, ctype, session, - session->client_sock, - NULL, - session->ctx->ev_base); + NULL); } } @@ -1836,6 +1833,7 @@ retry: session->master_conn->backend_conn = rspamd_http_connection_new ( session->ctx->http_ctx, + session->master_conn->backend_sock, NULL, proxy_backend_master_error_handler, proxy_backend_master_finish_handler, @@ -1869,8 +1867,7 @@ retry: rspamd_http_connection_write_message_shared ( session->master_conn->backend_conn, msg, NULL, NULL, session->master_conn, - session->master_conn->backend_sock, - session->master_conn->io_tv, session->ctx->ev_base); + session->master_conn->io_tv); } else { if (session->fname) { @@ -1898,8 +1895,7 @@ retry: rspamd_http_connection_write_message ( session->master_conn->backend_conn, msg, NULL, NULL, session->master_conn, - session->master_conn->backend_sock, - session->master_conn->io_tv, session->ctx->ev_base); + session->master_conn->io_tv); } } @@ -2088,6 +2084,7 @@ proxy_accept_socket (gint fd, short what, void *arg) if (!ctx->milter) { session->client_conn = rspamd_http_connection_new ( ctx->http_ctx, + nfd, NULL, proxy_client_error_handler, proxy_client_finish_handler, @@ -2104,9 +2101,7 @@ proxy_accept_socket (gint fd, short what, void *arg) rspamd_http_connection_read_message_shared (session->client_conn, session, - nfd, - &ctx->io_tv, - ctx->ev_base); + &ctx->io_tv); } else { msg_info_session ("accepted milter connection from %s port %d", diff --git a/src/worker.c b/src/worker.c index 8fa02b51a..0e993b84c 100644 --- a/src/worker.c +++ b/src/worker.c @@ -331,9 +331,7 @@ rspamd_worker_error_handler (struct rspamd_http_connection *conn, GError *err) NULL, "application/json", task, - task->http_conn->fd, - &task->tv, - task->ev_base); + &task->tv); } } @@ -416,6 +414,7 @@ accept_socket (gint fd, short what, void *arg) task->http_conn = rspamd_http_connection_new ( ctx->http_ctx, + nfd, rspamd_worker_body_handler, rspamd_worker_error_handler, rspamd_worker_finish_handler, @@ -436,9 +435,7 @@ accept_socket (gint fd, short what, void *arg) rspamd_http_connection_read_message (task->http_conn, task, - nfd, - &ctx->io_tv, - ctx->ev_base); + &ctx->io_tv); } #ifdef WITH_HYPERSCAN |