Removed the async_connect_waiting and blocking states from LmConnection.
As a first step of cleaning up the network code underlying LmConnection I want to make the blocking and non-blocking calls be as similar as possible.
The socket should be able to connect in asynchronous manner even if we want to block on the open call since the mainloop iteration will handle the "block" for lm_connection_open_and_block.
--- a/loudmouth/lm-connection.c Fri Oct 24 00:21:42 2008 +0200
+++ b/loudmouth/lm-connection.c Sat Oct 25 16:21:50 2008 +0200
@@ -135,9 +135,6 @@
guint open_id;
LmCallback *open_cb;
- gboolean async_connect_waiting;
- gboolean blocking;
-
gboolean cancel_open;
LmCallback *auth_cb;
@@ -521,7 +518,6 @@
(ConnectResultFunc) connection_socket_connect_cb,
connection,
connection,
- connection->blocking,
connection->server,
domain,
connection->port,
@@ -538,7 +534,6 @@
lm_message_queue_attach (connection->queue, connection->context);
connection->state = LM_CONNECTION_STATE_OPENING;
- connection->async_connect_waiting = FALSE;
return TRUE;
}
@@ -557,12 +552,10 @@
if (!lm_connection_is_open (connection)) {
/* lm_connection_is_open is FALSE for state OPENING as well */
connection->state = LM_CONNECTION_STATE_CLOSED;
- connection->async_connect_waiting = FALSE;
return;
}
connection->state = LM_CONNECTION_STATE_CLOSED;
- connection->async_connect_waiting = FALSE;
if (connection->sasl) {
lm_sasl_free (connection->sasl);
@@ -999,19 +992,6 @@
return server;
}
-gboolean
-_lm_connection_async_connect_waiting (LmConnection *connection)
-{
- return connection->async_connect_waiting;
-}
-
-void
-_lm_connection_set_async_connect_waiting (LmConnection *connection,
- gboolean waiting)
-{
- connection->async_connect_waiting = waiting;
-}
-
static void
connection_call_auth_cb (LmConnection *connection, gboolean success)
{
@@ -1294,7 +1274,6 @@
connection->open_cb = _lm_utils_new_callback (function,
user_data, notify);
- connection->blocking = FALSE;
return connection_do_open (connection, error);
}
@@ -1316,7 +1295,6 @@
g_return_val_if_fail (connection != NULL, FALSE);
connection->open_cb = NULL;
- connection->blocking = TRUE;
result = connection_do_open (connection, error);
--- a/loudmouth/lm-internals.h Fri Oct 24 00:21:42 2008 +0200
+++ b/loudmouth/lm-internals.h Sat Oct 25 16:21:50 2008 +0200
@@ -66,11 +66,6 @@
int error);
gboolean _lm_old_socket_failed (LmConnectData *data);
void _lm_old_socket_succeeded (LmConnectData *data);
-gboolean
-_lm_connection_async_connect_waiting (LmConnection *conn);
-void
-_lm_connection_set_async_connect_waiting (LmConnection *conn,
- gboolean waiting);
LmCallback * _lm_utils_new_callback (gpointer func,
gpointer data,
--- a/loudmouth/lm-old-socket.c Fri Oct 24 00:21:42 2008 +0200
+++ b/loudmouth/lm-old-socket.c Sat Oct 25 16:21:50 2008 +0200
@@ -65,8 +65,6 @@
gchar *server;
guint port;
- gboolean blocking;
-
LmSSL *ssl;
gboolean ssl_started;
LmProxy *proxy;
@@ -549,6 +547,7 @@
}
}
+#if 0
if (_lm_connection_async_connect_waiting (socket->connection)) {
gint res;
@@ -578,7 +577,9 @@
goto out;
}
}
- } else {
+ } else {
+#endif
+ {
/* for blocking sockets, G_IO_OUT means we are connected */
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET,
"Connection success (2).\n");
@@ -650,8 +651,6 @@
g_io_channel_set_encoding (connect_data->io_channel, NULL, NULL);
g_io_channel_set_buffered (connect_data->io_channel, FALSE);
-
- _lm_sock_set_blocking (connect_data->fd, socket->blocking);
if (socket->proxy) {
socket->watch_connect =
@@ -669,8 +668,6 @@
connect_data);
}
- _lm_connection_set_async_connect_waiting (socket->connection, !socket->blocking);
-
res = _lm_sock_connect (connect_data->fd,
addr->ai_addr, (int)addr->ai_addrlen);
if (res < 0) {
@@ -836,7 +833,6 @@
ConnectResultFunc connect_func,
gpointer user_data,
LmConnection *connection,
- gboolean blocking,
const gchar *server,
const gchar *domain,
guint port,
@@ -865,7 +861,6 @@
socket->ssl = ssl;
socket->ssl_started = FALSE;
socket->proxy = NULL;
- socket->blocking = blocking;
if (context) {
socket->context = g_main_context_ref (context);
--- a/loudmouth/lm-old-socket.h Fri Oct 24 00:21:42 2008 +0200
+++ b/loudmouth/lm-old-socket.h Sat Oct 25 16:21:50 2008 +0200
@@ -45,7 +45,6 @@
ConnectResultFunc connect_func,
gpointer user_data,
LmConnection *connection,
- gboolean blocking,
const gchar *server,
const gchar *domain,
guint port,