]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
master: Make sure processes aren't created if its service is stopped.
authorTimo Sirainen <tss@iki.fi>
Thu, 5 Nov 2009 17:45:07 +0000 (12:45 -0500)
committerTimo Sirainen <tss@iki.fi>
Thu, 5 Nov 2009 17:45:07 +0000 (12:45 -0500)
--HG--
branch : HEAD

src/master/dup2-array.c
src/master/service-monitor.c
src/master/service-process.c

index ee370224f6c16808fd66a47f5eb001364d25c1f3..18e55020e3450574e3054936bbd76dc67b2110be 100644 (file)
@@ -11,6 +11,9 @@ void dup2_append(ARRAY_TYPE(dup2) *dups, int fd_src, int fd_dest)
 {
        struct dup2 d;
 
+       i_assert(fd_src >= 0);
+       i_assert(fd_dest >= 0);
+
        d.fd_src = fd_src;
        d.fd_dest = fd_dest;
        array_append(dups, &d, 1);
index 451f0345e69e971830757b3ab6aa8af78fcaeab4..c0b072e7b840aebd4367e2d3e50176bb10efbb34 100644 (file)
@@ -335,10 +335,8 @@ void services_monitor_start(struct service_list *service_list)
                                io_add(services[i]->status_fd[0], IO_READ,
                                       service_status_input, services[i]);
                }
-               if (services[i]->status_fd[0] != -1) {
-                       service_monitor_start_extra_avail(services[i]);
-                       service_monitor_listen_start(services[i]);
-               }
+               service_monitor_start_extra_avail(services[i]);
+               service_monitor_listen_start(services[i]);
        }
 
        if (service_process_create(service_list->log) != NULL)
@@ -406,7 +404,7 @@ void services_monitor_reap_children(void)
        struct service *service;
        pid_t pid;
        int status;
-       bool service_destroyed;
+       bool service_stopped;
 
        while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
                process = hash_table_lookup(service_pids, &pid);
@@ -424,12 +422,12 @@ void services_monitor_reap_children(void)
                } else {
                        service_process_failure(process, status);
                }
-               service_destroyed = service->list->destroyed;
+               service_stopped = service->status_fd[0] == -1;
                if (service->type == SERVICE_TYPE_ANVIL)
                        service_anvil_process_destroyed(process);
                service_process_destroy(process);
 
-               if (!service_destroyed) {
+               if (!service_stopped) {
                        service_monitor_start_extra_avail(service);
                        if (service->to_throttle == NULL)
                                service_monitor_listen_start(service);
index 7a4d84e2a7087cc9f99a0364e43a1c0d628b4005..b786bbee43906c0e917775f36e43983a32ad82ad 100644 (file)
@@ -123,7 +123,7 @@ service_dup_fds(struct service *service)
        closelog();
 
        if (dup2_array(&dups) < 0)
-               service_error(service, "dup2s failed");
+               i_fatal("service(%s): dup2s failed", service->set->name);
 
        env_put(t_strdup_printf("SOCKET_COUNT=%d", socket_listener_count));
        env_put(t_strdup_printf("SSL_SOCKET_COUNT=%d", ssl_socket_count));
@@ -233,6 +233,8 @@ struct service_process *service_process_create(struct service *service)
        pid_t pid;
        bool process_forked;
 
+       i_assert(service->status_fd[0] != -1);
+
        if (service->to_throttle != NULL) {
                /* throttling service, don't create new processes */
                return NULL;