]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Changed post-login process's client counting to make sense again.
authorTimo Sirainen <tss@iki.fi>
Wed, 7 Apr 2010 01:20:55 +0000 (04:20 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 7 Apr 2010 01:20:55 +0000 (04:20 +0300)
This should also fix problems where a new process isn't created because an
existing one is waiting for auth request reply.

--HG--
branch : HEAD

src/lib-master/master-login.c
src/lib-master/master-service-private.h
src/lib-master/master-service.c

index f8ffed179db09f457aad353554ae272333432409..6c2679b0dda4bc55122477439f5c3e27fc80aeec 100644 (file)
@@ -28,6 +28,8 @@ struct master_login_connection {
        int fd;
        struct io *io;
        struct ostream *output;
+
+       unsigned int login_success:1;
 };
 
 struct master_login_postlogin {
@@ -187,6 +189,7 @@ static void master_login_auth_finish(struct master_login_client *client,
        close_sockets = service->master_status.available_count == 0 &&
                service->service_count_left == 1;
 
+       client->conn->login_success = TRUE;
        login->callback(client, auth_args[0], auth_args+1);
 
        if (close_sockets) {
@@ -250,7 +253,6 @@ static void master_login_postlogin_input(struct master_login_postlogin *pl)
                }
                master_login_client_free(&pl->client);
                master_login_postlogin_free(pl);
-               master_service_client_connection_destroyed(login->service);
                return;
        }
 
@@ -271,7 +273,6 @@ static void master_login_postlogin_timeout(struct master_login_postlogin *pl)
 
        master_login_client_free(&pl->client);
        master_login_postlogin_free(pl);
-       master_service_client_connection_destroyed(login->service);
 }
 
 static int master_login_postlogin(struct master_login_client *client,
@@ -329,7 +330,6 @@ master_login_auth_callback(const char *const *auth_args, const char *errormsg,
 {
        struct master_login_client *client = context;
        struct master_auth_reply reply;
-       struct master_service *service = client->conn->login->service;
 
        memset(&reply, 0, sizeof(reply));
        reply.tag = client->auth_req.tag;
@@ -348,18 +348,12 @@ master_login_auth_callback(const char *const *auth_args, const char *errormsg,
                return;
        }
 
-       i_assert(service->master_status.available_count > 0);
-       service->master_status.available_count--;
-       master_status_update(service);
-
        if (client->conn->login->postlogin_socket_path == NULL)
                master_login_auth_finish(client, auth_args);
        else {
                /* execute post-login scripts before finishing auth */
-               if (master_login_postlogin(client, auth_args) < 0) {
+               if (master_login_postlogin(client, auth_args) < 0)
                        master_login_client_free(&client);
-                       master_service_client_connection_destroyed(service);
-               }
        }
 }
 
@@ -410,12 +404,7 @@ void master_login_add(struct master_login *login, int fd)
 
        DLLIST_PREPEND(&login->conns, conn);
 
-       /* FIXME: currently there's a separate connection for each request.
-          and currently we don't try to accept more connections until this
-          request's authentication is finished, because updating
-          available_count gets tricky. */
-       login->service->login_authenticating = TRUE;
-       master_service_io_listeners_remove(login->service);
+       /* NOTE: currently there's a separate connection for each request. */
 }
 
 static void master_login_conn_close(struct master_login_connection *conn)
@@ -434,8 +423,8 @@ static void master_login_conn_close(struct master_login_connection *conn)
                i_error("close(master login) failed: %m");
        conn->fd = -1;
 
-       conn->login->service->login_authenticating = FALSE;
-       master_service_io_listeners_add(conn->login->service);
+       if (!conn->login_success)
+               master_service_client_connection_destroyed(conn->login->service);
 }
 
 static void master_login_conn_unref(struct master_login_connection **_conn)
index 3435960367f17dc7da2de6b9de0ccc3b1664b2e8..e76740fcdf69fe3d50ea3e758cba5523a5336108 100644 (file)
@@ -61,7 +61,6 @@ struct master_service {
        unsigned int call_avail_overflow:1;
        unsigned int delay_status_updates:1;
        unsigned int config_path_is_default:1;
-       unsigned int login_authenticating:1;
 };
 
 void master_service_io_listeners_add(struct master_service *service);
index 15c41df669461867cce6847375be9a30b997ca87..c50a2b94c27305e2350e2acaec2eff1b48538938 100644 (file)
@@ -706,14 +706,10 @@ static void master_service_listen(struct master_service_listener *l)
        conn.ssl = l->ssl;
        net_set_nonblock(conn.fd, TRUE);
 
-       if (service->login != NULL) {
-               /* incoming connections are going to master-login and they're
-                  not counted as real connections */
-       } else {
-               i_assert(service->master_status.available_count > 0);
-               service->master_status.available_count--;
-               master_status_update(service);
-       }
+       i_assert(service->master_status.available_count > 0);
+       service->master_status.available_count--;
+       master_status_update(service);
+
        service->callback(&conn);
 }
 
@@ -742,7 +738,7 @@ void master_service_io_listeners_add(struct master_service *service)
 {
        unsigned int i;
 
-       if (service->stopping || service->login_authenticating)
+       if (service->stopping)
                return;
 
        if (service->listeners == NULL)