aboutsummaryrefslogtreecommitdiffstats
path: root/utils/rspamd_http_server.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-20 15:24:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-20 15:24:51 +0100
commite4336fe612d4e95cd6fb76b9ced6a9599ebe1990 (patch)
tree0245846748ce51a179178bf77a3452842c39f62b /utils/rspamd_http_server.c
parentafc786bb1ca868077219b133d7611b71957b0b44 (diff)
downloadrspamd-e4336fe612d4e95cd6fb76b9ced6a9599ebe1990.tar.gz
rspamd-e4336fe612d4e95cd6fb76b9ced6a9599ebe1990.zip
Implement batch accept in server.
Diffstat (limited to 'utils/rspamd_http_server.c')
-rw-r--r--utils/rspamd_http_server.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/utils/rspamd_http_server.c b/utils/rspamd_http_server.c
index 71d74ee7d..3aefe6b9f 100644
--- a/utils/rspamd_http_server.c
+++ b/utils/rspamd_http_server.c
@@ -139,26 +139,31 @@ rspamd_server_accept (gint fd, short what, void *arg)
rspamd_inet_addr_t *addr;
gint nfd;
- if ((nfd =
- rspamd_accept_from_socket (fd, &addr)) == -1) {
- rspamd_fprintf (stderr, "accept failed: %s", strerror (errno));
- return;
- }
- /* Check for EAGAIN */
- if (nfd == 0) {
- return;
- }
+ do {
+ if ((nfd =
+ rspamd_accept_from_socket (fd, &addr)) == -1) {
+ rspamd_fprintf (stderr, "accept failed: %s", strerror (errno));
+ return;
+ }
+ /* Check for EAGAIN */
+ if (nfd == 0) {
+ return;
+ }
- rspamd_inet_address_destroy (addr);
- session = g_slice_alloc (sizeof (*session));
- session->conn = rspamd_http_connection_new (NULL, rspamd_server_error,
- rspamd_server_finish, 0, RSPAMD_HTTP_SERVER, c);
- rspamd_http_connection_set_key (session->conn, server_key);
- rspamd_http_connection_read_message (session->conn, session, nfd, &io_tv,
- ev_base);
- session->reply = FALSE;
- session->fd = nfd;
- session->ev_base = ev_base;
+ rspamd_inet_address_destroy (addr);
+ session = g_slice_alloc (sizeof (*session));
+ session->conn = rspamd_http_connection_new (NULL, rspamd_server_error,
+ rspamd_server_finish, 0, RSPAMD_HTTP_SERVER, c);
+ rspamd_http_connection_set_key (session->conn, server_key);
+ rspamd_http_connection_read_message (session->conn,
+ session,
+ nfd,
+ &io_tv,
+ ev_base);
+ session->reply = FALSE;
+ session->fd = nfd;
+ session->ev_base = ev_base;
+ } while (nfd > 0);
}
static void