Register a read handler, to be called when the connection is readable. * If NULL, the existing handler is removed. */
| 248 | * If NULL, the existing handler is removed. |
| 249 | */ |
| 250 | static 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 | |
| 267 | static const char *connSocketGetLastError(connection *conn) { |
| 268 | return strerror(conn->last_errno); |
nothing calls this directly
no test coverage detected