Code

frontend: Force-close the connection in sdb_connection_close().
authorSebastian Harl <sh@tokkee.org>
Fri, 11 Apr 2014 07:18:28 +0000 (09:18 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 11 Apr 2014 07:18:28 +0000 (09:18 +0200)
Previously, it would still be kept open if someone else referenced the object.

src/frontend/connection.c

index b98987dd2e53b68ddf828e64c0bb67e61f01bba4..93829ab248dc3992eca7124b1c6a8f95bd035345 100644 (file)
@@ -439,6 +439,14 @@ sdb_connection_accept(int fd)
 void
 sdb_connection_close(sdb_conn_t *conn)
 {
+       if (! conn)
+               return;
+
+       /* close the connection even if someone else still references it */
+       if (conn->fd >= 0)
+               close(conn->fd);
+       conn->fd = -1;
+
        sdb_object_deref(SDB_OBJ(conn));
 } /* sdb_connection_close */