summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-01-20 16:05:18 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-01-20 16:05:18 +0000
commit3951e4e858d891993c2d0f3fc317a3b9026269b3 (patch)
tree56a31b58a8f185cc527293e1233eb89f4711af75 /src/client
parent0b7e2390bfb711499cab3511d7ff51a19c17369a (diff)
downloadrspamd-3951e4e858d891993c2d0f3fc317a3b9026269b3.tar.gz
rspamd-3951e4e858d891993c2d0f3fc317a3b9026269b3.zip
Implement refcount for http connection.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/rspamdclient.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c
index d4b6e5d8b..c00a30f1c 100644
--- a/src/client/rspamdclient.c
+++ b/src/client/rspamdclient.c
@@ -73,7 +73,7 @@ rspamd_client_error_handler (struct rspamd_http_connection *conn, GError *err)
req->cb (c, c->server_name->str, NULL, req->ud, err);
}
-static void
+static gint
rspamd_client_finish_handler (struct rspamd_http_connection *conn,
struct rspamd_http_message *msg)
{
@@ -88,13 +88,14 @@ rspamd_client_finish_handler (struct rspamd_http_connection *conn,
c->req_sent = TRUE;
rspamd_http_connection_reset (c->http_conn);
rspamd_http_connection_read_message (c->http_conn, c->req, c->fd, &c->timeout, c->ev_base);
+ return 0;
}
else {
if (msg->body == NULL || msg->body->len == 0 || msg->code != 200) {
err = g_error_new (RCLIENT_ERROR, msg->code, "HTTP error occurred: %d", msg->code);
req->cb (c, c->server_name->str, NULL, req->ud, err);
g_error_free (err);
- return;
+ return -1;
}
parser = ucl_parser_new (0);
@@ -104,12 +105,14 @@ rspamd_client_finish_handler (struct rspamd_http_connection *conn,
ucl_parser_free (parser);
req->cb (c, c->server_name->str, NULL, req->ud, err);
g_error_free (err);
- return;
+ return -1;
}
req->cb (c, c->server_name->str, ucl_parser_get_object (parser), req->ud, NULL);
ucl_parser_free (parser);
}
+
+ return -1;
}
struct rspamd_client_connection *
@@ -203,7 +206,7 @@ void
rspamd_client_destroy (struct rspamd_client_connection *conn)
{
if (conn != NULL) {
- rspamd_http_connection_free (conn->http_conn);
+ rspamd_http_connection_unref (conn->http_conn);
if (conn->req != NULL) {
g_slice_free1 (sizeof (struct rspamd_client_request), conn->req);
}