]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added service_count setting to limit how many requests a service can handle before...
authorTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2009 18:07:35 +0000 (14:07 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 31 Aug 2009 18:07:35 +0000 (14:07 -0400)
--HG--
branch : HEAD

src/lib-master/master-interface.h
src/lib-master/master-service.c
src/master/master-settings.c
src/master/master-settings.h
src/master/service-process.c

index 7b69006ecb8e9276304ed186a1284c2517e81a27..168c847ba0413dc57ff9c17c9b70a2de11d937bf 100644 (file)
@@ -77,6 +77,10 @@ struct master_auth_reply {
    master_status.available_count as specified in configuration file */
 #define MASTER_CLIENT_LIMIT_ENV "CLIENT_LIMIT"
 
+/* getenv(MASTER_SERVICE_COUNT_ENV) specifies how many client connections the
+   process can finish handling before it should kill itself. */
+#define MASTER_SERVICE_COUNT_ENV "SERVICE_COUNT"
+
 /* getenv(MASTER_CONFIG_FILE_ENV) provides path to configuration file/socket */
 #define MASTER_CONFIG_FILE_ENV "CONFIG_FILE"
 
index 25b409b73031ed502a9a6f4dee711a5caeb5c3cd..750b490e6e6d4a4c18203dd904f4bdb253d85fbc 100644 (file)
@@ -273,6 +273,13 @@ void master_service_init_finish(struct master_service *service)
                        i_fatal(MASTER_CLIENT_LIMIT_ENV" not set");
                master_service_set_client_limit(service, count);
 
+               /* set the default service count */
+               value = getenv(MASTER_SERVICE_COUNT_ENV);
+               count = value == NULL ? 0 :
+                       (unsigned int)strtoul(value, NULL, 10);
+               if (count > 0)
+                       master_service_set_service_count(service, count);
+
                /* start listening errors for status fd, it means master died */
                service->io_status_error = io_add(MASTER_STATUS_FD, IO_ERROR,
                                                  master_status_error, service);
index 52b1b94b39bb14a94b973b4beca925a008ed0b62..b075a758a076d74989a97dd61e4cf7d90fdcfbe5 100644 (file)
@@ -102,6 +102,7 @@ static struct setting_define service_setting_defines[] = {
 
        DEF(SET_UINT, process_limit),
        DEF(SET_UINT, client_limit),
+       DEF(SET_UINT, service_count),
        DEF(SET_UINT, vsz_limit),
 
        DEFLIST(unix_listeners, "unix_listener",
@@ -132,6 +133,7 @@ static struct service_settings service_default_settings = {
 
        MEMBER(process_limit) (unsigned int)-1,
        MEMBER(client_limit) 0,
+       MEMBER(service_count) 0,
        MEMBER(vsz_limit) 256,
 
        MEMBER(unix_listeners) ARRAY_INIT,
index 0ed31ad82292af20a71974e53fdaf651aeaeaeda..081c5937d66a561ffa4967fe2c13ad2daad8c7b9 100644 (file)
@@ -33,6 +33,7 @@ struct service_settings {
 
        unsigned int process_limit;
        unsigned int client_limit;
+       unsigned int service_count;
        unsigned int vsz_limit;
 
        ARRAY_TYPE(file_listener_settings) unix_listeners;
index 0232c4bc2c0eb41070cf955d768856d4c109a1ad..a5362be13bcb949322d00ee4edd164950bfc415a 100644 (file)
@@ -401,8 +401,11 @@ service_process_setup_environment(struct service *service, unsigned int uid)
                /* fallback to default limit */
                limit = service->set->master_set->default_client_limit;
        }
-
        env_put(t_strdup_printf(MASTER_CLIENT_LIMIT_ENV"=%u", limit));
+       if (service->set->service_count != 0) {
+               env_put(t_strdup_printf(MASTER_SERVICE_COUNT_ENV"=%u",
+                                       service->set->service_count));
+       }
        env_put(t_strdup_printf(MASTER_UID_ENV"=%u", uid));
 
        if (!service->set->master_set->version_ignore)