[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

aCaB acab at clamav.net
Sun Apr 4 01:18:11 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit 80f4bd69c2ce4cfb5aaabf9cf14a64d6280b50e0
Author: aCaB <acab at clamav.net>
Date:   Fri Jan 29 20:10:45 2010 +0100

    fix accept

diff --git a/clamd/server-th.c b/clamd/server-th.c
index 7b24808..3d24cba 100644
--- a/clamd/server-th.c
+++ b/clamd/server-th.c
@@ -301,20 +301,11 @@ struct acceptdata {
     pthread_cond_t cond_nfds;
     int max_queue;
     int commandtimeout;
-#ifdef _WIN32
-    HANDLE event_wake_recv;
-    HANDLE event_wake_accept;
-#else
     int syncpipe_wake_recv[2];
     int syncpipe_wake_accept[2];
-#endif
 };
 
-#ifdef _WIN32
-#define ACCEPTDATA_INIT(mutex1, mutex2) { FDS_INIT(mutex1), FDS_INIT(mutex2), PTHREAD_COND_INITIALIZER, 0, 0, NULL, NULL}
-#else
 #define ACCEPTDATA_INIT(mutex1, mutex2) { FDS_INIT(mutex1), FDS_INIT(mutex2), PTHREAD_COND_INITIALIZER, 0, 0, {-1, -1}, {-1, -1}}
-#endif
 
 static void *acceptloop_th(void *arg)
 {
@@ -330,7 +321,9 @@ static void *acceptloop_th(void *arg)
     for (;;) {
 	/* Block waiting for data to become available for reading */
 	int new_sd = fds_poll_recv(fds, -1, 0, event_wake_accept);
-
+#ifdef _WIN32
+	ResetEvent(event_wake_accept);
+#endif
 	/* TODO: what about sockets that get rm-ed? */
 	if (!fds->nfds) {
 	    /* no more sockets to poll, all gave an error */
@@ -351,7 +344,7 @@ static void *acceptloop_th(void *arg)
 	    struct fd_buf *buf = &fds->buf[i];
 	    if (!buf->got_newdata)
 		continue;
-#ifndef _WIN32 // FIXME
+#ifndef _WIN32
 	    if (buf->fd == data->syncpipe_wake_accept[0]) {
 		/* dummy sync pipe, just to wake us */
 		if (read(buf->fd, buff, sizeof(buff)) < 0) {
@@ -1107,8 +1100,9 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
 	    pthread_cond_signal(&acceptdata.cond_nfds);
 	new_sd = fds_poll_recv(fds, selfchk ? (int)selfchk : -1, 1, event_wake_recv);
 
-
-#ifndef _WIN32
+#ifdef _WIN32
+	ResetEvent(event_wake_recv);
+#else
 	if (!fds->nfds) {
 	    continue;
 	    /* at least the dummy/sync pipe should have remained */
@@ -1137,7 +1131,7 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
 	    if (!buf->got_newdata)
 		continue;
 
-#ifndef _WIN32 //FIXME
+#ifndef _WIN32
 	    if (buf->fd == acceptdata.syncpipe_wake_recv[0]) {
 		/* dummy sync pipe, just to wake us */
 		if (read(buf->fd, buff, sizeof(buff)) < 0) {
diff --git a/win32/compat/net.c b/win32/compat/net.c
index 305b780..f119bed 100644
--- a/win32/compat/net.c
+++ b/win32/compat/net.c
@@ -386,7 +386,10 @@ int poll_with_event(struct pollfd *fds, int nfds, int timeout, HANDLE event) {
     setme[1] = event;
     timeout = timeout>=0 ? timeout*1000 : INFINITE;
     if(!nfds) {
-	Sleep(timeout);
+	if(event)
+	    WaitForSingleObject(event, timeout);
+	else
+	    Sleep(timeout);
 	return 0;
     }
     items = malloc(nfds * sizeof(struct w32polldata));

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list