Commit fc7818af authored by Niels Möller's avatar Niels Möller
Browse files

Made a new funtion, io_iter, for the contents of the io_run loop.

Rev: src/io.c:1.11
parent d072255f
...@@ -89,10 +89,8 @@ static int do_read(struct abstract_read **r, UINT32 length, UINT8 *buffer) ...@@ -89,10 +89,8 @@ static int do_read(struct abstract_read **r, UINT32 length, UINT8 *buffer)
/* UNLINK_FD must be followed by a continue, to avoid updating _fd */ /* UNLINK_FD must be followed by a continue, to avoid updating _fd */
#define UNLINK_FD (*_fd = (*_fd)->next) #define UNLINK_FD (*_fd = (*_fd)->next)
void io_run(struct io_backend *b) static int io_iter(struct io_backend *b)
{ {
while(1)
{
struct pollfd *fds; struct pollfd *fds;
int i; int i;
unsigned long nfds; /* FIXME: Should be nfds_t if that type is defined */ unsigned long nfds; /* FIXME: Should be nfds_t if that type is defined */
...@@ -118,7 +116,7 @@ void io_run(struct io_backend *b) ...@@ -118,7 +116,7 @@ void io_run(struct io_backend *b)
{ {
if (!nfds) if (!nfds)
/* All done */ /* All done */
break; return 0;
timeout = -1; timeout = -1;
} }
...@@ -129,7 +127,7 @@ void io_run(struct io_backend *b) ...@@ -129,7 +127,7 @@ void io_run(struct io_backend *b)
FOR_FDS(struct io_fd, fd, b->io, i++) FOR_FDS(struct io_fd, fd, b->io, i++)
{ {
fds[i].fd = fd->on_hold ? -1 : fd->fd; fds[i].fd = fd->fd;
fds[i].events = 0; fds[i].events = 0;
if (!fd->on_hold) if (!fd->on_hold)
fds[i].events |= POLLIN; fds[i].events |= POLLIN;
...@@ -172,7 +170,7 @@ void io_run(struct io_backend *b) ...@@ -172,7 +170,7 @@ void io_run(struct io_backend *b)
{ {
case EAGAIN: case EAGAIN:
case EINTR: case EINTR:
continue; return 1;
default: default:
fatal("io_run:poll failed: %s", strerror(errno)); fatal("io_run:poll failed: %s", strerror(errno));
} }
...@@ -295,13 +293,19 @@ void io_run(struct io_backend *b) ...@@ -295,13 +293,19 @@ void io_run(struct io_backend *b)
} }
END_FOR_FDS; END_FOR_FDS;
} }
} return 1;
}
void io_run(struct io_backend *b)
{
while(io_iter(b))
;
} }
/* /*
* Fill in ADDR from HOST, SERVICE and PROTOCOL. * Fill in ADDR from HOST, SERVICE and PROTOCOL.
* Supplying a null pointer for HOST means use INADDR_ANY. * Supplying a null pointer for HOST means use INADDR_ANY.
* Otherwise HOST is an numbers-and-dits ip-number or a dns name. * Otherwise HOST is an numbers-and-dots ip-number or a dns name.
* *
* PROTOCOL can be tcp or udp. * PROTOCOL can be tcp or udp.
* *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment