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

Function connSocketClose

src/connection.cpp:149–170  ·  view source on GitHub ↗

Close the connection and free resources. */

Source from the content-addressed store, hash-verified

147
148/* Close the connection and free resources. */
149static void connSocketClose(connection *conn) {
150 if (conn->fd != -1) {
151 aeDeleteFileEvent(serverTL->el,conn->fd,AE_READABLE | AE_WRITABLE);
152 close(conn->fd);
153 conn->fd = -1;
154 }
155
156 /* If called from within a handler, schedule the close but
157 * keep the connection until the handler returns.
158 */
159 if (connHasRefs(conn)) {
160 conn->flags |= CONN_FLAG_CLOSE_SCHEDULED;
161 return;
162 }
163
164 if (conn->fprint) {
165 zfree(conn->fprint);
166 conn->fprint = NULL;
167 }
168
169 zfree(conn);
170}
171
172static int connSocketWrite(connection *conn, const void *data, size_t data_len) {
173 int ret = write(conn->fd, data, data_len);

Callers

nothing calls this directly

Calls 3

aeDeleteFileEventFunction · 0.85
connHasRefsFunction · 0.85
zfreeFunction · 0.85

Tested by

no test coverage detected