summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Noordhuis <pcnoordhuis@gmail.com>2013-07-10 21:08:29 -0700
committerPieter Noordhuis <pcnoordhuis@gmail.com>2013-07-10 21:08:29 -0700
commita5e0de0d8587c6f42f0df475e01d19be5084a5fd (patch)
tree4568bbe03818628b71bf7937c14b4676b8bd9bee
parentbcf83543762577a9b0f5625c848b7061cc980f30 (diff)
parentaf9bf16953b2e559ec7ecd12a25d5ea97b879bb2 (diff)
downloadhiredict-a5e0de0d8587c6f42f0df475e01d19be5084a5fd.tar.xz
Merge branch 'example-ae'
-rw-r--r--Makefile2
-rw-r--r--example-ae.c7
2 files changed, 7 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 16b8767..aed1ec0 100644
--- a/Makefile
+++ b/Makefile
@@ -73,7 +73,7 @@ hiredis-example-ae:
@false
else
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
hiredis-%: %.o $(STLIBNAME)
diff --git a/example-ae.c b/example-ae.c
index 5ed34a3..93f1a84 100644
--- a/example-ae.c
+++ b/example-ae.c
@@ -21,17 +21,22 @@ void getCallback(redisAsyncContext *c, void *r, void *privdata) {
void connectCallback(const redisAsyncContext *c, int status) {
if (status != REDIS_OK) {
printf("Error: %s\n", c->errstr);
+ aeStop(loop);
return;
}
+
printf("Connected...\n");
}
void disconnectCallback(const redisAsyncContext *c, int status) {
if (status != REDIS_OK) {
printf("Error: %s\n", c->errstr);
+ aeStop(loop);
return;
}
+
printf("Disconnected...\n");
+ aeStop(loop);
}
int main (int argc, char **argv) {
@@ -44,7 +49,7 @@ int main (int argc, char **argv) {
return 1;
}
- loop = aeCreateEventLoop();
+ loop = aeCreateEventLoop(64);
redisAeAttach(loop, c);
redisAsyncSetConnectCallback(c,connectCallback);
redisAsyncSetDisconnectCallback(c,disconnectCallback);