Simplify connect code.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 15 Oct 2006 13:06:35 +0000 (15:06 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 15 Oct 2006 13:06:35 +0000 (15:06 +0200)
src/admin.c
src/network.c
src/network.h

index 4777a5fc453856d842b9f4b8fa7d07010ce3a768..d94cfcdc42370d292adc91a1aedac0b25de649bf 100644 (file)
@@ -154,13 +154,12 @@ static void com_connect_network (struct client *c, char **args, void *userdata)
                        network_select_next_server(s);
                        connect_network(s);
                        break;
-               case NETWORK_CONNECTION_STATE_CONNECTED:
-                       admin_out(c, "Already connected to `%s'", args[1]);
-                       break;
                case NETWORK_CONNECTION_STATE_LOGIN_SENT:
-               case NETWORK_CONNECTION_STATE_MOTD_RECVD:
                        admin_out(c, "Connect to `%s' already in progress", args[1]);
                        break;
+               case NETWORK_CONNECTION_STATE_MOTD_RECVD:
+                       admin_out(c, "Already connected to `%s'", args[1]);
+                       break;
        }
 }
 
@@ -294,7 +293,6 @@ static void list_networks(struct client *c, char **args, void *userdata)
                case NETWORK_CONNECTION_STATE_RECONNECT_PENDING:
                        admin_out(c, ("%s: Reconnecting"), n->name);
                        break;
-               case NETWORK_CONNECTION_STATE_CONNECTED:
                case NETWORK_CONNECTION_STATE_LOGIN_SENT:
                case NETWORK_CONNECTION_STATE_MOTD_RECVD:
                        admin_out(c, ("%s: connected"), n->name);
index d495a362ce13e87ecd50338db5c375957f8a6b94..056ea5b78d2b5e15b0df550929236e1f6468d33d 100644 (file)
@@ -46,7 +46,6 @@ static void server_send_login (struct network *s)
 {
        g_assert(s);
 
-       g_assert(s->connection.state == NETWORK_CONNECTION_STATE_CONNECTED);
        s->connection.state = NETWORK_CONNECTION_STATE_LOGIN_SENT;
 
        log_network(NULL, LOG_TRACE, s, "Sending login details");
@@ -221,22 +220,6 @@ static gboolean handle_server_receive (GIOChannel *c, GIOCondition cond, void *_
        return TRUE;
 }
 
-static gboolean handle_server_connected (GIOChannel *c, GIOCondition cond, void *_server)
-{
-       struct network *server = (struct network *)_server;
-
-       g_assert(server);
-
-       server->connection.state = NETWORK_CONNECTION_STATE_CONNECTED;
-       server_send_login(server);
-
-       server->connection.incoming_id = g_io_add_watch(server->connection.outgoing, G_IO_IN | G_IO_HUP | G_IO_ERR, handle_server_receive, server);
-       
-       return FALSE;
-}
-
-
-
 static struct tcp_server_config *network_get_next_tcp_server(struct network *n)
 {
        GList *cur;
@@ -514,7 +497,8 @@ static gboolean connect_current_tcp_server(struct network *s)
 
        s->connection.outgoing = ioc;
        
-       s->connection.incoming_id = g_io_add_watch(s->connection.outgoing, G_IO_OUT, handle_server_connected, s);
+       s->connection.incoming_id = g_io_add_watch(s->connection.outgoing, G_IO_IN | G_IO_HUP | G_IO_ERR, handle_server_receive, s);
+       server_send_login(s);
 
        g_io_channel_unref(s->connection.outgoing);
 
@@ -672,7 +656,6 @@ static gboolean connect_program(struct network *s)
 
        s->connection.outgoing = g_io_channel_unix_new(sock);
        g_io_channel_set_close_on_unref(s->connection.outgoing, TRUE);
-       s->connection.state = NETWORK_CONNECTION_STATE_CONNECTED;
 
        server_send_login(s);
        
index be4a655e8e3bd5a4829672aaaebdac8bf3ddc5d6..62db357abf6b52d7731f63d2b7e985b743d72cf8 100644 (file)
@@ -35,7 +35,6 @@ struct linestack_context;
 enum network_connection_state { 
                NETWORK_CONNECTION_STATE_NOT_CONNECTED = 0, 
                NETWORK_CONNECTION_STATE_RECONNECT_PENDING,
-               NETWORK_CONNECTION_STATE_CONNECTED,
                NETWORK_CONNECTION_STATE_LOGIN_SENT, 
                NETWORK_CONNECTION_STATE_MOTD_RECVD,
 };