Rebase against 69eafe63ad7e3525f3498ab6af9f4c149753407f.

[server-Parent_Process]
Removed patch to avoid holding reference on parent process in
wineserver (accepted upstream).
This commit is contained in:
Sebastian Lackner 2016-04-25 17:23:42 +02:00
parent 1051d1524c
commit f837e9bbfd
5 changed files with 18 additions and 223 deletions

View File

@ -1,4 +1,4 @@
From 96e37506c2666ce99559281dd977122994f20b6d Mon Sep 17 00:00:00 2001
From be137f0fb6f21d40f3caaa4cce69c0e22d90d8da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 4 Mar 2016 22:22:42 +0100
Subject: ddraw: Set ddsOldCaps correctly in ddraw7_GetCaps.
@ -12,7 +12,7 @@ Subject: ddraw: Set ddsOldCaps correctly in ddraw7_GetCaps.
5 files changed, 106 insertions(+)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index f9231d8..eeb941c 100644
index e9ca114..59f19ff 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -1532,6 +1532,8 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
@ -25,10 +25,10 @@ index f9231d8..eeb941c 100644
if(DriverCaps)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 7c2ec85..05427b2 100644
index 88d4f0c..07a8c10 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -8840,6 +8840,31 @@ static void test_getdc(void)
@@ -8977,6 +8977,31 @@ static void test_getdc(void)
DestroyWindow(window);
}
@ -60,17 +60,17 @@ index 7c2ec85..05427b2 100644
START_TEST(ddraw1)
{
IDirectDraw *ddraw;
@@ -8918,4 +8943,5 @@ START_TEST(ddraw1)
@@ -9055,4 +9080,5 @@ START_TEST(ddraw1)
test_overlay_rect();
test_blt();
test_getdc();
+ test_caps();
}
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index fd5dc9c..b1793ce 100644
index fdba786..44d23ad 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -9947,6 +9947,31 @@ static void test_getdc(void)
@@ -10153,6 +10153,31 @@ static void test_draw_primitive(void)
DestroyWindow(window);
}
@ -102,17 +102,17 @@ index fd5dc9c..b1793ce 100644
START_TEST(ddraw2)
{
IDirectDraw2 *ddraw;
@@ -10032,4 +10057,5 @@ START_TEST(ddraw2)
test_overlay_rect();
@@ -10239,4 +10264,5 @@ START_TEST(ddraw2)
test_blt();
test_getdc();
test_draw_primitive();
+ test_caps();
}
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 44f211e..1d06a62 100644
index cbcae06..67515a1 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -11225,6 +11225,31 @@ static void test_getdc(void)
@@ -11477,6 +11477,31 @@ static void test_draw_primitive(void)
DestroyWindow(window);
}
@ -144,17 +144,17 @@ index 44f211e..1d06a62 100644
START_TEST(ddraw4)
{
IDirectDraw4 *ddraw;
@@ -11318,4 +11343,5 @@ START_TEST(ddraw4)
test_blt();
@@ -11571,4 +11596,5 @@ START_TEST(ddraw4)
test_color_clamping();
test_getdc();
test_draw_primitive();
+ test_caps();
}
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 628d6d3..d0b0852 100644
index 5bfbe4d..23681f6 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -11511,6 +11511,31 @@ static void test_getdc(void)
@@ -11762,6 +11762,31 @@ static void test_draw_primitive(void)
DestroyWindow(window);
}
@ -186,10 +186,10 @@ index 628d6d3..d0b0852 100644
START_TEST(ddraw7)
{
HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -11615,4 +11640,5 @@ START_TEST(ddraw7)
test_blt();
@@ -11867,4 +11892,5 @@ START_TEST(ddraw7)
test_color_clamping();
test_getdc();
test_draw_primitive();
+ test_caps();
}
--

View File

