summaryrefslogtreecommitdiff
path: root/src/notify.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-01-25 17:34:52 +0100
committerantirez <antirez@gmail.com>2013-01-28 13:15:16 +0100
commit562b2bd6a7d6e8ee893d68059360b593ed43352f (patch)
tree5d5ab5783bc1e52320049df7af6e40905d9acde2 /src/notify.c
parentfce016d31bc11ff19de1f1ff216e4a0588fea3ac (diff)
downloadredis-562b2bd6a7d6e8ee893d68059360b593ed43352f.tar.gz
Keyspace notifications: fixed a leak and a bug introduced in the latest commit.
Diffstat (limited to 'src/notify.c')
-rw-r--r--src/notify.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/notify.c b/src/notify.c
index f8e018295..bb598c4f2 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -92,22 +92,22 @@ sds keyspaceEventsFlagsToString(int flags) {
* 'dbid' is the database ID where the key lives. */
void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {
sds chan;
- robj *chanobj;
+ robj *chanobj, *eventobj;
int len = -1;
char buf[24];
/* If notifications for this class of events are off, return ASAP. */
if (!(server.notify_keyspace_events & type)) return;
+ eventobj = createStringObject(event,strlen(event));
+
/* __keyspace@<db>__:<key> <event> notifications. */
if (server.notify_keyspace_events & REDIS_NOTIFY_KEYSPACE) {
- robj *eventobj;
-
chan = sdsnewlen("__keyspace@",11);
len = ll2string(buf,sizeof(buf),dbid);
chan = sdscatlen(chan, buf, len);
chan = sdscatlen(chan, "__:", 3);
- eventobj = createStringObject(event,strlen(event));
+ chan = sdscatsds(chan, key->ptr);
chanobj = createObject(REDIS_STRING, chan);
pubsubPublishMessage(chanobj, eventobj);
decrRefCount(chanobj);
@@ -119,8 +119,10 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {
if (len == -1) len = ll2string(buf,sizeof(buf),dbid);
chan = sdscatlen(chan, buf, len);
chan = sdscatlen(chan, "__:", 3);
+ chan = sdscatsds(chan, eventobj->ptr);
chanobj = createObject(REDIS_STRING, chan);
pubsubPublishMessage(chanobj, key);
decrRefCount(chanobj);
}
+ decrRefCount(eventobj);
}