From: Sebastian Harl Date: Mon, 15 Dec 2014 08:18:43 +0000 (+0100) Subject: connection: Let sdb_connection_close not deallocate the connection. X-Git-Tag: sysdb-0.7.0~109 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=d81bfcccccea93ac261b75814e530a5fc50cfc58 connection: Let sdb_connection_close not deallocate the connection. That'll allow for more flexible use. --- diff --git a/src/frontend/connection.c b/src/frontend/connection.c index ea2970f..cf610ac 100644 --- a/src/frontend/connection.c +++ b/src/frontend/connection.c @@ -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 diff --git a/src/include/frontend/connection.h b/src/include/frontend/connection.h index 20cc6c2..906f906 100644 --- a/src/include/frontend/connection.h +++ b/src/include/frontend/connection.h @@ -39,6 +39,10 @@ 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); diff --git a/t/unit/frontend/connection_test.c b/t/unit/frontend/connection_test.c index de5b010..6ce11ff 100644 --- a/t/unit/frontend/connection_test.c +++ b/t/unit/frontend/connection_test.c @@ -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