This is a temporary patch that can be removed when we will make the
lexer, parser and code generator fully reentrant.
static bpf_u_int32 netmask;
static int snaplen;
int no_optimize;
static bpf_u_int32 netmask;
static int snaplen;
int no_optimize;
+#ifdef WIN32
+static int
+pcap_compile_unsafe(pcap_t *p, struct bpf_program *program,
+ const char *buf, int optimize, bpf_u_int32 mask);
+
+int
+pcap_compile(pcap_t *p, struct bpf_program *program,
+ const char *buf, int optimize, bpf_u_int32 mask)
+{
+ int result;
+
+ EnterCriticalSection(&g_PcapCompileCriticalSection);
+ OutputDebugString("Hello my dear, I locked myself\n");
+ result = pcap_compile_unsafe(p, program, buf, optimize, mask);
+
+ LeaveCriticalSection(&g_PcapCompileCriticalSection);
+
+ return result;
+}
+
+static int
+pcap_compile_unsafe(pcap_t *p, struct bpf_program *program,
+ const char *buf, int optimize, bpf_u_int32 mask)
+#else /* WIN32 */
int
pcap_compile(pcap_t *p, struct bpf_program *program,
const char *buf, int optimize, bpf_u_int32 mask)
int
pcap_compile(pcap_t *p, struct bpf_program *program,
const char *buf, int optimize, bpf_u_int32 mask)
{
extern int n_errors;
const char * volatile xbuf = buf;
{
extern int n_errors;
const char * volatile xbuf = buf;
#ifdef WIN32
#include <Packet32.h>
#ifdef WIN32
#include <Packet32.h>
+extern CRITICAL_SECTION g_PcapCompileCriticalSection;
#endif /* WIN32 */
#ifdef MSDOS
#endif /* WIN32 */
#ifdef MSDOS
plus alignment padding) */
};
plus alignment padding) */
};
+CRITICAL_SECTION g_PcapCompileCriticalSection;
+
+BOOL WINAPI DllMain(
+ HANDLE hinstDLL,
+ DWORD dwReason,
+ LPVOID lpvReserved
+)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ OutputDebugString("Hello my dear, I INITIALIZED THE CS\n");
+ InitializeCriticalSection(&g_PcapCompileCriticalSection);
+ }
+
+ return TRUE;
+}
+
/* Start winsock */
int
wsockinit()
/* Start winsock */
int
wsockinit()