As Jukka reported,previous console management patch introduced a regression in console input synchronization. This patch should fix it.
ChangeLog:
- in console input record queue, replace semaphore with a manual reset event, so that we get correct behavior in synchronization handling
A+ -- Eric Pouech
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/kernel32/console.c dlls/kernel/console.c --- dlls/kernel32/console.c 2003-06-21 17:56:08.000000000 +0200 +++ dlls/kernel/console.c 2003-06-22 14:30:36.000000000 +0200 @@ -191,7 +191,7 @@ DWORD count, LPDWORD written ) { BOOL ret; - DWORD w; + TRACE("(%p,%p,%ld,%p)\n", handle, buffer, count, written); if (written) *written = 0; @@ -199,14 +199,11 @@ { req->handle = console_handle_unmap(handle); wine_server_add_data( req, buffer, count * sizeof(INPUT_RECORD) ); - if ((ret = !wine_server_call_err( req ))) w = reply->written; + if ((ret = !wine_server_call_err( req )) && written) + *written = reply->written; } SERVER_END_REQ; - if (ret) - { - ReleaseSemaphore( GetConsoleInputWaitHandle(), w, NULL ); - if (written) *written = w; - } + return ret; } diff -u -N -r -x '*~' -x '.#*' -x CVS programs/wineconsole32/wineconsole.c programs/wineconsole/wineconsole.c --- programs/wineconsole32/wineconsole.c 2003-06-21 17:53:28.000000000 +0200 +++ programs/wineconsole/wineconsole.c 2003-06-22 14:37:37.000000000 +0200 @@ -535,7 +535,6 @@ DWORD ret; struct config_data cfg; STARTUPINFOW si; - HANDLE sem; data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)); if (!data) return 0; @@ -564,7 +563,6 @@ /* should always be defined */ } - sem = CreateSemaphore(NULL, 0, 65536, NULL); /* the handles here are created without the whistles and bells required by console * (mainly because wineconsole doesn't need it) * - they are not inheritable @@ -574,8 +572,7 @@ { req->access = GENERIC_READ | GENERIC_WRITE; req->inherit = FALSE; - req->pid = pid; - req->wait_event = sem; + req->pid = pid; ret = !wine_server_call_err( req ); data->hConIn = (HANDLE)reply->handle_in; diff -u -N -r -x '*~' -x '.#*' -x CVS server32/console.c server/console.c --- server32/console.c 2003-06-21 18:00:21.000000000 +0200 +++ server/console.c 2003-06-22 14:28:46.000000000 +0200 @@ -203,7 +203,7 @@ return evt; } -static struct object *create_console_input( struct thread* renderer, struct object* wait_obj ) +static struct object *create_console_input( struct thread* renderer ) { struct console_input *console_input; @@ -222,7 +222,7 @@ console_input->history_index = 0; console_input->history_mode = 0; console_input->edition_mode = 0; - console_input->wait_obj = wait_obj; + console_input->event = create_event( NULL, 0, 1, 0 ); if (!console_input->history || !console_input->evt) { @@ -514,9 +514,8 @@ else i++; } } + if (!console->recnum && count) set_event( console->event ); console->recnum += count; - /* wake up all waiters */ - wake_up( &console->obj, 0 ); return count; } @@ -555,6 +554,7 @@ { free( console->records ); console->records = NULL; + reset_event( console->event ); } } release_object( console ); @@ -943,7 +943,7 @@ release_object( console_in->evt ); console_in->evt = NULL; - release_object( console_in->wait_obj ); + release_object( console_in->event ); for (i = 0; i < console_in->history_size; i++) if (console_in->history[i]) free( console_in->history[i] ); @@ -1209,7 +1209,6 @@ struct process *process; struct process *renderer = current->process; struct console_input *console; - struct object *wait_event; process = (req->pid) ? get_process_from_id( req->pid ) : (struct process *)grab_object( renderer->parent ); @@ -1222,13 +1221,7 @@ set_error( STATUS_ACCESS_DENIED ); goto the_end; } - wait_event = get_handle_obj( renderer, req->wait_event, 0, NULL); - if (!wait_event) - { - set_error( STATUS_INVALID_PARAMETER ); - goto the_end; - } - if ((console = (struct console_input*)create_console_input( current, wait_event ))) + if ((console = (struct console_input*)create_console_input( current ))) { if ((in = alloc_handle( renderer, console, req->access, req->inherit ))) { @@ -1531,8 +1524,8 @@ if (console) { - reply->handle = alloc_handle( current->process, console->wait_obj, - SEMAPHORE_ALL_ACCESS, FALSE); + reply->handle = alloc_handle( current->process, console->event, + EVENT_ALL_ACCESS, FALSE); release_object( console ); } else set_error( STATUS_INVALID_PARAMETER ); diff -u -N -r -x '*~' -x '.#*' -x CVS server32/console.h server/console.h --- server32/console.h 2003-06-21 17:53:30.000000000 +0200 +++ server/console.h 2003-06-22 14:24:31.000000000 +0200 @@ -42,7 +42,7 @@ int history_index; /* number of used entries in history array */ int history_mode; /* mode of history (non zero means remove doubled strings */ int edition_mode; /* index to edition mode flavors */ - struct object *wait_obj; /* object to wait on for input queue */ + struct event *event; /* event to wait on for input queue */ }; /* console functions */ diff -u -N -r -x '*~' -x '.#*' -x CVS server32/protocol.def server/protocol.def --- server32/protocol.def 2003-06-21 17:53:31.000000000 +0200 +++ server/protocol.def 2003-06-22 14:28:54.000000000 +0200 @@ -778,7 +778,6 @@ unsigned int access; /* wanted access rights */ int inherit; /* inherit flag */ process_id_t pid; /* pid of process which shall be attached to the console */ - obj_handle_t wait_event; /* semaphore for number of active input events */ @REPLY obj_handle_t handle_in; /* handle to console input */ obj_handle_t event; /* handle to renderer events change notification */