Helper for connection implementations to call handlers: * 1. Increment refs to protect the connection. * 2. Execute the handler (if set). * 3. Decrement refs and perform deferred close, if refs==0. */
| 75 | * 3. Decrement refs and perform deferred close, if refs==0. |
| 76 | */ |
| 77 | static inline int callHandler(connection *conn, ConnectionCallbackFunc handler) { |
| 78 | connIncrRefs(conn); |
| 79 | if (handler) handler(conn); |
| 80 | connDecrRefs(conn); |
| 81 | if (conn->flags & CONN_FLAG_CLOSE_SCHEDULED) { |
| 82 | if (!connHasRefs(conn)) connClose(conn); |
| 83 | return 0; |
| 84 | } |
| 85 | return 1; |
| 86 | } |
| 87 | |
| 88 | #endif /* __REDIS_CONNHELPERS_H */ |
no test coverage detected