- for_each_file(td, f, i) {
- f->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ fprintf(f_out, "fio: waiting for connection\n");
+
+ /*
+ * Accept loop. poll for incoming events, accept them. Repeat until we
+ * have all connections.
+ */
+ while (!td->terminate) {
+ pfd.fd = nd->listenfd;
+ pfd.events = POLLIN;
+
+ ret = poll(&pfd, 1, -1);
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+
+ td_verror(td, errno, "poll");
+ break;
+ } else if (!ret)
+ continue;
+
+ /*
+ * should be impossible
+ */
+ if (!(pfd.revents & POLLIN))
+ continue;
+
+ f->fd = accept(nd->listenfd, (struct sockaddr *) &nd->addr, &socklen);