+ unsigned n;
+
+ FOR_EACH_LISTEN_FD(n, ss) {
+ if (ss->listen_fds[n] >= 0)
+ continue;
+ ret = para_listen(protocol, ss->listen_addresses[n],
+ ss->default_port);
+ if (ret < 0) {
+ char *url = format_url(ss->listen_addresses[n],
+ ss->default_port);
+ PARA_ERROR_LOG("could not listen on %s %s: %s\n",
+ protocol == IPPROTO_TCP? "TCP" : "DCCP",
+ url, para_strerror(-ret));
+ free(url);
+ continue;
+ }
+ ss->listen_fds[n] = ret;
+ ret = mark_fd_nonblocking(ss->listen_fds[n]);
+ if (ret < 0) {
+ char *url = format_url(ss->listen_addresses[n],
+ ss->default_port);
+ PARA_ERROR_LOG("could not set %s socket fd for %s to "
+ "nonblocking mode: %s\n",
+ protocol == IPPROTO_TCP? "TCP" : "DCCP", url,
+ para_strerror(-ret));
+ free(url);
+ close(ss->listen_fds[n]);
+ ss->listen_fds[n] = -1;
+ continue;
+ }
+ add_close_on_fork_list(ss->listen_fds[n]);
+ }