aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-28 20:20:10 +0200
committerEric Wong <normalperson@yhbt.net>2008-09-01 18:35:19 -0700
commit827d346899cf0d0d95f8320660944c8f38488b57 (patch)
tree1d4176ca09d1d319a3a2e11e8679ad7840882d2b
parent1cb70dcaf7d733c4bbf55d6071d7eabd28651814 (diff)
downloadmpd-827d346899cf0d0d95f8320660944c8f38488b57.tar.gz
mpd-827d346899cf0d0d95f8320660944c8f38488b57.tar.xz
mpd-827d346899cf0d0d95f8320660944c8f38488b57.zip
client: no while loop in client_manager_io()
The last patch removed the "continue" directive, and now the while loop is without function. Remove it. Also make client_manager_io() return 0.
-rw-r--r--src/client.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/src/client.c b/src/client.c
index 6ee9b988d..f03dd407b 100644
--- a/src/client.c
+++ b/src/client.c
@@ -476,47 +476,41 @@ int client_manager_io(void)
fd_set efds;
struct client *client, *n;
int selret;
- int fdmax;
+ int fdmax = 0;
- while (1) {
- fdmax = 0;
+ FD_ZERO( &efds );
+ client_manager_register_read_fd(&rfds, &fdmax);
+ client_manager_register_write_fd(&wfds, &fdmax);
- FD_ZERO( &efds );
- client_manager_register_read_fd(&rfds, &fdmax);
- client_manager_register_write_fd(&wfds, &fdmax);
+ registered_IO_add_fds(&fdmax, &rfds, &wfds, &efds);
- registered_IO_add_fds(&fdmax, &rfds, &wfds, &efds);
+ selret = select(fdmax + 1, &rfds, &wfds, &efds, NULL);
+ if (selret < 0) {
+ if (errno == EINTR)
+ return 0;
- selret = select(fdmax + 1, &rfds, &wfds, &efds, NULL);
- if (selret < 0) {
- if (errno == EINTR)
- break;
-
- FATAL("select() failed: %s\n", strerror(errno));
- }
+ FATAL("select() failed: %s\n", strerror(errno));
+ }
- registered_IO_consume_fds(&selret, &rfds, &wfds, &efds);
+ registered_IO_consume_fds(&selret, &rfds, &wfds, &efds);
- getConnections(&rfds);
+ getConnections(&rfds);
- list_for_each_entry_safe(client, n, &clients, siblings) {
- if (FD_ISSET(client->fd, &rfds)) {
- if (COMMAND_RETURN_KILL ==
- client_read(client)) {
- return COMMAND_RETURN_KILL;
- }
- client->lastTime = time(NULL);
- }
- if (FD_ISSET(client->fd, &wfds)) {
- client_write_deferred(client);
- client->lastTime = time(NULL);
+ list_for_each_entry_safe(client, n, &clients, siblings) {
+ if (FD_ISSET(client->fd, &rfds)) {
+ if (COMMAND_RETURN_KILL ==
+ client_read(client)) {
+ return COMMAND_RETURN_KILL;
}
+ client->lastTime = time(NULL);
+ }
+ if (FD_ISSET(client->fd, &wfds)) {
+ client_write_deferred(client);
+ client->lastTime = time(NULL);
}
-
- break;
}
- return 1;
+ return 0;
}
void client_manager_init(void)