[xiph-cvs] cvs commit: icecast/src fserve.c
Michael Smith
msmith at xiph.org
Sun Aug 18 02:38:45 PDT 2002
msmith 02/08/18 05:38:45
Modified: src fserve.c
Log:
Use select() if poll() isn't available in fserve.
Revision Changes Path
1.3 +33 -2 icecast/src/fserve.c
Index: fserve.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/fserve.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fserve.c 18 Aug 2002 08:49:25 -0000 1.2
+++ fserve.c 18 Aug 2002 09:38:45 -0000 1.3
@@ -2,7 +2,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+
+#ifdef HAVE_POLL
#include <sys/poll.h>
+#endif
#ifndef _WIN32
#include <unistd.h>
@@ -45,8 +48,13 @@
static int fserve_clients;
static int client_tree_changed=0;
+#ifdef HAVE_POLL
static struct pollfd *ufds = NULL;
static int ufdssize = 0;
+#else
+static fd_set fds;
+static int fd_max = 0;
+#endif
/* avl tree helper */
static int _compare_clients(void *compare_arg, void *a, void *b);
@@ -89,6 +97,7 @@
int i;
while(run_fserv) {
+#ifdef HAVE_POLL
if(client_tree_changed) {
client_tree_changed = 0;
i = 0;
@@ -105,9 +114,32 @@
avl_tree_unlock(client_tree);
}
- if(poll(ufds, ufdssize, 200) > 0) {
+ if(poll(ufds, ufdssize, 200) > 0)
return;
+#else
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 200000;
+ if(client_tree_changed) {
+ client_tree_changed = 0;
+ i=0;
+ FD_ZERO(&fds);
+ fd_max = 0;
+ avl_tree_rlock(client_tree);
+ client_node = avl_get_first(client_tree);
+ while(client_node) {
+ client = client_node->key;
+ FD_SET(client->client->con->sock, &fds);
+ if(client->client->con->sock > fd_max)
+ fd_max = client->client->con->sock;
+ client_node = avl_get_next(client_node);
+ }
+ avl_tree_unlock(client_tree);
}
+
+ if(select(fd_max+1, NULL, &fds, NULL, &tv) > 0)
+ return;
+#endif
else {
avl_tree_rlock(pending_tree);
client_node = avl_get_first(pending_tree);
@@ -117,7 +149,6 @@
}
}
}
-
void *fserv_thread_function(void *arg)
{
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list