summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann <sandmann@redhat.com>2007-07-30 02:00:59 -0400
committerSøren Sandmann <sandmann@redhat.com>2007-07-30 02:00:59 -0400
commitcd28b76a9837d9e8818cb24358773ff085886509 (patch)
tree4186db537c082e97d43cd8675b5a538b1c675092
parent599abadb66b57b93e99fd53f2e23ac2ea4a539c7 (diff)
Revert last commit
-rw-r--r--src/lac.h79
-rw-r--r--src/lacconnection.c187
-rw-r--r--src/lacdns-nameserver.c26
-rw-r--r--src/lachttp.c42
4 files changed, 77 insertions, 257 deletions
diff --git a/src/lac.h b/src/lac.h
index 4ae0251..db5396e 100644
--- a/src/lac.h
+++ b/src/lac.h
@@ -263,69 +263,70 @@ gboolean lac_fd_is_watched (gint fd);
/*
* Connection
*/
-typedef struct _LacGConnection LacGConnection;
-typedef union _LacGConnectionEvent LacGConnectionEvent;
+typedef struct _LacConnection LacConnection;
+typedef union _LacConnectionEvent LacConnectionEvent;
typedef enum {
- LAC_GCONNECTION_EVENT_CONNECT, /* connect successful */
- LAC_GCONNECTION_EVENT_READ, /* data to read */
- LAC_GCONNECTION_EVENT_CLOSE, /* GConnection closed */
- LAC_GCONNECTION_EVENT_ERROR, /* error */
-} LacGConnectionEventType;
+ LAC_CONNECTION_EVENT_CONNECT, /* connect successful */
+ LAC_CONNECTION_EVENT_READ, /* data to read */
+ LAC_CONNECTION_EVENT_CLOSE, /* Connection closed */
+ LAC_CONNECTION_EVENT_ERROR, /* error */
+} LacConnectionEventType;
typedef struct {
- LacGConnectionEventType type;
-} LacGConnectionConnectEvent;
+ LacConnectionEventType type;
+} LacConnectionConnectEvent;
typedef struct {
- LacGConnectionEventType type;
+ LacConnectionEventType type;
gpointer _lac_reserved0;
gpointer _lac_reserved1;
LacByteQueue *byte_queue;
const gchar *data;
guint len;
-} LacGConnectionReadEvent;
+} LacConnectionReadEvent;
typedef struct {
- LacGConnectionEventType type;
+ LacConnectionEventType type;
gboolean remote_closed; /* true: remote closed.
false: local closed */
-} LacGConnectionCloseEvent;
+} LacConnectionCloseEvent;
typedef struct {
- LacGConnectionEventType type;
+ LacConnectionEventType type;
const GError *err;
-} LacGConnectionErrorEvent;
-
-union _LacGConnectionEvent {
- LacGConnectionEventType type;
- LacGConnectionConnectEvent connect;
- LacGConnectionReadEvent read;
- LacGConnectionCloseEvent close;
- LacGConnectionErrorEvent error;
+} LacConnectionErrorEvent;
+
+union _LacConnectionEvent {
+ LacConnectionEventType type;
+ LacConnectionConnectEvent connect;
+ LacConnectionReadEvent read;
+ LacConnectionCloseEvent close;
+ LacConnectionErrorEvent error;
};
-typedef void (* LacGConnectionFunc) (LacGConnection *connection,
- const LacGConnectionEvent *event);
+typedef void (* LacConnectionFunc) (LacConnection *connection,
+ const LacConnectionEvent *event);
-LacGConnection * lac_g_connection_new (const LacAddress *address,
- gint port,
- LacGConnectionFunc callback,
- gpointer data);
-gpointer lac_g_connection_get_data (LacGConnection *connection);
-void lac_g_connection_write (LacGConnection *connection,
+LacConnection * lac_connection_new (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_g_connection_write_cstr (LacGConnection *connection,
+void lac_connection_write_cstr (LacConnection *connection,
const gchar *data);
-void lac_g_connection_shutdown_write (LacGConnection *connection);
-LacGConnection * lac_g_connection_ref (LacGConnection *connection);
-void lac_g_connection_unref (LacGConnection *connection);
-G_CONST_RETURN LacAddress *lac_g_connection_get_address (LacGConnection *connection);
-gint lac_g_connection_get_port (LacGConnection *connection);
-void lac_g_connection_close (LacGConnection *connection);
-gboolean lac_g_connection_is_connected (LacGConnection *connection);
-void lac_g_connection_flush (LacGConnection *connection);
+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);
+
/*
* URI
diff --git a/src/lacconnection.c b/src/lacconnection.c
index e8b4365..d96a7f4 100644
--- a/src/lacconnection.c
+++ b/src/lacconnection.c
@@ -1,72 +1,3 @@
-
-#include "lac.h"
-#include <string.h>
-typedef struct _LacConnection LacConnection;
-typedef union _LacConnectionEvent LacConnectionEvent;
-
-typedef enum {
- LAC_CONNECTION_EVENT_CONNECT, /* connect successful */
- LAC_CONNECTION_EVENT_READ, /* data to read */
- LAC_CONNECTION_EVENT_CLOSE, /* Connection closed */
- LAC_CONNECTION_EVENT_ERROR, /* error */
-} LacConnectionEventType;
-
-typedef struct {
- LacConnectionEventType type;
-} LacConnectionConnectEvent;
-
-typedef struct {
- LacConnectionEventType type;
- gpointer _lac_reserved0;
- gpointer _lac_reserved1;
- LacByteQueue *byte_queue;
- const gchar *data;
- guint len;
-} LacConnectionReadEvent;
-
-typedef struct {
- LacConnectionEventType type;
- gboolean remote_closed; /* true: remote closed.
- false: local closed */
-} LacConnectionCloseEvent;
-
-typedef struct {
- LacConnectionEventType type;
- const GError *err;
-} LacConnectionErrorEvent;
-
-union _LacConnectionEvent {
- LacConnectionEventType type;
- LacConnectionConnectEvent connect;
- LacConnectionReadEvent read;
- LacConnectionCloseEvent close;
- LacConnectionErrorEvent error;
-};
-
-typedef void (* LacConnectionFunc) (LacConnection *connection,
- const LacConnectionEvent *event);
-
-LacConnection * lac_connection_new (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);
-
-
-
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- */
/* Lac - Library for asynchronous communication
@@ -88,6 +19,9 @@ void lac_connection_flush (LacConnection *con
* Boston, MA 02111-1307, USA.
*/
+#include "lac.h"
+#include <string.h>
+
/*
* Prototypes for a primitive abstraction covering TCP and SSL
*/
@@ -608,118 +542,3 @@ lac_connection_flush (LacConnection *connection)
if (lac_byte_queue_get_length (connection->unwritten) == 0)
lac_connection_do_writes (connection);
}
-
-
-
-
-
-
-
-
-
-
-
-/******** general connection ************/
-
-struct _LacGConnection
-{
- LacConnection *connection;
-
- LacGConnectionFunc func;
- gpointer data;
-};
-
-static void
-on_connection_callback (LacConnection *connection,
- const LacConnectionEvent *event)
-{
- LacGConnection *g_connection = lac_connection_get_data (connection);
-
- g_connection->func (g_connection, (LacGConnectionEvent *)event);
-}
-
-LacGConnection *
-lac_g_connection_new (const LacAddress *address,
- gint port,
- LacGConnectionFunc callback,
- gpointer data)
-{
- LacGConnection *g_connection = g_new0 (LacGConnection, 1);
-
- g_connection->connection = lac_connection_new (address, port,
- on_connection_callback, g_connection);
-
- return g_connection;
-}
-
-gpointer
-lac_g_connection_get_data (LacGConnection *connection)
-{
- return connection->data;
-}
-
-void
-lac_g_connection_write (LacGConnection *connection,
- const gchar *data,
- guint len)
-{
- lac_connection_write (connection->connection, data, len);
-}
-
-void
-lac_g_connection_write_cstr (LacGConnection *connection,
- const gchar *data)
-{
- lac_connection_write_cstr (connection->connection, data);
-}
-
-void
-lac_g_connection_shutdown_write (LacGConnection *connection)
-{
- lac_connection_shutdown_write (connection->connection);
-}
-
-LacGConnection *
-lac_g_connection_ref (LacGConnection *connection)
-{
- lac_connection_ref (connection->connection);
-
- return connection;
-}
-
-void
-lac_g_connection_unref (LacGConnection *connection)
-{
- lac_connection_unref (connection->connection);
-}
-
-G_CONST_RETURN LacAddress *
-lac_g_connection_get_address (LacGConnection *connection)
-{
- return lac_connection_get_address (connection->connection);
-}
-
-
-gint
-lac_g_connection_get_port (LacGConnection *connection)
-{
- return lac_connection_get_port (connection->connection);
-}
-
-void
-lac_g_connection_close (LacGConnection *connection)
-{
- lac_connection_close (connection->connection);
-}
-
-gboolean
-lac_g_connection_is_connected (LacGConnection *connection)
-{
- return lac_connection_is_connected (connection->connection);
-}
-
-void
-lac_g_connection_flush (LacGConnection *connection)
-{
- lac_connection_flush (connection->connection);
-}
diff --git a/src/lacdns-nameserver.c b/src/lacdns-nameserver.c
index 601d9ff..8e2eacf 100644
--- a/src/lacdns-nameserver.c
+++ b/src/lacdns-nameserver.c
@@ -324,10 +324,10 @@ typedef struct TcpClosure {
} TcpClosure;
static void
-name_server_handle_tcp_event (LacGConnection *connection,
- const LacGConnectionEvent *event)
+name_server_handle_tcp_event (LacConnection *connection,
+ const LacConnectionEvent *event)
{
- TcpClosure *closure = lac_g_connection_get_data (connection);
+ TcpClosure *closure = lac_connection_get_data (connection);
#if 0
lac_debug_checkpoint ();
@@ -335,11 +335,11 @@ name_server_handle_tcp_event (LacGConnection *connection,
switch (event->type)
{
- case LAC_GCONNECTION_EVENT_CONNECT:
+ case LAC_CONNECTION_EVENT_CONNECT:
/* ignore */
break;
- case LAC_GCONNECTION_EVENT_READ:
+ case LAC_CONNECTION_EVENT_READ:
g_string_append_len (
closure->unparsed_data, event->read.data, event->read.len);
@@ -347,11 +347,11 @@ name_server_handle_tcp_event (LacGConnection *connection,
closure->server->outstanding_queries,
closure->unparsed_data->str, closure->unparsed_data->len))
{
- lac_g_connection_close (connection);
+ lac_connection_close (connection);
}
break;
- case LAC_GCONNECTION_EVENT_CLOSE:
+ case LAC_CONNECTION_EVENT_CLOSE:
if (event->close.remote_closed && closure->unparsed_data->len > 0)
{
/* Since we didn't get a useful response, we can't
@@ -361,14 +361,14 @@ name_server_handle_tcp_event (LacGConnection *connection,
g_warning ("DNS: server closed connection in the "
"middle of a message");
}
- lac_g_connection_unref (connection);
+ lac_connection_unref (connection);
g_string_free (closure->unparsed_data, TRUE);
g_free (closure);
break;
- case LAC_GCONNECTION_EVENT_ERROR:
+ case LAC_CONNECTION_EVENT_ERROR:
g_warning ("error: %s\n", event->error.err->message);
- lac_g_connection_unref (connection);
+ lac_connection_unref (connection);
g_string_free (closure->unparsed_data, TRUE);
g_free (closure);
break;
@@ -383,7 +383,7 @@ static void
name_server_dispatch_tcp_query (NameServer *server, Query *query)
{
TcpClosure *closure;
- LacGConnection *connection;
+ LacConnection *connection;
GString *msg_str;
g_assert (!g_hash_table_lookup (
@@ -398,7 +398,7 @@ name_server_dispatch_tcp_query (NameServer *server, Query *query)
#if 0
g_print ("NEW CONNECTION\n");
#endif
- connection = lac_g_connection_new (
+ connection = lac_connection_new (
server->address, DNS_PORT,
name_server_handle_tcp_event, closure);
@@ -411,7 +411,7 @@ name_server_dispatch_tcp_query (NameServer *server, Query *query)
/* message */
g_string_append_len (msg_str, query->msg, query->msg_len);
- lac_g_connection_write (connection, msg_str->str, msg_str->len);
+ lac_connection_write (connection, msg_str->str, msg_str->len);
query->timeout_id = g_timeout_add (QUERY_TIMEOUT, query_timeout, query);
g_string_free (msg_str, TRUE);
diff --git a/src/lachttp.c b/src/lachttp.c
index bf4bd35..6717d50 100644
--- a/src/lachttp.c
+++ b/src/lachttp.c
@@ -241,7 +241,7 @@ static void http_host_transport_closed_notify (HttpHost *hos
*/
struct _HttpTransport {
HttpHost * host;
- LacGConnection * connection;
+ LacConnection * connection;
GQueue * unsent;
GQueue * in_progress;
LacHttpRequest * current;
@@ -2026,7 +2026,7 @@ answer_timeout (gpointer data)
#endif
server_choked_on_pipeline (transport, CHOKE_RECOVERY);
http_host_transport_will_close_notify (transport->host, transport);
- lac_g_connection_close (transport->connection);
+ lac_connection_close (transport->connection);
}
return FALSE;
@@ -2064,8 +2064,8 @@ http_transport_flush_write_buffer (HttpTransport *transport)
if (n_bytes > 0)
{
- /* FIXME: should we have a lac_g_connection_write_byte_queue()? */
- lac_g_connection_write (transport->connection, bytes, n_bytes);
+ /* FIXME: should we have a lac_connection_write_byte_queue()? */
+ lac_connection_write (transport->connection, bytes, n_bytes);
lac_byte_queue_delete_head (transport->write_buffer, n_bytes);
}
@@ -2077,7 +2077,7 @@ flush_write_buffer_timeout (gpointer data)
HttpTransport *transport = data;
http_transport_flush_write_buffer (transport);
- lac_g_connection_flush (transport->connection);
+ lac_connection_flush (transport->connection);
transport->write_timeout = 0;
return FALSE;
@@ -2088,7 +2088,7 @@ flush_write_buffer_timeout (gpointer data)
* we have serialized it. There is no point in distinguishing
* between stuff we have buffered up here and stuff that has
* been passed to send(), because it could just as well be buffered
- * in the LacGConnection, in the kernel or in transit.
+ * in the LacConnection, in the kernel or in transit.
*/
static void
http_transport_transmit_request (HttpTransport *transport,
@@ -2143,7 +2143,7 @@ http_transport_transmit_request (HttpTransport *transport,
else
{
http_transport_flush_write_buffer (transport);
- lac_g_connection_flush (transport->connection);
+ lac_connection_flush (transport->connection);
}
http_transport_reset_answer_timeout (transport);
@@ -2188,7 +2188,7 @@ static void
write_log_file (HttpTransport * transport,
guint len,
gint used,
- const LacGConnectionReadEvent *read_event)
+ const LacConnectionReadEvent *read_event)
{
static FILE *f;
int i, n_bytes;
@@ -2222,7 +2222,7 @@ write_log_file (HttpTransport * transport,
static void
http_transport_handle_read (HttpTransport *transport,
- const LacGConnectionReadEvent *read_event)
+ const LacConnectionReadEvent *read_event)
{
#if 0
{
@@ -2288,7 +2288,7 @@ http_transport_handle_read (HttpTransport *transport,
}
g_error_free (err);
- lac_g_connection_close (transport->connection);
+ lac_connection_close (transport->connection);
break;
}
@@ -2382,7 +2382,7 @@ http_transport_handle_read (HttpTransport *transport,
/* FIXME return outstanding */
http_host_transport_will_close_notify (
transport->host, transport);
- lac_g_connection_close (transport->connection);
+ lac_connection_close (transport->connection);
}
}
}
@@ -2425,16 +2425,16 @@ http_transport_handle_close (HttpTransport *transport)
}
static void
-connection_callback (LacGConnection *connection,
- const LacGConnectionEvent *event)
+connection_callback (LacConnection *connection,
+ const LacConnectionEvent *event)
{
- HttpTransport *transport = lac_g_connection_get_data (connection);
+ HttpTransport *transport = lac_connection_get_data (connection);
http_transport_reset_answer_timeout (transport);
switch (event->type)
{
- case LAC_GCONNECTION_EVENT_CONNECT:
+ case LAC_CONNECTION_EVENT_CONNECT:
#if 0
g_print ("CONNECT\n");
#endif
@@ -2447,18 +2447,18 @@ connection_callback (LacGConnection *connection,
}
break;
- case LAC_GCONNECTION_EVENT_READ:
+ case LAC_CONNECTION_EVENT_READ:
http_transport_handle_read (transport, &(event->read));
break;
- case LAC_GCONNECTION_EVENT_CLOSE:
+ case LAC_CONNECTION_EVENT_CLOSE:
#if 0
g_print ("%p HTTP TRANSPORT CLOSED\n", transport);
#endif
http_transport_handle_close (transport);
break;
- case LAC_GCONNECTION_EVENT_ERROR:
+ case LAC_CONNECTION_EVENT_ERROR:
g_print ("seen error: %s\n", event->error.err->message);
if (!transport->broken_server &&
@@ -2564,7 +2564,7 @@ http_transport_new (HttpHost *host,
#endif
transport->host = host;
- transport->connection = lac_g_connection_new (
+ transport->connection = lac_connection_new (
host->address, host->port, connection_callback, transport);
transport->unsent = g_queue_new ();
@@ -2584,7 +2584,7 @@ http_transport_new (HttpHost *host,
static void
http_transport_destroy (HttpTransport *transport)
{
- lac_g_connection_unref (transport->connection);
+ lac_connection_unref (transport->connection);
#if 0
g_source_remove (transport->debug_timeout);
@@ -2617,7 +2617,7 @@ http_transport_add_request (HttpTransport *transport,
request->transport = transport;
- if (lac_g_connection_is_connected (transport->connection))
+ if (lac_connection_is_connected (transport->connection))
{
http_transport_transmit_request (transport, request);
}