Code

connection: Let sdb_connection_close not deallocate the connection.
authorSebastian Harl <sh@tokkee.org>
Mon, 15 Dec 2014 08:18:43 +0000 (09:18 +0100)
committerSebastian Harl <sh@tokkee.org>
Mon, 15 Dec 2014 08:18:43 +0000 (09:18 +0100)
That'll allow for more flexible use.

src/frontend/connection.c
src/include/frontend/connection.h
t/unit/frontend/connection_test.c

index ea2970f2f61f2f9faa1022b9457ce3e0c217a184..cf610ac45a06951a82c00644a943ef43d5da8ced 100644 (file)
@@ -462,8 +462,6 @@ sdb_connection_close(sdb_conn_t *conn)
        if (conn->fd >= 0)
                close(conn->fd);
        conn->fd = -1;
-
-       sdb_object_deref(SDB_OBJ(conn));
 } /* sdb_connection_close */
 
 ssize_t
index 20cc6c2b4b321d34a436be54c2459fa46d9df94e..906f906acbea436c5518dd84e798145a84b4d5ac 100644 (file)
 extern "C" {
 #endif
 
+/*
+ * sdb_conn_t represents an open connection from a client. It inherits from
+ * sdb_object_t and may safely be cast to a generic object.
+ */
 typedef struct sdb_conn sdb_conn_t;
 
 /*
@@ -81,8 +85,8 @@ sdb_connection_accept(int fd);
 
 /*
  * sdb_connection_close:
- * Close a open connection and deallocate any memory. The connection object is
- * no longer valid after calling this function.
+ * Close an open connection. Any subsequent reads from the connection will
+ * fail. Use sdb_object_deref to free the memory used by the object.
  */
 void
 sdb_connection_close(sdb_conn_t *conn);
index de5b01007f4521a8a81b19dfa2810095c468c479..6ce11ff511a97a30f67f9d482d1368806ff21a94 100644 (file)
@@ -234,6 +234,7 @@ START_TEST(test_conn_accept)
 
        unlink(socket_path);
        sdb_connection_close(conn);
+       sdb_object_deref(SDB_OBJ(conn));
        pthread_join(thr, NULL);
 }
 END_TEST