[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:44 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 64927c5dac3404c1386e3c8837e7fbe2eb714512
Author: aCaB <acab at clamav.net>
Date: Wed Feb 3 01:40:00 2010 +0100
win32 fixes
diff --git a/ChangeLog b/ChangeLog
index 58d37f8..f1ac27f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Feb 3 01:38:50 CET 2010 (acab)
+-----------------------------------
+ * win32: workaround HUP reset in poll, set stdin to binary mode
+
Tue Feb 2 14:23:18 CET 2010 (tk)
---------------------------------
* freshclam: new option Bytecode
diff --git a/win32/compat/net.c b/win32/compat/net.c
index 1799bd9..47194df 100644
--- a/win32/compat/net.c
+++ b/win32/compat/net.c
@@ -386,7 +386,7 @@ VOID CALLBACK poll_cb(PVOID param, BOOLEAN timedout) {
int poll_with_event(struct pollfd *fds, int nfds, int timeout, HANDLE event) {
HANDLE *setme, cankill;
struct w32polldata *items;
- unsigned int i, ret = 0;
+ unsigned int i, ret = 0, reallywait = 1;
if(timeout <0) timeout = INFINITE;
if(!nfds) {
@@ -402,28 +402,47 @@ int poll_with_event(struct pollfd *fds, int nfds, int timeout, HANDLE event) {
setme[1] = event;
items = malloc(nfds * sizeof(struct w32polldata));
for(i=0; i<nfds; i++) {
- items[i].event = CreateEvent(NULL, TRUE, FALSE, NULL);
items[i].polldata = &fds[i];
- items[i].setme = setme[0];
- if(WSAEventSelect(fds[i].fd, items[i].event, FD_ACCEPT|FD_READ|FD_CLOSE)) {
- /* handle error here */
- }
- if(RegisterWaitForSingleObject(&items[i].waiter, items[i].event, poll_cb, &items[i], timeout, WT_EXECUTEONLYONCE)) {
- /* handle errors here */
+ items[i].event = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if(items[i].event) {
+ items[i].setme = setme[0];
+ if(WSAEventSelect(fds[i].fd, items[i].event, FD_ACCEPT|FD_READ|FD_CLOSE)) {
+ CloseHandle(items[i].event);
+ items[i].event = NULL;
+ } else {
+ char c; /* Ugly workaround to FD_CLOSE not being persistent
+ better win32 code is possible at the cost of a larger diff vs. the unix
+ netcode - for now it stays ugly...
+ */
+ int n = recv(fds[i].fd, &c, 1, MSG_PEEK);
+ if(!n)
+ items[i].polldata->revents = POLLHUP;
+ if(n == 1)
+ items[i].polldata->revents = POLLIN;
+ if(n >= 0 || !RegisterWaitForSingleObject(&items[i].waiter, items[i].event, poll_cb, &items[i], timeout, 0*WT_EXECUTEONLYONCE)) {
+ WSAEventSelect(fds[i].fd, items[i].event, 0);
+ CloseHandle(items[i].event);
+ items[i].event = NULL;
+ reallywait = 0;
+ }
+ }
}
}
- if((ret = WaitForMultipleObjects(2 - (event == NULL), setme, FALSE, timeout)) == WAIT_OBJECT_0 + 1) {
- ret = 1;
- } else {
- ret = 0;
+ if(reallywait) {
+ if(WaitForMultipleObjects(2 - (event == NULL), setme, FALSE, timeout) == WAIT_OBJECT_0 + 1)
+ ret = 1;
+ else
+ ret = 0;
}
cankill = CreateEvent(NULL, TRUE, FALSE, NULL);
for(i=0; i<nfds; i++) {
- ResetEvent(cankill);
- UnregisterWaitEx(items[i].waiter, cankill);
- WSAEventSelect(fds[i].fd, items[i].event, 0);
- WaitForSingleObject(cankill, INFINITE);
- CloseHandle(items[i].event);
+ if(items[i].event) {
+ ResetEvent(cankill);
+ UnregisterWaitEx(items[i].waiter, cankill);
+ WSAEventSelect(fds[i].fd, items[i].event, 0);
+ WaitForSingleObject(cankill, INFINITE);
+ CloseHandle(items[i].event);
+ }
ret += (items[i].polldata->revents != 0);
}
CloseHandle(cankill);
diff --git a/win32/compat/setargv.c b/win32/compat/setargv.c
index 5585b5c..88c3fe4 100644
--- a/win32/compat/setargv.c
+++ b/win32/compat/setargv.c
@@ -25,6 +25,8 @@
#include "dirent.h"
#include "libgen.h"
+#include <fcntl.h>
+
/* THIS IS A HACK ! */
/* _setargv is the designed way to customize command line parsing which we use here
for globbing reasons (incidentally the globbing in setargv.obj is badly broken)
@@ -50,6 +52,7 @@ int _setargv() {
int *g_argc = __p___argc();
char ***g_argv = __p___argv();
+ _setmode(_fileno(stdin), _O_BINARY);
do {
c = *cur;
switch(c) {
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list