diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-10-19 20:56:06 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-10-19 21:24:30 +0200 |
commit | e3067fe2316a3efb89fd7be78be8f9b18618f8fa (patch) | |
tree | 111568166856639b42ba2060c95bd0b1dfb6ff2b | |
parent | 947612865d5dce64240955bc152e225f385349a8 (diff) |
Actively disconnect on an error
This calls the disconnect callback, causing the registered event
handlers to be cleared. After this, the error callback will be called,
knowing that events will no longer be fired.
-rw-r--r-- | extra/hiredis/libev.h | 4 | ||||
-rw-r--r-- | extra/hiredis/libevent.h | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/extra/hiredis/libev.h b/extra/hiredis/libev.h index 4b36898..3246820 100644 --- a/extra/hiredis/libev.h +++ b/extra/hiredis/libev.h @@ -17,9 +17,11 @@ void libevRedisReadEvent(struct ev_loop *loop, ev_io *watcher, int revents) { libevRedisEvents *e = watcher->data; if (redisBufferRead(e->context) == REDIS_ERR) { + redisDisconnect(e->context); e->err(e->context); } else { if (redisProcessCallbacks(e->context) == REDIS_ERR) { + redisDisconnect(e->context); e->err(e->context); } } @@ -31,7 +33,7 @@ void libevRedisWriteEvent(struct ev_loop *loop, ev_io *watcher, int revents) { int done = 0; if (redisBufferWrite(e->context, &done) == REDIS_ERR) { - ev_io_stop(e->loop,&e->wev); + redisDisconnect(e->context); e->err(e->context); } else { /* Stop firing the write event when done */ diff --git a/extra/hiredis/libevent.h b/extra/hiredis/libevent.h index 6f7f9ad..be70b25 100644 --- a/extra/hiredis/libevent.h +++ b/extra/hiredis/libevent.h @@ -19,9 +19,11 @@ void libeventRedisReadEvent(int fd, short event, void *arg) { event_add(&e->rev,NULL); if (redisBufferRead(e->context) == REDIS_ERR) { + redisDisconnect(e->context); e->err(e->context); } else { if (redisProcessCallbacks(e->context) == REDIS_ERR) { + redisDisconnect(e->context); e->err(e->context); } } @@ -33,7 +35,7 @@ void libeventRedisWriteEvent(int fd, short event, void *arg) { int done = 0; if (redisBufferWrite(e->context,&done) == REDIS_ERR) { - /* Handle error */ + redisDisconnect(e->context); e->err(e->context); } else { /* Schedule write event again when writing is not done. */ |