@ -51,7 +51,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "ef36a25aec33670cd2099e4bce379bd6e2ac42a0"
echo "69eafe63ad7e3525f3498ab6af9f4c149753407f"
}
# Show version information
@ -277,7 +277,6 @@ patch_enable_all ()
enable_server_Key_State="$1"
enable_server_Map_EXDEV_Error="$1"
enable_server_Misc_ACL="$1"
enable_server_Parent_Process="$1"
enable_server_PeekMessage="$1"
enable_server_Pipe_ObjectName="$1"
enable_server_Realtime_Priority="$1"
@ -1004,9 +1003,6 @@ patch_enable ()
server-Misc_ACL)
enable_server_Misc_ACL="$2"
;;
server-Parent_Process)
enable_server_Parent_Process="$2"
;;
server-PeekMessage)
enable_server_PeekMessage="$2"
;;
@ -5893,23 +5889,6 @@ if test "$enable_server_Map_EXDEV_Error" -eq 1; then
) >> "$patchlist"
fi
# Patchset server-Parent_Process
# |
# | This patchset fixes the following Wine bugs:
# | * [#37087] Do not hold reference on parent process in wineserver
# |
# | Modified files:
# | * dlls/kernel32/tests/process.c, server/console.c, server/process.c, server/process.h, server/snapshot.c, server/thread.c
# |
if test "$enable_server_Parent_Process" -eq 1; then
patch_apply server-Parent_Process/0001-server-Increase-size-of-PID-table-to-512-to-reduce-r.patch
patch_apply server-Parent_Process/0002-server-Do-not-hold-reference-on-parent-process.patch
(
echo '+ { "Sebastian Lackner", "server: Increase size of PID table to 512 to reduce risk of collisions.", 1 },';
echo '+ { "Sebastian Lackner", "server: Do not hold reference on parent process.", 1 },';
) >> "$patchlist"
fi
# Patchset server-PeekMessage
# |
# | This patchset fixes the following Wine bugs:

View File

@ -1,56 +0,0 @@
From d1cbc9aa239ab353301fe709b36bd260eb42aa83 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Thu, 10 Dec 2015 05:57:34 +0100
Subject: server: Increase size of PID table to 512 to reduce risk of
collisions.
In addition, add code to avoid reusing the last 256 used PIDs.
---
server/process.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/server/process.c b/server/process.c
index e00b429..1b41037 100644
--- a/server/process.c
+++ b/server/process.c
@@ -336,6 +336,7 @@ static unsigned int used_ptid_entries; /* number of entries in use */
static unsigned int alloc_ptid_entries; /* number of allocated entries */
static unsigned int next_free_ptid; /* next free entry */
static unsigned int last_free_ptid; /* last free entry */
+static unsigned int num_free_ptids; /* number of free ptids */
static void kill_all_processes(void);
@@ -352,16 +353,17 @@ unsigned int alloc_ptid( void *ptr )
id = used_ptid_entries + PTID_OFFSET;
entry = &ptid_entries[used_ptid_entries++];
}
- else if (next_free_ptid)
+ else if (next_free_ptid && num_free_ptids >= 256)
{
id = next_free_ptid;
entry = &ptid_entries[id - PTID_OFFSET];
if (!(next_free_ptid = entry->next)) last_free_ptid = 0;
+ num_free_ptids--;
}
else /* need to grow the array */
{
unsigned int count = alloc_ptid_entries + (alloc_ptid_entries / 2);
- if (!count) count = 64;
+ if (!count) count = 512;
if (!(entry = realloc( ptid_entries, count * sizeof(*entry) )))
{
set_error( STATUS_NO_MEMORY );
@@ -388,8 +390,8 @@ void free_ptid( unsigned int id )
/* append to end of free list so that we don't reuse it too early */
if (last_free_ptid) ptid_entries[last_free_ptid - PTID_OFFSET].next = id;
else next_free_ptid = id;
-
last_free_ptid = id;
+ num_free_ptids++;
}
/* retrieve the pointer corresponding to a process or thread id */
--
2.6.2

View File

@ -1,127 +0,0 @@
From dbb9762fb427305959d824655c6e7691888aad67 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Thu, 10 Dec 2015 05:55:41 +0100
Subject: server: Do not hold reference on parent process.
---
dlls/kernel32/tests/process.c | 2 +-
server/console.c | 3 +--
server/process.c | 7 +++----
server/process.h | 2 +-
server/snapshot.c | 2 +-
server/thread.c | 2 +-
6 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index b88db45..b845b2e 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -1158,7 +1158,7 @@ static void test_Toolhelp(void)
Sleep(100);
}
/* The following test fails randomly on some Windows versions, but Gothic 2 depends on it */
- todo_wine ok(i < 20 || broken(i == 20), "process object not released\n");
+ ok(i < 20 || broken(i == 20), "process object not released\n");
snapshot = pCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
ok(snapshot != INVALID_HANDLE_VALUE, "CreateToolhelp32Snapshot failed %u\n", GetLastError());
diff --git a/server/console.c b/server/console.c
index a57b2fe..3d0e0e0 100644
--- a/server/console.c
+++ b/server/console.c
@@ -1425,13 +1425,12 @@ DECL_HANDLER(alloc_console)
case 0:
/* renderer is current, console to be attached to parent process */
renderer = current;
- if (!(process = current->process->parent))
+ if (!(process = get_process_from_id( current->process->parent_id )))
{
if (fd != -1) close( fd );
set_error( STATUS_ACCESS_DENIED );
return;
}
- grab_object( process );
attach = 1;
break;
case 0xffffffff:
diff --git a/server/process.c b/server/process.c
index cef491a..12de41d 100644
--- a/server/process.c
+++ b/server/process.c
@@ -504,7 +504,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit
close( fd );
goto error;
}
- process->parent = NULL;
+ process->parent_id = 0;
process->debugger = NULL;
process->handles = NULL;
process->msg_fd = NULL;
@@ -556,7 +556,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit
else
{
struct process *parent = parent_thread->process;
- process->parent = (struct process *)grab_object( parent );
+ process->parent_id = parent->id;
process->handles = inherit_all ? copy_handle_table( process, parent )
: alloc_handle_table( process, 0 );
/* Note: for security reasons, starting a new process does not attempt
@@ -623,7 +623,6 @@ static void process_destroy( struct object *obj )
release_object( process->job );
}
if (process->console) release_object( process->console );
- if (process->parent) release_object( process->parent );
if (process->msg_fd) release_object( process->msg_fd );
list_remove( &process->entry );
if (process->idle_event) release_object( process->idle_event );
@@ -1352,7 +1351,7 @@ DECL_HANDLER(get_process_info)
if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_LIMITED_INFORMATION )))
{
reply->pid = get_process_id( process );
- reply->ppid = process->parent ? get_process_id( process->parent ) : 0;
+ reply->ppid = process->parent_id;
reply->exit_code = process->exit_code;
reply->priority = process->priority;
reply->affinity = process->affinity;
diff --git a/server/process.h b/server/process.h
index fa7f60d..34b6ea6 100644
--- a/server/process.h
+++ b/server/process.h
@@ -56,7 +56,7 @@ struct process
{
struct object obj; /* object header */
struct list entry; /* entry in system-wide process list */
- struct process *parent; /* parent process */
+ process_id_t parent_id; /* parent process id (at the time of creation) */
struct list thread_list; /* thread list */
struct thread *debugger; /* thread debugging this process */
struct handle_table *handles; /* handle entries */
diff --git a/server/snapshot.c b/server/snapshot.c
index dd00bd1..bec281d 100644
--- a/server/snapshot.c
+++ b/server/snapshot.c
@@ -113,7 +113,7 @@ static int snapshot_next_process( struct snapshot *snapshot, struct next_process
ptr = &snapshot->processes[snapshot->process_pos++];
reply->count = ptr->count;
reply->pid = get_process_id( ptr->process );
- reply->ppid = ptr->process->parent ? get_process_id( ptr->process->parent ) : 0;
+ reply->ppid = ptr->process->parent_id;
reply->threads = ptr->threads;
reply->priority = ptr->priority;
reply->handles = ptr->handles;
diff --git a/server/thread.c b/server/thread.c
index bad2231..176cf44 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1300,7 +1300,7 @@ DECL_HANDLER(init_thread)
process->peb = req->entry;
process->cpu = req->cpu;
reply->info_size = init_process( current );
- if (!process->parent)
+ if (!process->parent_id)
process->affinity = current->affinity = get_thread_affinity( current );
else
set_thread_affinity( current, current->affinity );
--
2.6.4

View File

@ -1 +0,0 @@
Fixes: [37087] Do not hold reference on parent process in wineserver