summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-06 18:13:23 +0200
committerPieter Noordhuis <pcnoordhuis@gmail.com>2010-10-06 18:13:23 +0200
commit97920b443e58aa9c15f9836841164c7123194859 (patch)
tree8c02c645b0790e22b0583e983b6660d4d2710214
parent5a38356cc4133c581f2935b38e12abb2a2037419 (diff)
Rename variables
-rw-r--r--libevent-example.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/libevent-example.c b/libevent-example.c
index 1f49d29..5e0bb9f 100644
--- a/libevent-example.c
+++ b/libevent-example.c
@@ -10,40 +10,39 @@
* redisContext to the read and write handlers. */
typedef struct redisEvents {
redisContext *context;
- struct event read;
- struct event write;
+ struct event rev, wev;
} redisEvents;
void redisLibEventRead(int fd, short event, void *arg) {
NOT_USED(fd); NOT_USED(event);
- redisEvents *re = arg;
+ redisEvents *e = arg;
/* Always re-schedule read events */
- event_add(&re->read,NULL);
+ event_add(&e->rev,NULL);
- if (redisBufferRead(re->context) == REDIS_ERR) {
+ if (redisBufferRead(e->context) == REDIS_ERR) {
/* Handle error. */
- printf("Read error: %s\n", re->context->error);
+ printf("Read error: %s\n", e->context->error);
} else {
/* Check replies. */
- redisProcessCallbacks(re->context);
+ redisProcessCallbacks(e->context);
}
}
void redisLibEventWrite(int fd, short event, void *arg) {
NOT_USED(fd); NOT_USED(event);
- redisEvents *re = arg;
+ redisEvents *e = arg;
int done = 0;
- if (redisBufferWrite(re->context, &done) == REDIS_ERR) {
+ if (redisBufferWrite(e->context, &done) == REDIS_ERR) {
/* Handle error */
- printf("Write error: %s\n", re->context->error);
+ printf("Write error: %s\n", e->context->error);
} else {
/* Schedule write event again when writing is not done. */
if (!done) {
- event_add(&re->write,NULL);
+ event_add(&e->wev,NULL);
} else {
- event_add(&re->read,NULL);
+ event_add(&e->rev,NULL);
}
}
}
@@ -53,7 +52,7 @@ void redisLibEventWrite(int fd, short event, void *arg) {
void redisLibEventOnWrite(redisContext *c, void *privdata) {
NOT_USED(c);
redisEvents *e = privdata;
- event_add(&e->write,NULL);
+ event_add(&e->wev,NULL);
}
/* Free the redisEvents struct when the context is free'd. */
@@ -68,8 +67,8 @@ redisContext *redisLibEventConnect(const char *ip, int port) {
e->context = redisConnectNonBlock(ip, port, NULL);
redisSetCommandCallback(e->context, redisLibEventOnWrite, e);
redisSetFreeCallback(e->context, redisLibEventOnFree, e);
- event_set(&e->read, e->context->fd, EV_READ, redisLibEventRead, e);
- event_set(&e->write, e->context->fd, EV_WRITE, redisLibEventWrite, e);
+ event_set(&e->rev, e->context->fd, EV_READ, redisLibEventRead, e);
+ event_set(&e->wev, e->context->fd, EV_WRITE, redisLibEventWrite, e);
return e->context;
}