- if (ss->listen_fd < 0)
- return NULL;
- ret = para_accept(ss->listen_fd, rfds, NULL, 0, &fd);
- if (ret < 0)
- PARA_ERROR_LOG("%s\n", para_strerror(-ret));
- if (ret <= 0)
- return NULL;
- ret = -E_MAX_CLIENTS;
- if (ss->max_clients > 0 && ss->num_clients >= ss->max_clients)
- goto err_out;
- ret = mark_fd_nonblocking(fd);
- if (ret < 0)
- goto err_out;
- ret = acl_check_access(fd, &ss->acl, ss->default_deny);
- if (ret < 0)
- goto err_out;
- ss->num_clients++;
- sc = para_calloc(sizeof(*sc));
- sc->fd = fd;
- sc->name = para_strdup(remote_name(fd));
- sc->cq = cq_new(MAX_CQ_BYTES);
- para_list_add(&sc->node, &ss->client_list);
- add_close_on_fork_list(fd);
- PARA_INFO_LOG("accepted client #%d: %s (fd %d)\n", ss->num_clients,
- sc->name, fd);
- return sc;
-err_out:
- PARA_WARNING_LOG("%s\n", para_strerror(-ret));
- close(fd);
+ FOR_EACH_LISTEN_FD(n, ss) {
+ if (ss->listen_fds[n] < 0)
+ continue;
+ ret = para_accept(ss->listen_fds[n], rfds, NULL, 0, &fd);
+ if (ret < 0)
+ goto warn;
+ if (ret == 0)
+ continue;
+ ret = -E_MAX_CLIENTS;
+ if (ss->max_clients > 0 && ss->num_clients >= ss->max_clients)
+ goto close_fd_and_warn;
+ ret = mark_fd_nonblocking(fd);
+ if (ret < 0)
+ goto close_fd_and_warn;
+ ret = acl_check_access(fd, &ss->acl, ss->default_deny);
+ if (ret < 0)
+ goto close_fd_and_warn;
+ ss->num_clients++;
+ sc = para_calloc(sizeof(*sc));
+ sc->fd = fd;
+ sc->name = para_strdup(remote_name(fd));
+ sc->cq = cq_new(MAX_CQ_BYTES);
+ para_list_add(&sc->node, &ss->client_list);
+ add_close_on_fork_list(fd);
+ PARA_INFO_LOG("accepted client #%d: %s (fd %d)\n", ss->num_clients,
+ sc->name, fd);
+ return sc;
+close_fd_and_warn:
+ close(fd);
+warn:
+ PARA_WARNING_LOG("%s\n", para_strerror(-ret));
+ }