summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2007-07-31 00:59:11 -0400
committerSøren Sandmann <sandmann@redhat.com>2007-07-31 00:59:11 -0400
commit4d1c16402cb4afdff09166976809d175172cd521 (patch)
tree81de30e28af2d88cf53ce517257e42e00125edfc
parentf393c0608ace0eb825172bbe368e822055bcd705 (diff)
Rest of lac_tls_connection methods; plug leak
-rw-r--r--src/lactlsconnection.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/lactlsconnection.c b/src/lactlsconnection.c
index 88f233e..9ca6334 100644
--- a/src/lactlsconnection.c
+++ b/src/lactlsconnection.c
@@ -33,7 +33,6 @@ struct _LacTlsConnection
LacByteQueue * buffer;
LacByteQueue * unwritten;
- gnutls_anon_client_credentials_t anoncred;
gnutls_certificate_credentials_t xcred;
gnutls_session_t session;
@@ -234,9 +233,6 @@ tcp_callback (LacConnection *connection,
switch (event->type)
{
case LAC_CONNECTION_EVENT_CLOSE:
- gnutls_deinit (tls->session);
- /* fall thru */
-
case LAC_CONNECTION_EVENT_ERROR:
tls->callback (tls, event);
break;
@@ -312,6 +308,7 @@ lac_tls_connection_new (const LacAddress *address,
tls->buffer = lac_byte_queue_new ();
tls->unwritten = lac_byte_queue_new ();
tls->write_shutdown = FALSE;
+ tls->ref_count = 1;
gnutls_global_init ();
@@ -349,7 +346,15 @@ lac_tls_connection_unref (LacTlsConnection *connection)
{
if (--connection->ref_count == 0)
{
+ lac_connection_unref (connection->tcp_connection);
+
+ lac_byte_queue_free (connection->buffer, TRUE);
+ lac_byte_queue_free (connection->unwritten, TRUE);
+ gnutls_deinit (connection->session);
+
gnutls_certificate_free_credentials (connection->xcred);
+
+ g_free (connection);
}
}
@@ -388,11 +393,37 @@ lac_tls_connection_shutdown_write (LacTlsConnection *connection)
lac_connection_shutdown_write (connection->tcp_connection);
}
-G_CONST_RETURN LacAddress *lac_tls_connection_get_address (LacTlsConnection *connection);
-gint lac_tls_connection_get_port (LacTlsConnection *connection);
-void lac_tls_connection_close (LacTlsConnection *connection);
-gboolean lac_tls_connection_is_connected (LacTlsConnection *connection);
-void lac_tls_connection_flush (LacTlsConnection *connection);
+G_CONST_RETURN LacAddress *
+lac_tls_connection_get_address (LacTlsConnection *connection)
+{
+ return lac_connection_get_address (connection->tcp_connection);
+}
+
+gint
+lac_tls_connection_get_port (LacTlsConnection *connection)
+{
+ return lac_connection_get_port (connection->tcp_connection);
+}
+
+void
+lac_tls_connection_close (LacTlsConnection *connection)
+{
+ lac_connection_close (connection->tcp_connection);
+}
+
+gboolean
+lac_tls_connection_is_connected (LacTlsConnection *connection)
+{
+ return
+ lac_connection_is_connected (connection->tcp_connection) &&
+ !connection->need_handshake;
+}
+
+void
+lac_tls_connection_flush (LacTlsConnection *connection)
+{
+ lac_connection_flush (connection->tcp_connection);
+}
gpointer