Set the client 'c' to track the prefix 'prefix'. If the client 'c' is * already registered for the specified prefix, no operation is performed. */
| 153 | /* Set the client 'c' to track the prefix 'prefix'. If the client 'c' is |
| 154 | * already registered for the specified prefix, no operation is performed. */ |
| 155 | void enableBcastTrackingForPrefix(client *c, char *prefix, size_t plen) { |
| 156 | bcastState *bs = raxFind(PrefixTable,(unsigned char*)prefix,plen); |
| 157 | /* If this is the first client subscribing to such prefix, create |
| 158 | * the prefix in the table. */ |
| 159 | if (bs == raxNotFound) { |
| 160 | bs = zmalloc(sizeof(*bs)); |
| 161 | bs->keys = raxNew(); |
| 162 | bs->clients = raxNew(); |
| 163 | raxInsert(PrefixTable,(unsigned char*)prefix,plen,bs,NULL); |
| 164 | } |
| 165 | if (raxTryInsert(bs->clients,(unsigned char*)&c,sizeof(c),NULL,NULL)) { |
| 166 | if (c->client_tracking_prefixes == NULL) |
| 167 | c->client_tracking_prefixes = raxNew(); |
| 168 | raxInsert(c->client_tracking_prefixes, |
| 169 | (unsigned char*)prefix,plen,NULL,NULL); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | /* Enable the tracking state for the client 'c', and as a side effect allocates |
| 174 | * the tracking table if needed. If the 'redirect_to' argument is non zero, the |
no test coverage detected