Console fix #2 (resent)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



his patch changes the way the console renderer is handled in the
server. it was a process, it's now a thread... this would allow
(not sure it's going to be done though) to have a single process
handle several consoles

A+
-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle
Name: cs_rndr
ChangeLog: let the console renderer be defined as a thread
GenDate: 2001/12/01 20:07:21 UTC
ModifiedFiles: server/console.c server/console.h server/debugger.c server/process.c server/process.h server/thread.c
AddedFiles: 
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/console.c,v
retrieving revision 1.30
diff -u -u -r1.30 console.c
--- server/console.c	2001/11/30 18:46:50	1.30
+++ server/console.c	2001/12/01 12:37:14
@@ -180,7 +180,7 @@
     return evt;
 }
 
-static struct object *create_console_input( struct process* renderer )
+static struct object *create_console_input( struct thread* renderer )
 {
     struct console_input *console_input;
 
@@ -310,9 +310,10 @@
  *	2/ parent is a renderer which launches process, and process should attach to the console
  *	   renderered by parent
  */
-void inherit_console(struct process *parent, struct process *process, handle_t hconin)
+void inherit_console(struct thread *parent_thread, struct process *process, handle_t hconin)
 {
     int done = 0;
+    struct process* parent = parent_thread->process;
 
     /* if parent is a renderer, then attach current process to its console
      * a bit hacky....
@@ -323,7 +324,7 @@
 
         if ((console = (struct console_input*)get_handle_obj( parent, hconin, 0, NULL )))
 	{
-	    if (console->renderer == parent)
+	    if (console->renderer == parent_thread)
 	    {
 		process->console = (struct console_input*)grab_object( console );
 		process->console->num_proc++;
@@ -1097,7 +1098,7 @@
         goto the_end;
     }
 
-    if ((console = (struct console_input*)create_console_input( renderer )))
+    if ((console = (struct console_input*)create_console_input( current )))
     {
         if ((in = alloc_handle( renderer, console, req->access, req->inherit )))
         {
Index: server/console.h
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/console.h,v
retrieving revision 1.2
diff -u -u -r1.2 console.h
--- server/console.h	2001/11/30 18:46:50	1.2
+++ server/console.h	2001/11/30 20:49:58
@@ -16,7 +16,7 @@
 {
     struct object                obj;           /* object header */
     int                          num_proc;      /* number of processes attached to this console */
-    struct process              *renderer;      /* console renderer thread */
+    struct thread               *renderer;      /* console renderer thread */
     int                          mode;          /* input mode */
     struct screen_buffer        *active;        /* active screen buffer */
     int                          recnum;        /* number of input records */
@@ -31,7 +31,7 @@
 
 /* console functions */
 
-extern void inherit_console(struct process *parent, struct process *process, handle_t hconin);
+extern void inherit_console(struct thread *parent_thread, struct process *process, handle_t hconin);
 extern int free_console( struct process *process );
 
 #endif  /* __WINE_SERVER_CONSOLE_H */
Index: server/debugger.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/debugger.c,v
retrieving revision 1.33
diff -u -u -r1.33 debugger.c
--- server/debugger.c	2001/11/30 18:46:50	1.33
+++ server/debugger.c	2001/11/30 22:29:43
@@ -413,9 +413,8 @@
         if (thread->process == process) goto error;
 
     /* don't let a debugger debug its console... won't work */
-    if (debugger->process->console &&
-        debugger->process->console->renderer == process &&
-        process->console) goto error;
+    if (debugger->process->console && debugger->process->console->renderer->process == process)
+        goto error;
 
     suspend_process( process );
 
Index: server/process.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/process.c,v
retrieving revision 1.74
diff -u -u -r1.74 process.c
--- server/process.c	2001/11/30 18:46:50	1.74
+++ server/process.c	2001/11/30 21:05:55
@@ -97,7 +97,7 @@
 
 
 /* set the console and stdio handles for a newly created process */
-static int set_process_console( struct process *process, struct process *parent,
+static int set_process_console( struct process *process, struct thread *parent_thread,
                                 struct startup_info *info, struct init_process_reply *reply )
 {
     if (process->create_flags & CREATE_NEW_CONSOLE)
@@ -105,26 +105,26 @@
         /* let the process init do the allocation */
         return 1;
     }
-    else if (parent && !(process->create_flags & DETACHED_PROCESS))
+    else if (parent_thread && !(process->create_flags & DETACHED_PROCESS))
     {
         /* FIXME: some better error checking should be done...
          * like if hConOut and hConIn are console handles, then they should be on the same
          * physical console
          */
-        inherit_console( parent, process,
+        inherit_console( parent_thread, process,
                          (info->inherit_all || (info->start_flags & STARTF_USESTDHANDLES)) ?
                          info->hstdin : 0 );
     }
-    if (parent)
+    if (parent_thread)
     {
         if (!info->inherit_all && !(info->start_flags & STARTF_USESTDHANDLES))
         {
             /* duplicate the handle from the parent into this process */
-            reply->hstdin  = duplicate_handle( parent, info->hstdin, process,
+            reply->hstdin  = duplicate_handle( parent_thread->process, info->hstdin, process,
                                                0, TRUE, DUPLICATE_SAME_ACCESS );
-            reply->hstdout = duplicate_handle( parent, info->hstdout, process,
+            reply->hstdout = duplicate_handle( parent_thread->process, info->hstdout, process,
                                                0, TRUE, DUPLICATE_SAME_ACCESS );
-            reply->hstderr = duplicate_handle( parent, info->hstderr, process,
+            reply->hstderr = duplicate_handle( parent_thread->process, info->hstderr, process,
                                                0, TRUE, DUPLICATE_SAME_ACCESS );
         }
         else
@@ -260,7 +260,7 @@
     }
 
     /* set the process console */
-    if (!set_process_console( process, parent, info, reply )) return;
+    if (!set_process_console( process, parent_thread, info, reply )) return;
 
     if (parent)
     {
@@ -434,7 +434,7 @@
 }
 
 /* kill all processes being attached to a console renderer */
-static void kill_console_processes( struct process *renderer, int exit_code )
+void kill_console_processes( struct thread *renderer, int exit_code )
 {
     for (;;)  /* restart from the beginning of the list every time */
     {
@@ -442,7 +442,7 @@
 
         /* find the first process being attached to 'renderer' and still running */
         while (process &&
-               (process == renderer || !process->console ||
+               (process == renderer->process || !process->console ||
                 process->console->renderer != renderer || !process->running_threads))
         {
             process = process->next;
@@ -462,9 +462,6 @@
 
     /* close the console attached to this process, if any */
     free_console( process );
-
-    /* close the processes using process as renderer, if any */
-    kill_console_processes( process, 0 );
 
     while (process->exe.next)
     {
Index: server/process.h
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/process.h,v
retrieving revision 1.23
diff -u -u -r1.23 process.h
--- server/process.h	2001/11/23 23:05:07	1.23
+++ server/process.h	2001/11/30 20:21:22
@@ -78,6 +78,7 @@
 extern void suspend_process( struct process *process );
 extern void resume_process( struct process *process );
 extern void kill_process( struct process *process, struct thread *skip, int exit_code );
+extern void kill_console_processes( struct thread *renderer, int exit_code );
 extern void kill_debugged_processes( struct thread *debugger, int exit_code );
 extern struct process_snapshot *process_snap( int *count );
 extern struct module_snapshot *module_snap( struct process *process, int *count );
Index: server/thread.c
===================================================================
RCS file: /usr/share/cvs/cvsroot/wine/wine/server/thread.c,v
retrieving revision 1.70
diff -u -u -r1.70 thread.c
--- server/thread.c	2001/11/30 18:46:50	1.70
+++ server/thread.c	2001/11/30 20:50:02
@@ -698,6 +698,7 @@
         /* if it is waiting on the socket, we don't need to send a SIGTERM */
         violent_death = 0;
     }
+    kill_console_processes( thread, 0 );
     debug_exit_thread( thread );
     abandon_mutexes( thread );
     remove_process_thread( thread->process, thread );

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux