summaryrefslogtreecommitdiffstats
path: root/src/memcached.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2008-12-03 19:48:15 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2008-12-03 19:48:15 +0300
commit42b81716ece887b0011b1e40b0101ad37598997e (patch)
tree62d7512875ea0e2adb47d524d23628d86e83b4d4 /src/memcached.c
parentd62fb36650acfd0863c32a78b0941a4c0d0e58b1 (diff)
downloadrspamd-42b81716ece887b0011b1e40b0101ad37598997e.tar.gz
rspamd-42b81716ece887b0011b1e40b0101ad37598997e.zip
* Remove strlcpy code and replace it with glib alternative
* Polish code and remove bugs found
Diffstat (limited to 'src/memcached.c')
-rw-r--r--src/memcached.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/memcached.c b/src/memcached.c
index 05ae16617..22dd9fbb3 100644
--- a/src/memcached.c
+++ b/src/memcached.c
@@ -105,7 +105,9 @@ write_handler (int fd, short what, memcached_ctx_t *ctx)
iov[2].iov_len = ctx->param->bufsize - ctx->param->bufpos;
iov[3].iov_base = CRLF;
iov[3].iov_len = sizeof (CRLF) - 1;
- writev (ctx->sock, iov, 4);
+ if (writev (ctx->sock, iov, 4) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: writev failed: %m");
+ }
}
else {
iov[0].iov_base = read_buf;
@@ -195,10 +197,14 @@ read_handler (int fd, short what, memcached_ctx_t *ctx)
iov[0].iov_len = sizeof (struct memc_udp_header);
iov[1].iov_base = read_buf;
iov[1].iov_len = r;
- writev (ctx->sock, iov, 2);
+ if (writev (ctx->sock, iov, 2) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: writev failed: %m");
+ }
}
else {
- write (ctx->sock, read_buf, r);
+ if (write (ctx->sock, read_buf, r) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: write failed: %m");
+ }
}
event_del (&ctx->mem_ev);
event_set (&ctx->mem_ev, ctx->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, socket_callback, (void *)ctx);
@@ -325,9 +331,14 @@ delete_handler (int fd, short what, memcached_ctx_t *ctx)
iov[1].iov_base = read_buf;
iov[1].iov_len = r;
ctx->param->bufpos = writev (ctx->sock, iov, 2);
+ if (ctx->param->bufpos == -1) {
+ memc_log (ctx, __LINE__, "memc_write: writev failed: %m");
+ }
}
else {
- write (ctx->sock, read_buf, r);
+ if (write (ctx->sock, read_buf, r) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: write failed: %m");
+ }
}
event_del (&ctx->mem_ev);
event_set (&ctx->mem_ev, ctx->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, socket_callback, (void *)ctx);