DOS event handling fixes
Jukka Heinonen
jhei at iki.fi
Fri Mar 29 13:54:44 CST 2002
When DOS program waits for keyboard input using
interrupt 16, it is quite likely that routine DOSVM_Wait
either fails to wake up when new input is available
(since it uses MsgWaitForMultipleObjects that never signals
if DOSVM_Loop processes console input) or it processes a pending
event that adds new input but it does not return
(since processing pending events did not make the routine return).
This patch fixes both of these problems.
Changelog:
Routine DOSVM_Wait now wakes up if new events are queued
and it returns if it processed any queued events.
Index: dosvm.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/dosvm.c,v
retrieving revision 1.14
diff -u -r1.14 dosvm.c
--- dosvm.c 19 Mar 2002 02:05:57 -0000 1.14
+++ dosvm.c 29 Mar 2002 19:36:04 -0000
@@ -85,6 +85,7 @@
static CRITICAL_SECTION qcrit = CRITICAL_SECTION_INIT("DOSVM");
static struct _DOSEVENT *pending_event, *current_event;
static int sig_sent;
+static HANDLE event_notifier;
static CONTEXT86 *current_context;
static int DOSVM_SimulateInt( int vect, CONTEXT86 *context, BOOL inwine )
@@ -210,6 +211,10 @@
} else {
TRACE("new event queued (time=%ld)\n", GetTickCount());
}
+
+ /* Wake up DOSVM_Wait so that it can serve pending events. */
+ SetEvent(event_notifier);
+
LeaveCriticalSection(&qcrit);
} else {
/* DOS subsystem not running */
@@ -304,8 +309,9 @@
BOOL got_msg = FALSE;
objs[0]=GetStdHandle(STD_INPUT_HANDLE);
- objs[1]=hObject;
- objc=hObject?2:1;
+ objs[1]=event_notifier;
+ objs[2]=hObject;
+ objc=hObject?3:2;
do {
/* check for messages (waste time before the response check below) */
if (PeekMessageA)
@@ -335,6 +341,7 @@
IF_SET(&context);
SET_PEND(&context);
DOSVM_SendQueuedEvents(&context);
+ got_msg = TRUE;
}
if (got_msg) break;
} else {
@@ -356,7 +363,7 @@
ERR_(module)("dosvm wait error=%ld\n",GetLastError());
}
if ((read_pipe != -1) && hObject) {
- if (waitret==(WAIT_OBJECT_0+1)) break;
+ if (waitret==(WAIT_OBJECT_0+2)) break;
}
if (waitret==WAIT_OBJECT_0)
goto chk_console_input;
@@ -677,6 +684,10 @@
TRACE("Initializing DOS memory structures\n");
DOSMEM_Init( TRUE );
DOSDEV_InstallDOSDevices();
+ event_notifier = CreateEventA(NULL, FALSE, FALSE, NULL);
+ if(!event_notifier)
+ ERR("Failed to create event object!\n");
+
}
return TRUE;
}
--
Jukka Heinonen <http://www.iki.fi/jhei/>
More information about the wine-patches
mailing list