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

Function createInstanceLink

src/sentinel.cpp:1049–1070  ·  view source on GitHub ↗

Create a not yet connected link object. */

Source from the content-addressed store, hash-verified

1047
1048/* Create a not yet connected link object. */
1049instanceLink *createInstanceLink(void) {
1050 instanceLink *link = (instanceLink*)zmalloc(sizeof(*link), MALLOC_LOCAL);
1051
1052 link->refcount = 1;
1053 link->disconnected = 1;
1054 link->pending_commands = 0;
1055 link->cc = NULL;
1056 link->pc = NULL;
1057 link->cc_conn_time = 0;
1058 link->pc_conn_time = 0;
1059 link->last_reconn_time = 0;
1060 link->pc_last_activity = 0;
1061 /* We set the act_ping_time to "now" even if we actually don't have yet
1062 * a connection with the node, nor we sent a ping.
1063 * This is useful to detect a timeout in case we'll not be able to connect
1064 * with the node at all. */
1065 link->act_ping_time = mstime();
1066 link->last_ping_time = 0;
1067 link->last_avail_time = mstime();
1068 link->last_pong_time = mstime();
1069 return link;
1070}
1071
1072/* Disconnect a hiredis connection in the context of an instance link. */
1073void instanceLinkCloseConnection(instanceLink *link, redisAsyncContext *c) {

Callers 1

Calls 2

zmallocFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected