Commit 31741747 authored by Alexandre Julliard's avatar Alexandre Julliard

Put CLONE_FILES back in, it is still breaking too many things.

parent a08e2cf1
...@@ -49,13 +49,8 @@ CRITICAL_SECTION X11DRV_CritSection = { 0, }; ...@@ -49,13 +49,8 @@ CRITICAL_SECTION X11DRV_CritSection = { 0, };
# define CLONE_SIGHAND 0x00000800 # define CLONE_SIGHAND 0x00000800
# define CLONE_PID 0x00001000 # define CLONE_PID 0x00001000
# endif /* CLONE_VM */ # endif /* CLONE_VM */
# define PER_THREAD_FILE_HANDLES
#endif /* linux */ #endif /* linux */
#ifdef HAVE_RFORK
# define PER_THREAD_FILE_HANDLES
#endif
static int init_done; static int init_done;
#ifndef NO_REENTRANT_LIBC #ifndef NO_REENTRANT_LIBC
...@@ -130,12 +125,7 @@ void SYSDEPS_SetCurThread( TEB *teb ) ...@@ -130,12 +125,7 @@ void SYSDEPS_SetCurThread( TEB *teb )
*/ */
static void SYSDEPS_StartThread( TEB *teb ) static void SYSDEPS_StartThread( TEB *teb )
{ {
int parent_socket = -1;
#ifdef PER_THREAD_FILE_HANDLES
parent_socket = NtCurrentTeb()->socket;
#endif
SYSDEPS_SetCurThread( teb ); SYSDEPS_SetCurThread( teb );
if (parent_socket != -1) close( parent_socket );
CLIENT_InitThread(); CLIENT_InitThread();
SIGNAL_Init(); SIGNAL_Init();
__TRY __TRY
...@@ -162,20 +152,21 @@ int SYSDEPS_SpawnThread( TEB *teb ) ...@@ -162,20 +152,21 @@ int SYSDEPS_SpawnThread( TEB *teb )
#ifndef NO_REENTRANT_LIBC #ifndef NO_REENTRANT_LIBC
#ifdef linux #ifdef linux
if (clone( (int (*)(void *))SYSDEPS_StartThread, teb->stack_top, const int flags = CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD;
CLONE_VM | CLONE_FS | SIGCHLD, teb ) < 0) if (clone( (int (*)(void *))SYSDEPS_StartThread, teb->stack_top, flags, teb ) < 0)
return -1; return -1;
close( teb->socket ); /* close the child socket in the parent */ if (!(flags & CLONE_FILES)) close( teb->socket ); /* close the child socket in the parent */
return 0; return 0;
#endif #endif
#ifdef HAVE_RFORK #ifdef HAVE_RFORK
const int flags = RFPROC | RFMEM; /*|RFFDG*/
void **sp = (void **)teb->stack_top; void **sp = (void **)teb->stack_top;
*--sp = teb; *--sp = teb;
*--sp = 0; *--sp = 0;
*--sp = SYSDEPS_StartThread; *--sp = SYSDEPS_StartThread;
__asm__ __volatile__( __asm__ __volatile__(
"pushl %2;\n\t" /* RFPROC|RFMEM|RFFDG */ "pushl %2;\n\t" /* flags */
"pushl $0;\n\t" /* 0 ? */ "pushl $0;\n\t" /* 0 ? */
"movl %1,%%eax;\n\t" /* SYS_rfork */ "movl %1,%%eax;\n\t" /* SYS_rfork */
".byte 0x9a; .long 0; .word 7;\n\t" /* lcall 7:0... FreeBSD syscall */ ".byte 0x9a; .long 0; .word 7;\n\t" /* lcall 7:0... FreeBSD syscall */
...@@ -185,9 +176,9 @@ int SYSDEPS_SpawnThread( TEB *teb ) ...@@ -185,9 +176,9 @@ int SYSDEPS_SpawnThread( TEB *teb )
"ret;\n" "ret;\n"
"1:\n\t" /* parent -> caller thread */ "1:\n\t" /* parent -> caller thread */
"addl $8,%%esp" : "addl $8,%%esp" :
: "r" (sp), "g" (SYS_rfork), "g" (RFPROC|RFMEM|RFFDG) : "r" (sp), "g" (SYS_rfork), "g" (flags)
: "eax", "edx"); : "eax", "edx");
close( teb->socket ); /* close the child socket in the parent */ if (flags & RFFDG) close( teb->socket ); /* close the child socket in the parent */
return 0; return 0;
#endif #endif
...@@ -215,10 +206,9 @@ int SYSDEPS_SpawnThread( TEB *teb ) ...@@ -215,10 +206,9 @@ int SYSDEPS_SpawnThread( TEB *teb )
*/ */
void SYSDEPS_ExitThread( int status ) void SYSDEPS_ExitThread( int status )
{ {
#ifndef PER_THREAD_FILE_HANDLES int socket = NtCurrentTeb()->socket;
/* otherwise it will be closed automagically by _exit */ NtCurrentTeb()->socket = -1;
close( NtCurrentTeb()->socket ); close( socket );
#endif
#ifdef HAVE__LWP_CREATE #ifdef HAVE__LWP_CREATE
_lwp_exit(); _lwp_exit();
#endif #endif
......
...@@ -143,6 +143,7 @@ void CALLBACK THREAD_FreeTEB( ULONG_PTR arg ) ...@@ -143,6 +143,7 @@ void CALLBACK THREAD_FreeTEB( ULONG_PTR arg )
/* Free the associated memory */ /* Free the associated memory */
if (teb->socket != -1) close( teb->socket );
if (teb->stack_sel) SELECTOR_FreeBlock( teb->stack_sel, 1 ); if (teb->stack_sel) SELECTOR_FreeBlock( teb->stack_sel, 1 );
SELECTOR_FreeBlock( teb->teb_sel, 1 ); SELECTOR_FreeBlock( teb->teb_sel, 1 );
if (teb->buffer) munmap( teb->buffer, teb->buffer_size ); if (teb->buffer) munmap( teb->buffer, teb->buffer_size );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment