Patch: wait-debug.diff
Introduce a debug channel for WaitForMultipleObjectsEx() in scheduler/synchro.c - I found this very useful to debug my asynchronous socket code.
Moreover, include "async.h" _after_ declaring debug channels so that TRACEs can be used in the static functions in async.h.
Patch against: CVS 2002-04-12, with my async-immediate, async-file patches applied.
Modified files: dlls/kernel: comm.c dlls/ntdll: ntdll.spec files: file.c include: async.h scheduler: synchro.c
diff -ruNX ignore TMP/wine/dlls/kernel/comm.c MW/wine/dlls/kernel/comm.c --- TMP/wine/dlls/kernel/comm.c Fri Apr 12 12:31:58 2002 +++ MW/wine/dlls/kernel/comm.c Fri Apr 12 12:32:19 2002 @@ -80,7 +80,6 @@ #include "winerror.h"
#include "wine/server.h" -#include "async.h" #include "file.h" #include "heap.h"
@@ -91,6 +90,7 @@ #endif
WINE_DEFAULT_DEBUG_CHANNEL(comm); +#include "async.h"
/*********************************************************************** * Asynchronous I/O for asynchronous wait requests * diff -ruNX ignore TMP/wine/dlls/ntdll/ntdll.spec MW/wine/dlls/ntdll/ntdll.spec --- TMP/wine/dlls/ntdll/ntdll.spec Tue Apr 2 16:51:27 2002 +++ MW/wine/dlls/ntdll/ntdll.spec Fri Apr 12 12:33:12 2002 @@ -5,7 +5,7 @@ global heap int int21 int31 io loaddll local module ntdll process profile reg relay resource segment seh selector server snoop string system tape task thread tid timer toolhelp ver virtual - vxd win32) + vxd wait win32)
#note that the Zw... functions are alternate names for the #Nt... functions. (see www.sysinternals.com for details) diff -ruNX ignore TMP/wine/files/file.c MW/wine/files/file.c --- TMP/wine/files/file.c Fri Apr 12 12:31:58 2002 +++ MW/wine/files/file.c Fri Apr 12 12:32:19 2002 @@ -55,7 +55,6 @@
#include "drive.h" #include "file.h" -#include "async.h" #include "heap.h" #include "msdos.h" #include "wincon.h" @@ -64,6 +63,7 @@ #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(file); +#include "async.h"
#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON) #define MAP_ANON MAP_ANONYMOUS diff -ruNX ignore TMP/wine/include/async.h MW/wine/include/async.h --- TMP/wine/include/async.h Fri Apr 12 12:31:58 2002 +++ MW/wine/include/async.h Fri Apr 12 12:32:19 2002 @@ -102,6 +102,7 @@ ovp->ops->set_status ( ovp, ret ); }
+ TRACE ("ovp %p, status %lx %lx, ret %x\n", ovp, status, ovp->ops->get_status (ovp), ret); if ( ovp->ops->get_status (ovp) != STATUS_PENDING ) finish_async (ovp);
diff -ruNX ignore TMP/wine/scheduler/synchro.c MW/wine/scheduler/synchro.c --- TMP/wine/scheduler/synchro.c Mon Apr 8 10:56:59 2002 +++ MW/wine/scheduler/synchro.c Fri Apr 12 12:33:12 2002 @@ -23,6 +23,7 @@ #include <signal.h> #include <sys/time.h> #include <sys/poll.h> +#include <stdio.h> #include <unistd.h> #include <string.h>
@@ -30,6 +31,9 @@ #include "thread.h" #include "winerror.h" #include "wine/server.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wait); #include "async.h"
@@ -225,9 +229,22 @@ BOOL wait_all, DWORD timeout, BOOL alertable ) { - int ret, cookie; + int ret, cookie,i; struct timeval tv;
+ if ( TRACE_ON ( __default ) ) + { + const int len = 256; + char bf[len], *pp; + + for (i = 0, pp = bf; i < count && pp < bf+len; i++) + pp += snprintf (pp, bf + len - pp, " %d", handles[i]); + bf[len-1] = 0; + + TRACE ( "n=%ld wait=%c timeout=%ld alertable=%c handles%s\n", count, + ( wait_all ? 'y' : 'n' ), timeout, ( alertable ? 'y' : 'n' ), bf ); + } + if (count > MAXIMUM_WAIT_OBJECTS) { SetLastError( ERROR_INVALID_PARAMETER ); @@ -259,6 +276,7 @@ call_apcs( alertable ); if (alertable) break; } + TRACE ("status: %d\n", ret); if (HIWORD(ret)) /* is it an error code? */ { SetLastError( RtlNtStatusToDosError(ret) );