Skip to content

Commit

Permalink
master: Start service processes only after adding all service listeners
Browse files Browse the repository at this point in the history
Otherwise the processes could try to connect to services that aren't being
listened on, causing errors. Especially stats-writer socket needs to be
available early on.
  • Loading branch information
sirainen authored and cmouse committed Sep 8, 2018
1 parent d78aaeb commit d9365fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/master/service-monitor.c
Expand Up @@ -441,6 +441,7 @@ static int service_login_create_notify_fd(struct service *service)

void services_monitor_start(struct service_list *service_list)
{
ARRAY(struct service *) listener_services;
struct service *const *services;

if (services_log_init(service_list) < 0)
Expand All @@ -454,6 +455,7 @@ void services_monitor_start(struct service_list *service_list)
master_client_connected, service_list);
}

t_array_init(&listener_services, array_count(&service_list->services));
array_foreach(&service_list->services, services) {
struct service *service = *services;

Expand Down Expand Up @@ -486,10 +488,14 @@ void services_monitor_start(struct service_list *service_list)
io_add(service->status_fd[0], IO_READ,
service_status_input, service);
}
service_monitor_start_extra_avail(service);
service_monitor_listen_start(service);
array_append(&listener_services, &service, 1);
}

/* create processes only after adding all listeners */
array_foreach(&listener_services, services)
service_monitor_start_extra_avail(*services);

if (service_list->log->status_fd[0] != -1) {
if (service_process_create(service_list->log) != NULL)
service_monitor_listen_stop(service_list->log);
Expand Down

0 comments on commit d9365fa

Please sign in to comment.