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

Function protectClient

src/networking.cpp:2172–2179  ·  view source on GitHub ↗

This function is used when we want to re-enter the event loop but there * is the risk that the client we are dealing with will be freed in some * way. This happens for instance in: * * * DEBUG RELOAD and similar. * * When a Lua script is in -BUSY state. * * So the function will protect the client by doing two things: * * 1) It removes the file events. This way it is not possible that an

Source from the content-addressed store, hash-verified

2170 * 2) Moreover it makes sure that if the client is freed in a different code
2171 * path, it is not really released, but only marked for later release. */
2172void protectClient(client *c) {
2173 c->flags |= CLIENT_PROTECTED;
2174 AssertCorrectThread(c);
2175 if (c->conn) {
2176 connSetReadHandler(c->conn,NULL);
2177 connSetWriteHandler(c->conn,NULL);
2178 }
2179}
2180
2181/* This will undo the client protection done by protectClient() */
2182void unprotectClient(client *c) {

Callers 2

debugCommandFunction · 0.85
luaMaskCountHookFunction · 0.85

Calls 2

connSetReadHandlerFunction · 0.85
connSetWriteHandlerFunction · 0.85

Tested by

no test coverage detected