summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2008-01-02 23:39:55 -0500
committerSøren Sandmann <sandmann@redhat.com>2008-01-02 23:39:55 -0500
commita37b60a53d0b897949d29a59a0f13c81384b9830 (patch)
treec4963813d47ceaad5b8f28c95c4d3af5dbb7ff53
parentcd38a514e8c6657a5b2db1c3a3ad9948e0dd0e58 (diff)
Various formatting fixes
-rw-r--r--src/lac.h49
-rw-r--r--src/lacaddress.c8
-rw-r--r--src/lacconnection.c45
-rw-r--r--src/lacprimitives.c6
-rw-r--r--src/lactlsconnection.c8
5 files changed, 66 insertions, 50 deletions
diff --git a/src/lac.h b/src/lac.h
index 3f21ce7..b2f7c84 100644
--- a/src/lac.h
+++ b/src/lac.h
@@ -282,28 +282,28 @@ typedef struct _LacConnection LacConnection;
typedef void (* LacConnectionFunc) (LacConnection *connection,
const LacConnectionEvent *event);
-LacConnection * lac_connection_new_tcp (const LacAddress *address,
- gint port,
- LacConnectionFunc callback,
- gpointer data);
-LacConnection * lac_connection_new_tls (const LacAddress *address,
- gint port,
- LacConnectionFunc callback,
- gpointer data);
-gpointer lac_connection_get_data (LacConnection *connection);
-void lac_connection_write (LacConnection *connection,
- const gchar *data,
- guint len);
-void lac_connection_write_cstr (LacConnection *connection,
- const gchar *data);
-void lac_connection_shutdown_write (LacConnection *connection);
-LacConnection * lac_connection_ref (LacConnection *connection);
-void lac_connection_unref (LacConnection *connection);
-G_CONST_RETURN LacAddress *lac_connection_get_address (LacConnection *connection);
-gint lac_connection_get_port (LacConnection *connection);
-void lac_connection_close (LacConnection *connection);
-gboolean lac_connection_is_connected (LacConnection *connection);
-void lac_connection_flush (LacConnection *connection);
+LacConnection * lac_connection_new_tcp (const LacAddress *address,
+ gint port,
+ LacConnectionFunc callback,
+ gpointer data);
+LacConnection * lac_connection_new_tls (const LacAddress *address,
+ gint port,
+ LacConnectionFunc callback,
+ gpointer data);
+gpointer lac_connection_get_data (LacConnection *connection);
+void lac_connection_write (LacConnection *connection,
+ const gchar *data,
+ guint len);
+void lac_connection_write_cstr (LacConnection *connection,
+ const gchar *data);
+void lac_connection_shutdown_write (LacConnection *connection);
+LacConnection * lac_connection_ref (LacConnection *connection);
+void lac_connection_unref (LacConnection *connection);
+const LacAddress *lac_connection_get_address (LacConnection *connection);
+gint lac_connection_get_port (LacConnection *connection);
+void lac_connection_close (LacConnection *connection);
+gboolean lac_connection_is_connected (LacConnection *connection);
+void lac_connection_flush (LacConnection *connection);
/*
@@ -375,8 +375,9 @@ typedef enum {
LAC_HTTP_ERROR_PREMATURE_CLOSE, /* server closed connection before
* sending a complete response
*/
- LAC_HTTP_ERROR_PIPELINE_TIMEOUT /* Some servers have a bug that make them stall
- * in the middle of a pipelined response.
+ LAC_HTTP_ERROR_PIPELINE_TIMEOUT /* Some servers have a bug that
+ * make them stall in the middle of
+ * a pipelined response.
*/
} LacHttpError;
diff --git a/src/lacaddress.c b/src/lacaddress.c
index ca5c52b..4b14a9a 100644
--- a/src/lacaddress.c
+++ b/src/lacaddress.c
@@ -692,15 +692,15 @@ lac_address_get_a_b_c_d (const LacAddress *addr,
}
void
-lac_address_get_in_addr (const LacAddress *addr,
- struct in_addr *in_addr)
+lac_address_get_in_addr (const LacAddress *addr,
+ struct in_addr *in_addr)
{
*in_addr = addr->in_address;
}
void
-lac_address_set_in_addr (LacAddress *addr,
- struct in_addr *in_addr)
+lac_address_set_in_addr (LacAddress *addr,
+ struct in_addr *in_addr)
{
addr->in_address = *in_addr;
}
diff --git a/src/lacconnection.c b/src/lacconnection.c
index 054f84a..c7f7740 100644
--- a/src/lacconnection.c
+++ b/src/lacconnection.c
@@ -58,40 +58,51 @@ on_ssl_event (LacTlsConnection *connection,
gen->func (gen, event);
}
-LacConnection *
-lac_connection_new_tcp (const LacAddress *address,
- gint port,
- LacConnectionFunc func,
- gpointer data)
+static LacConnection *
+lac_connection_new_internal (const LacAddress *address,
+ gint port,
+ LacConnectionFunc func,
+ gpointer data)
{
LacConnection *connection = g_new0 (LacConnection, 1);
- connection->is_tcp = TRUE;
- connection->u.tcp = lac_tcp_connection_new (address, port, on_tcp_event, connection);
connection->ref_count = 1;
connection->func = func;
connection->data = data;
connection->address = lac_address_copy (address);
connection->port = port;
+
+ return connection;
+}
+
+LacConnection *
+lac_connection_new_tcp (const LacAddress *address,
+ gint port,
+ LacConnectionFunc func,
+ gpointer data)
+{
+ LacConnection *connection =
+ lac_connection_new_internal (address, port, func, data);
+
+ connection->is_tcp = TRUE;
+ connection->u.tcp = lac_tcp_connection_new (address, port,
+ on_tcp_event, connection);
return connection;
}
LacConnection *
lac_connection_new_tls (const LacAddress *address,
- gint port,
+ gint port,
LacConnectionFunc func,
- gpointer data)
+ gpointer data)
{
- LacConnection *connection = g_new0 (LacConnection, 1);
+ LacConnection *connection =
+ lac_connection_new_internal (address, port, func, data);
connection->is_tcp = FALSE;
- connection->u.tls = lac_tls_connection_new (address, port, on_ssl_event, connection);
- connection->ref_count = 1;
- connection->func = func;
- connection->data = data;
- connection->address = lac_address_copy (address);
- connection->port = port;
+ connection->u.tls = lac_tls_connection_new (address, port,
+ on_ssl_event, connection);
return connection;
}
@@ -156,7 +167,7 @@ lac_connection_write_cstr (LacConnection *connection,
lac_connection_write (connection, data, len);
}
-G_CONST_RETURN LacAddress *
+const LacAddress *
lac_connection_get_address (LacConnection *connection)
{
return connection->address;
diff --git a/src/lacprimitives.c b/src/lacprimitives.c
index 0e6ce70..46c0838 100644
--- a/src/lacprimitives.c
+++ b/src/lacprimitives.c
@@ -69,9 +69,9 @@ extern gint h_errno;
#include <gnutls/gnutls.h>
-static void set_error_from_errno (GError **err,
- gint eno,
- const gchar *msg);
+static void set_error_from_errno (GError **err,
+ gint eno,
+ const gchar *msg);
GQuark
lac_socket_error_quark (void)
diff --git a/src/lactlsconnection.c b/src/lactlsconnection.c
index 0181f28..5769522 100644
--- a/src/lactlsconnection.c
+++ b/src/lactlsconnection.c
@@ -160,7 +160,10 @@ do_writes (LacTlsConnection *connection)
if (err)
{
emit_error (connection, err);
-
+
+ /* Closing here gurantees that the next event emitted by
+ * the TCP connection is going to be "close"
+ */
lac_connection_close (connection->tcp_connection);
}
}
@@ -304,7 +307,8 @@ lac_tls_connection_new (const LacAddress *address,
{
LacTlsConnection *tls = g_new0 (LacTlsConnection, 1);
- tls->tcp_connection = lac_connection_new_tcp (address, port, tcp_callback, tls);
+ tls->tcp_connection = lac_connection_new_tcp (
+ address, port, tcp_callback, tls);
tls->need_handshake = TRUE;
tls->callback = callback;
tls->data = data;