MCPcopy Create free account
hub / github.com/F-Stack/f-stack / enableBcastTrackingForPrefix

Function enableBcastTrackingForPrefix

app/redis-6.2.6/src/tracking.c:155–171  ·  view source on GitHub ↗

Set the client 'c' to track the prefix 'prefix'. If the client 'c' is * already registered for the specified prefix, no operation is performed. */

Source from the content-addressed store, hash-verified

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. */
155void 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

Callers 1

enableTrackingFunction · 0.85

Calls 5

raxFindFunction · 0.85
zmallocFunction · 0.85
raxNewFunction · 0.85
raxInsertFunction · 0.85
raxTryInsertFunction · 0.85

Tested by

no test coverage detected