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.
This commit is contained in:
parent
947612865d
commit
e3067fe231
@ -17,9 +17,11 @@ void libevRedisReadEvent(struct ev_loop *loop, ev_io *watcher, int revents) {
|
|||||||
libevRedisEvents *e = watcher->data;
|
libevRedisEvents *e = watcher->data;
|
||||||
|
|
||||||
if (redisBufferRead(e->context) == REDIS_ERR) {
|
if (redisBufferRead(e->context) == REDIS_ERR) {
|
||||||
|
redisDisconnect(e->context);
|
||||||
e->err(e->context);
|
e->err(e->context);
|
||||||
} else {
|
} else {
|
||||||
if (redisProcessCallbacks(e->context) == REDIS_ERR) {
|
if (redisProcessCallbacks(e->context) == REDIS_ERR) {
|
||||||
|
redisDisconnect(e->context);
|
||||||
e->err(e->context);
|
e->err(e->context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,7 +33,7 @@ void libevRedisWriteEvent(struct ev_loop *loop, ev_io *watcher, int revents) {
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
if (redisBufferWrite(e->context, &done) == REDIS_ERR) {
|
if (redisBufferWrite(e->context, &done) == REDIS_ERR) {
|
||||||
ev_io_stop(e->loop,&e->wev);
|
redisDisconnect(e->context);
|
||||||
e->err(e->context);
|
e->err(e->context);
|
||||||
} else {
|
} else {
|
||||||
/* Stop firing the write event when done */
|
/* Stop firing the write event when done */
|
||||||
|
@ -19,9 +19,11 @@ void libeventRedisReadEvent(int fd, short event, void *arg) {
|
|||||||
event_add(&e->rev,NULL);
|
event_add(&e->rev,NULL);
|
||||||
|
|
||||||
if (redisBufferRead(e->context) == REDIS_ERR) {
|
if (redisBufferRead(e->context) == REDIS_ERR) {
|
||||||
|
redisDisconnect(e->context);
|
||||||
e->err(e->context);
|
e->err(e->context);
|
||||||
} else {
|
} else {
|
||||||
if (redisProcessCallbacks(e->context) == REDIS_ERR) {
|
if (redisProcessCallbacks(e->context) == REDIS_ERR) {
|
||||||
|
redisDisconnect(e->context);
|
||||||
e->err(e->context);
|
e->err(e->context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +35,7 @@ void libeventRedisWriteEvent(int fd, short event, void *arg) {
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
if (redisBufferWrite(e->context,&done) == REDIS_ERR) {
|
if (redisBufferWrite(e->context,&done) == REDIS_ERR) {
|
||||||
/* Handle error */
|
redisDisconnect(e->context);
|
||||||
e->err(e->context);
|
e->err(e->context);
|
||||||
} else {
|
} else {
|
||||||
/* Schedule write event again when writing is not done. */
|
/* Schedule write event again when writing is not done. */
|
||||||
|
Loading…
Reference in New Issue
Block a user