[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:17:57 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 5eca45b5e7edf038046133ca6135f9513343c9a3
Author: aCaB <acab at clamav.net>
Date: Fri Jan 29 18:57:50 2010 +0100
clamd-win32 - WIP#3
diff --git a/clamd/others.c b/clamd/others.c
index b3271b1..c24653a 100644
--- a/clamd/others.c
+++ b/clamd/others.c
@@ -207,7 +207,7 @@ int poll_fd(int fd, int timeout_sec, int check_signals)
if (fds_add(&fds, fd, 1, timeout_sec) == -1)
return -1;
do {
- ret = fds_poll_recv(&fds, timeout_sec, check_signals);
+ ret = fds_poll_recv(&fds, timeout_sec, check_signals, NULL);
} while (ret == -1 && errno == EINTR);
fds_free(&fds);
return ret;
@@ -431,7 +431,7 @@ void fds_remove(struct fd_data *data, int fd)
* Must be called with buf_mutex lock held.
*/
/* TODO: handle ReadTimeout */
-int fds_poll_recv(struct fd_data *data, int timeout, int check_signals)
+int fds_poll_recv(struct fd_data *data, int timeout, int check_signals, void *dummy)
{
unsigned fdsok = data->nfds;
size_t i;
@@ -496,7 +496,11 @@ int fds_poll_recv(struct fd_data *data, int timeout, int check_signals)
int n = data->nfds;
fds_unlock(data);
+#ifdef _WIN32
+ retval = poll_with_event(data->poll_data, n, timeout, dummy);
+#else
retval = poll(data->poll_data, n, timeout);
+#endif
fds_lock(data);
if (retval > 0) {
diff --git a/clamd/others.h b/clamd/others.h
index ddd9b25..828f7df 100644
--- a/clamd/others.h
+++ b/clamd/others.h
@@ -79,7 +79,7 @@ int writen(int fd, void *buff, unsigned int count);
int fds_add(struct fd_data *data, int fd, int listen_only, int timeout);
void fds_remove(struct fd_data *data, int fd);
void fds_cleanup(struct fd_data *data);
-int fds_poll_recv(struct fd_data *data, int timeout, int check_signals);
+int fds_poll_recv(struct fd_data *data, int timeout, int check_signals, void *dummy);
void fds_free(struct fd_data *data);
#endif
diff --git a/clamd/server-th.c b/clamd/server-th.c
index 6e92e4f..7b24808 100644
--- a/clamd/server-th.c
+++ b/clamd/server-th.c
@@ -69,6 +69,9 @@ pthread_mutex_t reload_mutex = PTHREAD_MUTEX_INITIALIZER;
int sighup = 0;
static struct cl_stat dbstat;
+static void *event_wake_recv = NULL;
+static void *event_wake_accept = NULL;
+
static void scanner_thread(void *arg)
{
client_conn_t *conn = (client_conn_t *) arg;
@@ -326,7 +329,7 @@ static void *acceptloop_th(void *arg)
pthread_mutex_lock(fds->buf_mutex);
for (;;) {
/* Block waiting for data to become available for reading */
- int new_sd = fds_poll_recv(fds, -1, 0);
+ int new_sd = fds_poll_recv(fds, -1, 0, event_wake_accept);
/* TODO: what about sockets that get rm-ed? */
if (!fds->nfds) {
@@ -418,7 +421,7 @@ static void *acceptloop_th(void *arg)
/* notify recvloop */
#ifdef _WIN32
- SetEvent(data->event_wake_recv);
+ SetEvent(event_wake_recv);
#else
if (write(data->syncpipe_wake_recv[1], "", 1) == -1) {
logg("!write syncpipe failed\n");
@@ -462,7 +465,7 @@ static void *acceptloop_th(void *arg)
progexit = 1;
pthread_mutex_unlock(&exit_mutex);
#ifdef _WIN32
- SetEvent(data->event_wake_recv);
+ SetEvent(event_wake_recv);
#else
if (write(data->syncpipe_wake_recv[1], "", 1) < 0) {
logg("$Syncpipe write failed\n");
@@ -1065,8 +1068,8 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
return 1;
}
#ifdef _WIN32
- acceptdata.event_wake_accept = CreateEvent(NULL, TRUE, FALSE, NULL);
- acceptdata.event_wake_recv = CreateEvent(NULL, TRUE, FALSE, NULL);
+ event_wake_accept = CreateEvent(NULL, TRUE, FALSE, NULL);
+ event_wake_recv = CreateEvent(NULL, TRUE, FALSE, NULL);
#else
if (pipe(acceptdata.syncpipe_wake_recv) == -1 ||
(pipe(acceptdata.syncpipe_wake_accept) == -1)) {
@@ -1102,9 +1105,12 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
/* signal that we can accept more connections */
if (fds->nfds <= (unsigned)max_queue)
pthread_cond_signal(&acceptdata.cond_nfds);
- new_sd = fds_poll_recv(fds, selfchk ? (int)selfchk : -1, 1);
+ new_sd = fds_poll_recv(fds, selfchk ? (int)selfchk : -1, 1, event_wake_recv);
+
+#ifndef _WIN32
if (!fds->nfds) {
+ continue;
/* at least the dummy/sync pipe should have remained */
logg("!All recv() descriptors gone: fatal\n");
pthread_mutex_lock(&exit_mutex);
@@ -1113,6 +1119,7 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
pthread_mutex_unlock(fds->buf_mutex);
break;
}
+#endif
if (new_sd == -1 && errno != EINTR) {
logg("!Failed to poll sockets, fatal\n");
@@ -1122,7 +1129,7 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
}
- i = (rr_last + 1) % fds->nfds;
+ if(fds->nfds) i = (rr_last + 1) % fds->nfds;
for (j = 0; j < fds->nfds && new_sd >= 0; j++, i = (i+1) % fds->nfds) {
size_t pos = 0;
int error = 0;
@@ -1311,7 +1318,7 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
progexit = 1;
pthread_mutex_unlock(&exit_mutex);
#ifdef _WIN32
- SetEvent(acceptdata.event_wake_accept);
+ SetEvent(event_wake_accept);
#else
if (write(acceptdata.syncpipe_wake_accept[1], "", 1) < 0) {
logg("^Write to syncpipe failed\n");
@@ -1337,8 +1344,8 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
pthread_join(accept_th, NULL);
fds_free(fds);
#ifdef _WIN32
- CloseHandle(acceptdata.event_wake_accept);
- CloseHandle(acceptdata.event_wake_recv);
+ CloseHandle(event_wake_accept);
+ CloseHandle(event_wake_recv);
#else
close(acceptdata.syncpipe_wake_accept[1]);
close(acceptdata.syncpipe_wake_recv[1]);
diff --git a/win32/clamav-config.h b/win32/clamav-config.h
index cbbeccd..e60a5ae 100644
--- a/win32/clamav-config.h
+++ b/win32/clamav-config.h
@@ -493,7 +493,7 @@
/* #undef USE_SYSLOG */
/* Version number of package */
-#define VERSION "devel-r5076-706-g0380088"
+#define VERSION "devel-r5076-715-gd29df4c"
/* Version suffix for package */
#define VERSION_SUFFIX ""
diff --git a/win32/clamd.vcproj b/win32/clamd.vcproj
index c246e84..c332f45 100644
--- a/win32/clamd.vcproj
+++ b/win32/clamd.vcproj
@@ -1,251 +1,251 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9,00"
- Name="clamd"
- ProjectGUID="{B3CA73CF-E71E-42F3-95DE-43797A86C798}"
- RootNamespace="clamd"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories=""$(SolutionDir)";"$(SolutionDir)..\libclamav";"$(SolutionDir)compat";"$(SolutionDir)3rdparty\zlib";"$(SolutionDir)3rdparty\pthreads";"$(SolutionDir)3rdparty\bzip2";"$(SolutionDir)..""
- PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;_BIND_TO_CURRENT_VCLIBS_VERSION=1"
- MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- CompileAs="1"
- DisableSpecificWarnings="4996;4244;4090;4018"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"
- IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
- ConfigurationType="1"
- CharacterSet="2"
- WholeProgramOptimization="1"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="2"
- EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories=""$(SolutionDir)";"$(SolutionDir)..\libclamav";"$(SolutionDir)compat";"$(SolutionDir)3rdparty\zlib";"$(SolutionDir)3rdparty\pthreads";"$(SolutionDir)3rdparty\bzip2";"$(SolutionDir)..""
- PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;_BIND_TO_CURRENT_VCLIBS_VERSION=1"
- RuntimeLibrary="2"
- EnableFunctionLevelLinking="true"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- DebugInformationFormat="3"
- CompileAs="1"
- DisableSpecificWarnings="4996;4244;4090;4018"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- LinkIncremental="1"
- GenerateDebugInformation="true"
- SubSystem="1"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath="..\clamd\clamd.c"
- >
- </File>
- <File
- RelativePath="..\clamd\localserver.c"
- >
- </File>
- <File
- RelativePath="..\clamd\others.c"
- >
- </File>
- <File
- RelativePath="..\clamd\scanner.c"
- >
- </File>
- <File
- RelativePath="..\clamd\server-th.c"
- >
- </File>
- <File
- RelativePath="..\clamd\session.c"
- >
- </File>
- <File
- RelativePath="..\clamd\tcpserver.c"
- >
- </File>
- <File
- RelativePath="..\clamd\thrmgr.c"
- >
- </File>
- <Filter
- Name="shared"
- >
- <File
- RelativePath="..\shared\misc.c"
- >
- </File>
- <File
- RelativePath="..\shared\output.c"
- >
- </File>
- </Filter>
- <Filter
- Name="compat"
- >
- <File
- RelativePath=".\compat\libgen.c"
- >
- </File>
- <File
- RelativePath=".\compat\setargv.c"
- >
- </File>
- </Filter>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ Keyword="Win32Proj"
+ Name="clamd"
+ ProjectGUID="{B3CA73CF-E71E-42F3-95DE-43797A86C798}"
+ ProjectType="Visual C++"
+ RootNamespace="clamd"
+ TargetFrameworkVersion="196613"
+ Version="9,00"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ CharacterSet="2"
+ ConfigurationType="1"
+ IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ AdditionalIncludeDirectories=""$(SolutionDir)";"$(SolutionDir)..\libclamav";"$(SolutionDir)compat";"$(SolutionDir)3rdparty\zlib";"$(SolutionDir)3rdparty\pthreads";"$(SolutionDir)3rdparty\bzip2";"$(SolutionDir)..""
+ BasicRuntimeChecks="3"
+ CompileAs="1"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4996;4244;4090;4018"
+ MinimalRebuild="true"
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;_BIND_TO_CURRENT_VCLIBS_VERSION=1"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ GenerateDebugInformation="true"
+ LinkIncremental="1"
+ Name="VCLinkerTool"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ CharacterSet="2"
+ ConfigurationType="1"
+ IntermediateDirectory="$(SolutionDir)build\$(ProjectName)\$(ConfigurationName)"
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ AdditionalIncludeDirectories=""$(SolutionDir)";"$(SolutionDir)..\libclamav";"$(SolutionDir)compat";"$(SolutionDir)3rdparty\zlib";"$(SolutionDir)3rdparty\pthreads";"$(SolutionDir)3rdparty\bzip2";"$(SolutionDir)..""
+ CompileAs="1"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4996;4244;4090;4018"
+ EnableFunctionLevelLinking="true"
+ EnableIntrinsicFunctions="true"
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ PreprocessorDefinitions="WIN32_LEAN_AND_MEAN;HAVE_CONFIG_H;_BIND_TO_CURRENT_VCLIBS_VERSION=1"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ EnableCOMDATFolding="2"
+ GenerateDebugInformation="true"
+ LinkIncremental="1"
+ Name="VCLinkerTool"
+ OptimizeReferences="2"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ Name="Source Files"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\clamd\clamd.c"
+ >
+ </File>
+ <File
+ RelativePath="..\clamd\localserver.c"
+ >
+ </File>
+ <File
+ RelativePath="..\clamd\others.c"
+ >
+ </File>
+ <File
+ RelativePath="..\clamd\scanner.c"
+ >
+ </File>
+ <File
+ RelativePath="..\clamd\server-th.c"
+ >
+ </File>
+ <File
+ RelativePath="..\clamd\session.c"
+ >
+ </File>
+ <File
+ RelativePath="..\clamd\tcpserver.c"
+ >
+ </File>
+ <File
+ RelativePath="..\clamd\thrmgr.c"
+ >
+ </File>
+ <Filter
+ Name="shared"
+ >
+ <File
+ RelativePath="..\shared\misc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\shared\output.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="compat"
+ >
+ <File
+ RelativePath=".\compat\libgen.c"
+ >
+ </File>
+ <File
+ RelativePath=".\compat\setargv.c"
+ >
+ </File>
+ </Filter>
+ </Filter>
+ <Filter
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ Name="Header Files"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ Name="Resource Files"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/win32/compat/net.c b/win32/compat/net.c
index 3113752..0b7325e 100644
--- a/win32/compat/net.c
+++ b/win32/compat/net.c
@@ -327,11 +327,12 @@ int w32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, s
}
int w32_accept(int sockfd, const struct sockaddr *addr, socklen_t *addrlen) {
- if(accept((SOCKET)sockfd, addr, addrlen)) {
+ int sock;
+ if((sock = (int)accept((SOCKET)sockfd, addr, addrlen)<0)) {
wsock2errno();
return -1;
}
- return 0;
+ return sock;
}
int w32_listen(int sockfd, int backlog) {
@@ -358,7 +359,7 @@ struct w32polldata {
struct pollfd *polldata;
};
-VOID CALLBACK poll_cb(PVOID param, BOOLEAN timedout) {
+static VOID CALLBACK poll_cb(PVOID param, BOOLEAN timedout) {
WSANETWORKEVENTS evt;
struct w32polldata *item = (struct w32polldata *)param;
if(!timedout) {
@@ -368,6 +369,23 @@ VOID CALLBACK poll_cb(PVOID param, BOOLEAN timedout) {
if(evt.iErrorCode[i] & (FD_ACCEPT|FD_READ)) item->polldata->revents |= POLLIN;
if(evt.iErrorCode[i] & FD_CLOSE) item->polldata->revents |= POLLHUP;
}
+<<<<<<< HEAD:win32/compat/net.c
+ if(SetEvent(item->setme)==0) {
+ int a = GetLastError();
+ a++;
+ }
+ }
+}
+
+int poll_with_event(struct pollfd *fds, int nfds, int timeout, HANDLE event) {
+ HANDLE *setme;
+ struct w32polldata *items;
+ unsigned int i, ret = 0;
+
+ setme = malloc(2 * sizeof(HANDLE));
+ setme[0] = CreateEvent(NULL, TRUE, FALSE, NULL);
+ setme[1] = event;
+=======
}
}
@@ -376,6 +394,7 @@ int w32_poll(struct pollfd *fds, int nfds, int timeout) {
struct w32polldata *items;
unsigned int i, ret = 0;
+>>>>>>> d29df4cf2d499717dde976c27fa293470cfcf114:win32/compat/net.c
timeout = timeout>=0 ? timeout*1000 : INFINITE;
if(!nfds) {
Sleep(timeout);
@@ -385,7 +404,11 @@ int w32_poll(struct pollfd *fds, int nfds, int timeout) {
for(i=0; i<nfds; i++) {
items[i].event = CreateEvent(NULL, TRUE, FALSE, NULL);
items[i].polldata = &fds[i];
+<<<<<<< HEAD:win32/compat/net.c
+ items[i].setme = setme[0];
+=======
items[i].setme = setme;
+>>>>>>> d29df4cf2d499717dde976c27fa293470cfcf114:win32/compat/net.c
if(WSAEventSelect(fds[i].fd, items[i].event, FD_ACCEPT|FD_READ|FD_CLOSE)) {
/* handle error here */
}
@@ -393,7 +416,11 @@ int w32_poll(struct pollfd *fds, int nfds, int timeout) {
/* handle errors here */
}
}
+<<<<<<< HEAD:win32/compat/net.c
+ WaitForMultipleObjects(2 - (event == NULL) , setme, FALSE, timeout);
+=======
WaitForSingleObject(setme, timeout); /* FIXME - add the pipe here */
+>>>>>>> d29df4cf2d499717dde976c27fa293470cfcf114:win32/compat/net.c
for(i=0; i<nfds; i++) {
UnregisterWait(items[i].waiter);
WSAEventSelect(fds[i].fd, items[i].event, 0);
@@ -401,5 +428,10 @@ int w32_poll(struct pollfd *fds, int nfds, int timeout) {
ret += (items[i].polldata->revents != 0);
}
free(items);
+<<<<<<< HEAD:win32/compat/net.c
+ CloseHandle(setme[0]);
+ free(setme);
+=======
+>>>>>>> d29df4cf2d499717dde976c27fa293470cfcf114:win32/compat/net.c
return ret;
}
diff --git a/win32/compat/net.h b/win32/compat/net.h
index 6b765e1..e69f0bf 100644
--- a/win32/compat/net.h
+++ b/win32/compat/net.h
@@ -39,7 +39,7 @@ void w32_freeaddrinfo(struct addrinfo *res);
const char *w32_inet_ntop(int af, const void *src, char *dst, socklen_t size);
struct hostent *w32_gethostbyname(const char *name);
int w32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
-int w32_poll(struct pollfd *fds, int nfds, int timeout);
+int poll_with_event(struct pollfd *fds, int nfds, int timeout, HANDLE event);
int w32_accept(int sockfd, const struct sockaddr *addr, socklen_t *addrlen);
int w32_listen(int sockfd, int backlog);
int w32_shutdown(int sockfd, int how);
diff --git a/win32/libclamav.def b/win32/libclamav.def
index a80f97f..5002ad4 100644
--- a/win32/libclamav.def
+++ b/win32/libclamav.def
@@ -142,7 +142,7 @@ EXPORTS w32_freeaddrinfo
EXPORTS w32_inet_ntop
EXPORTS w32_gethostbyname
EXPORTS w32_select
-EXPORTS w32_poll
+EXPORTS poll_with_event
EXPORTS w32_stat
EXPORTS w32_strerror
EXPORTS w32_strerror_r
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list