aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-08-01 15:32:45 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-08-01 15:32:45 +0400
commit643576fcff380140d714e6f9711c402246f16a28 (patch)
treeafff9f26fa71cc67c5163009c6fbbf3abf822493 /lib
parent0c6e9d1f0bc8e010d30c27af1635513adfa9a6dd (diff)
downloadrspamd-643576fcff380140d714e6f9711c402246f16a28.tar.gz
rspamd-643576fcff380140d714e6f9711c402246f16a28.zip
Fix controller stages and debug info.
Handle timeouts in librspamdclient correctly.
Diffstat (limited to 'lib')
-rw-r--r--lib/librspamdclient.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/librspamdclient.c b/lib/librspamdclient.c
index c52a71806..e871c29f6 100644
--- a/lib/librspamdclient.c
+++ b/lib/librspamdclient.c
@@ -899,9 +899,12 @@ read_rspamd_reply_line (struct rspamd_connection *c, GError **err)
}
}
/* Poll socket */
- if (poll_sync_socket (c->socket, client->read_timeout, POLL_IN) == -1) {
+ if ((r = poll_sync_socket (c->socket, client->read_timeout, POLL_IN)) <= 0) {
if (*err == NULL) {
- *err = g_error_new (G_RSPAMD_ERROR, errno, "Could not connect to server %s: %s",
+ if (r == 0) {
+ errno = ETIMEDOUT;
+ }
+ *err = g_error_new (G_RSPAMD_ERROR, errno, "Cannot read reply from controller %s: %s",
c->server->name, strerror (errno));
}
upstream_fail (&c->server->up, c->connection_time);
@@ -1100,8 +1103,11 @@ rspamd_send_controller_command (struct rspamd_connection *c, const gchar *line,
make_socket_nonblocking (c->socket);
/* Poll socket */
do {
- if (poll_sync_socket (c->socket, client->read_timeout, POLL_IN) == -1) {
+ if ((r = poll_sync_socket (c->socket, client->read_timeout, POLL_IN)) <= 0) {
if (*err == NULL) {
+ if (r == 0) {
+ errno = ETIMEDOUT;
+ }
*err = g_error_new (G_RSPAMD_ERROR, errno, "Cannot read reply from controller %s: %s",
c->server->name, strerror (errno));
}
@@ -1186,8 +1192,11 @@ rspamd_read_controller_greeting (struct rspamd_connection *c, GError **err)
gint r;
static const gchar greeting_str[] = "Rspamd";
- if (poll_sync_socket (c->socket, client->read_timeout, POLL_IN) == -1) {
+ if ((r = poll_sync_socket (c->socket, client->read_timeout, POLL_IN)) <= 0) {
if (*err == NULL) {
+ if (r == 0) {
+ errno = ETIMEDOUT;
+ }
*err = g_error_new (G_RSPAMD_ERROR, errno, "Cannot read reply from controller %s: %s",
c->server->name, strerror (errno));
}