MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / modulePopulateClientInfoStructure

Function modulePopulateClientInfoStructure

src/module.cpp:1987–2012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1985 * REDISMODULE_OK and the structure pointed by 'ci' gets populated. */
1986
1987int modulePopulateClientInfoStructure(void *ci, client *client, int structver) {
1988 if (structver != 1) return REDISMODULE_ERR;
1989
1990 RedisModuleClientInfoV1 *ci1 = (RedisModuleClientInfoV1*)ci;
1991 memset(ci1,0,sizeof(*ci1));
1992 ci1->version = structver;
1993 if (client->flags & CLIENT_MULTI)
1994 ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_MULTI;
1995 if (client->flags & CLIENT_PUBSUB)
1996 ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_PUBSUB;
1997 if (client->flags & CLIENT_UNIX_SOCKET)
1998 ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_UNIXSOCKET;
1999 if (client->flags & CLIENT_TRACKING)
2000 ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_TRACKING;
2001 if (client->flags & CLIENT_BLOCKED)
2002 ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_BLOCKED;
2003 if (connGetType(client->conn) == CONN_TYPE_TLS)
2004 ci1->flags |= REDISMODULE_CLIENTINFO_FLAG_SSL;
2005
2006 int port;
2007 connPeerToString(client->conn,ci1->addr,sizeof(ci1->addr),&port);
2008 ci1->port = port;
2009 ci1->db = client->db->id;
2010 ci1->id = client->id;
2011 return REDISMODULE_OK;
2012}
2013
2014/* This is an helper for moduleFireServerEvent() and other functions:
2015 * It populates the replication info structure with the appropriate

Callers 2

RM_GetClientInfoByIdFunction · 0.85
moduleFireServerEventFunction · 0.85

Calls 2

connGetTypeFunction · 0.85
connPeerToStringFunction · 0.85

Tested by

no test coverage detected