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

Function connSocketSetReadHandler

src/connection.cpp:250–265  ·  view source on GitHub ↗

Register a read handler, to be called when the connection is readable. * If NULL, the existing handler is removed. */

Source from the content-addressed store, hash-verified

248 * If NULL, the existing handler is removed.
249 */
250static int connSocketSetReadHandler(connection *conn, ConnectionCallbackFunc func, bool fThreadSafe) {
251 if (func == conn->read_handler) return C_OK;
252
253 if (fThreadSafe)
254 conn->flags |= CONN_FLAG_READ_THREADSAFE;
255 else
256 conn->flags &= ~CONN_FLAG_READ_THREADSAFE;
257
258 conn->read_handler = func;
259 if (!conn->read_handler)
260 aeDeleteFileEvent(serverTL->el,conn->fd,AE_READABLE);
261 else
262 if (aeCreateFileEvent(serverTL->el,conn->fd,
263 AE_READABLE|AE_READ_THREADSAFE,conn->type->ae_handler,conn) == AE_ERR) return C_ERR;
264 return C_OK;
265}
266
267static const char *connSocketGetLastError(connection *conn) {
268 return strerror(conn->last_errno);

Callers

nothing calls this directly

Calls 2

aeDeleteFileEventFunction · 0.85
aeCreateFileEventFunction · 0.85

Tested by

no test coverage detected