Commit a5e0de0d authored by Pieter Noordhuis's avatar Pieter Noordhuis
Browse files

Merge branch 'example-ae'

parents bcf83543 af9bf169
...@@ -73,7 +73,7 @@ hiredis-example-ae: ...@@ -73,7 +73,7 @@ hiredis-example-ae:
@false @false
else else
hiredis-example-ae: example-ae.c adapters/ae.h $(STLIBNAME) hiredis-example-ae: example-ae.c adapters/ae.h $(STLIBNAME)
$(CC) -o $@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I$(AE_DIR) $(AE_DIR)/ae.o $(AE_DIR)/zmalloc.o example-ae.c $(STLIBNAME) $(CC) -o $@ $(REAL_CFLAGS) $(REAL_LDFLAGS) -I$(AE_DIR) $(AE_DIR)/ae.o $(AE_DIR)/zmalloc.o $(AE_DIR)/../deps/jemalloc/lib/libjemalloc.a -pthread example-ae.c $(STLIBNAME)
endif endif
hiredis-%: %.o $(STLIBNAME) hiredis-%: %.o $(STLIBNAME)
......
...@@ -21,17 +21,22 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) { ...@@ -21,17 +21,22 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) {
void connectCallback(const redisAsyncContext *c, int status) { void connectCallback(const redisAsyncContext *c, int status) {
if (status != REDIS_OK) { if (status != REDIS_OK) {
printf("Error: %s\n", c->errstr); printf("Error: %s\n", c->errstr);
aeStop(loop);
return; return;
} }
printf("Connected...\n"); printf("Connected...\n");
} }
void disconnectCallback(const redisAsyncContext *c, int status) { void disconnectCallback(const redisAsyncContext *c, int status) {
if (status != REDIS_OK) { if (status != REDIS_OK) {
printf("Error: %s\n", c->errstr); printf("Error: %s\n", c->errstr);
aeStop(loop);
return; return;
} }
printf("Disconnected...\n"); printf("Disconnected...\n");
aeStop(loop);
} }
int main (int argc, char **argv) { int main (int argc, char **argv) {
...@@ -44,7 +49,7 @@ int main (int argc, char **argv) { ...@@ -44,7 +49,7 @@ int main (int argc, char **argv) {
return 1; return 1;
} }
loop = aeCreateEventLoop(); loop = aeCreateEventLoop(64);
redisAeAttach(loop, c); redisAeAttach(loop, c);
redisAsyncSetConnectCallback(c,connectCallback); redisAsyncSetConnectCallback(c,connectCallback);
redisAsyncSetDisconnectCallback(c,disconnectCallback); redisAsyncSetDisconnectCallback(c,disconnectCallback);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment