Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
eb2e77fd
Commit
eb2e77fd
authored
Jun 04, 1999
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made handle table a separate object.
Global handle table is no longer bound to a process. Removed special handling of the initial process.
parent
1bdd154b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
77 additions
and
74 deletions
+77
-74
handle.c
server/handle.c
+0
-0
handle.h
server/handle.h
+3
-2
process.c
server/process.c
+60
-54
process.h
server/process.h
+1
-5
thread.c
server/thread.c
+13
-13
No files found.
server/handle.c
View file @
eb2e77fd
This diff is collapsed.
Click to expand it.
server/handle.h
View file @
eb2e77fd
...
...
@@ -27,7 +27,8 @@ extern int duplicate_handle( struct process *src, int src_handle, struct process
unsigned
int
access
,
int
inherit
,
int
options
);
extern
int
open_object
(
const
char
*
name
,
const
struct
object_ops
*
ops
,
unsigned
int
access
,
int
inherit
);
extern
int
copy_handle_table
(
struct
process
*
process
,
struct
process
*
parent
);
extern
void
free_handles
(
struct
process
*
process
);
extern
struct
object
*
alloc_handle_table
(
struct
process
*
process
,
int
count
);
extern
struct
object
*
copy_handle_table
(
struct
process
*
process
,
struct
process
*
parent
);
extern
void
close_global_handles
(
void
);
#endif
/* __WINE_SERVER_HANDLE_H */
server/process.c
View file @
eb2e77fd
...
...
@@ -24,8 +24,7 @@
/* process structure */
static
struct
process
initial_process
;
static
struct
process
*
first_process
=
&
initial_process
;
static
struct
process
*
first_process
;
static
int
running_processes
;
/* process operations */
...
...
@@ -49,16 +48,20 @@ static const struct object_ops process_ops =
};
/* initialization of a process structure */
static
void
init_process
(
struct
process
*
process
)
/* create a new process */
static
struct
process
*
create_process
(
struct
process
*
parent
,
struct
new_process_request
*
req
,
const
char
*
cmd_line
)
{
init_object
(
&
process
->
obj
,
&
process_ops
,
NULL
);
struct
process
*
process
;
if
(
!
(
process
=
alloc_object
(
sizeof
(
*
process
),
&
process_ops
,
NULL
)))
return
NULL
;
process
->
next
=
NULL
;
process
->
prev
=
NULL
;
process
->
thread_list
=
NULL
;
process
->
debug_next
=
NULL
;
process
->
debug_prev
=
NULL
;
process
->
debugger
=
NULL
;
process
->
handles
=
NULL
;
process
->
exit_code
=
0x103
;
/* STILL_ACTIVE */
process
->
running_threads
=
0
;
process
->
priority
=
NORMAL_PRIORITY_CLASS
;
...
...
@@ -68,47 +71,15 @@ static void init_process( struct process *process )
process
->
console_out
=
NULL
;
process
->
info
=
NULL
;
gettimeofday
(
&
process
->
start_time
,
NULL
);
/* alloc a handle for the process itself */
alloc_handle
(
process
,
process
,
PROCESS_ALL_ACCESS
,
0
);
}
/* create the initial process */
struct
process
*
create_initial_process
(
void
)
{
struct
new_process_request
*
info
;
copy_handle_table
(
&
initial_process
,
NULL
);
init_process
(
&
initial_process
);
if
(
!
alloc_console
(
&
initial_process
))
return
NULL
;
if
(
!
(
info
=
mem_alloc
(
sizeof
(
*
info
)
)))
return
NULL
;
info
->
start_flags
=
STARTF_USESTDHANDLES
;
info
->
hstdin
=
alloc_handle
(
&
initial_process
,
initial_process
.
console_in
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
1
);
info
->
hstdout
=
alloc_handle
(
&
initial_process
,
initial_process
.
console_out
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
1
);
info
->
hstderr
=
alloc_handle
(
&
initial_process
,
initial_process
.
console_out
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
1
);
info
->
env_ptr
=
NULL
;
initial_process
.
info
=
info
;
grab_object
(
&
initial_process
);
/* so that we never free it */
return
&
initial_process
;
}
/* create a new process */
static
struct
process
*
create_process
(
struct
new_process_request
*
req
,
const
char
*
cmd_line
)
{
struct
process
*
process
=
NULL
;
struct
process
*
parent
=
current
->
process
;
if
(
req
->
inherit_all
)
process
->
handles
=
copy_handle_table
(
process
,
parent
);
else
process
->
handles
=
alloc_handle_table
(
process
,
0
);
if
(
!
process
->
handles
)
goto
error
;
if
(
!
(
process
=
mem_alloc
(
sizeof
(
*
process
)
)))
return
NULL
;
if
(
!
copy_handle_table
(
process
,
req
->
inherit_all
?
parent
:
NULL
))
{
free
(
process
);
return
NULL
;
}
init_process
(
process
);
/* alloc a handle for the process itself */
alloc_handle
(
process
,
process
,
PROCESS_ALL_ACCESS
,
0
);
if
(
!
(
process
->
info
=
mem_alloc
(
sizeof
(
*
process
->
info
)
+
strlen
(
cmd_line
)
+
1
)))
goto
error
;
memcpy
(
process
->
info
,
req
,
sizeof
(
*
req
)
);
...
...
@@ -138,33 +109,60 @@ static struct process *create_process( struct new_process_request *req, const ch
/* attach to the debugger if requested */
if
(
req
->
create_flags
&
DEBUG_PROCESS
)
debugger_attach
(
process
,
current
);
else
if
(
parent
->
debugger
&&
!
(
req
->
create_flags
&
DEBUG_ONLY_THIS_PROCESS
))
else
if
(
parent
&&
parent
->
debugger
&&
!
(
req
->
create_flags
&
DEBUG_ONLY_THIS_PROCESS
))
debugger_attach
(
process
,
parent
->
debugger
);
process
->
next
=
first_process
;
first_process
->
prev
=
process
;
if
((
process
->
next
=
first_process
)
!=
NULL
)
process
->
next
->
prev
=
process
;
first_process
=
process
;
return
process
;
error:
free_console
(
process
);
if
(
process
->
info
)
free
(
process
->
info
);
if
(
process
->
handles
)
release_object
(
process
->
handles
);
release_object
(
process
);
return
NULL
;
}
/* create the initial process */
struct
process
*
create_initial_process
(
void
)
{
struct
process
*
process
;
struct
new_process_request
req
;
req
.
inherit
=
0
;
req
.
inherit_all
=
0
;
req
.
create_flags
=
CREATE_NEW_CONSOLE
;
req
.
start_flags
=
STARTF_USESTDHANDLES
;
req
.
hstdin
=
-
1
;
req
.
hstdout
=
-
1
;
req
.
hstderr
=
-
1
;
req
.
cmd_show
=
0
;
req
.
env_ptr
=
NULL
;
if
((
process
=
create_process
(
NULL
,
&
req
,
""
)))
{
process
->
info
->
hstdin
=
alloc_handle
(
process
,
process
->
console_in
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
1
);
process
->
info
->
hstdout
=
alloc_handle
(
process
,
process
->
console_out
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
1
);
process
->
info
->
hstderr
=
alloc_handle
(
process
,
process
->
console_out
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
1
);
release_object
(
process
);
}
return
process
;
}
/* destroy a process when its refcount is 0 */
static
void
process_destroy
(
struct
object
*
obj
)
{
struct
process
*
process
=
(
struct
process
*
)
obj
;
assert
(
obj
->
ops
==
&
process_ops
);
assert
(
process
!=
&
initial_process
);
/* we can't have a thread remaining */
assert
(
!
process
->
thread_list
);
if
(
process
->
next
)
process
->
next
->
prev
=
process
->
prev
;
if
(
process
->
prev
)
process
->
prev
->
next
=
process
->
next
;
else
first_process
=
process
->
next
;
free_console
(
process
);
free_handles
(
process
);
if
(
process
->
info
)
free
(
process
->
info
);
if
(
debug_level
)
memset
(
process
,
0xbb
,
sizeof
(
process
)
);
/* catch errors */
free
(
process
);
...
...
@@ -176,7 +174,9 @@ static void process_dump( struct object *obj, int verbose )
struct
process
*
process
=
(
struct
process
*
)
obj
;
assert
(
obj
->
ops
==
&
process_ops
);
printf
(
"Process next=%p prev=%p
\n
"
,
process
->
next
,
process
->
prev
);
fprintf
(
stderr
,
"Process next=%p prev=%p console=%p/%p handles=%p
\n
"
,
process
->
next
,
process
->
prev
,
process
->
console_in
,
process
->
console_out
,
process
->
handles
);
}
static
int
process_signaled
(
struct
object
*
obj
,
struct
thread
*
thread
)
...
...
@@ -209,8 +209,15 @@ static void process_killed( struct process *process, int exit_code )
assert
(
!
process
->
thread_list
);
process
->
exit_code
=
exit_code
;
gettimeofday
(
&
process
->
end_time
,
NULL
);
release_object
(
process
->
handles
);
process
->
handles
=
NULL
;
free_console
(
process
);
wake_up
(
&
process
->
obj
,
0
);
free_handles
(
process
);
if
(
!--
running_processes
)
{
/* last process died, close global handles */
close_global_handles
();
}
}
/* add a thread to a process running threads list */
...
...
@@ -237,7 +244,6 @@ void remove_process_thread( struct process *process, struct thread *thread )
if
(
!--
process
->
running_threads
)
{
/* we have removed the last running thread, exit the process */
running_processes
--
;
process_killed
(
process
,
thread
->
exit_code
);
}
release_object
(
thread
);
...
...
@@ -366,7 +372,7 @@ DECL_HANDLER(new_process)
char
*
cmd_line
=
(
char
*
)
data
;
CHECK_STRING
(
"new_process"
,
cmd_line
,
len
);
if
((
process
=
create_process
(
req
,
cmd_line
)))
if
((
process
=
create_process
(
current
->
process
,
req
,
cmd_line
)))
{
reply
.
pid
=
process
;
reply
.
handle
=
alloc_handle
(
current
->
process
,
process
,
...
...
server/process.h
View file @
eb2e77fd
...
...
@@ -15,8 +15,6 @@
/* process structures */
struct
handle_entry
;
struct
process
{
struct
object
obj
;
/* object header */
...
...
@@ -26,9 +24,7 @@ struct process
struct
process
*
debug_next
;
/* per-debugger process list */
struct
process
*
debug_prev
;
struct
thread
*
debugger
;
/* thread debugging this process */
struct
handle_entry
*
entries
;
/* handle entries */
int
handle_last
;
/* last valid handle */
int
handle_count
;
/* allocated table entries */
struct
object
*
handles
;
/* handle entries */
int
exit_code
;
/* process exit code */
int
running_threads
;
/* number of threads running in this process */
struct
timeval
start_time
;
/* absolute time at process start */
...
...
server/thread.c
View file @
eb2e77fd
...
...
@@ -74,8 +74,7 @@ static const struct object_ops thread_ops =
destroy_thread
};
static
struct
thread
initial_thread
;
static
struct
thread
*
first_thread
=
&
initial_thread
;
static
struct
thread
*
first_thread
;
/* initialization of a thread structure */
static
void
init_thread
(
struct
thread
*
thread
,
int
fd
)
...
...
@@ -104,12 +103,14 @@ static void init_thread( struct thread *thread, int fd )
/* create the initial thread and start the main server loop */
void
create_initial_thread
(
int
fd
)
{
current
=
&
initial_thread
;
init_thread
(
&
initial_thread
,
fd
);
initial_thread
.
process
=
create_initial_process
();
add_process_thread
(
initial_thread
.
process
,
&
initial_thread
);
initial_thread
.
client
=
add_client
(
fd
,
&
initial_thread
);
grab_object
(
&
initial_thread
);
/* so that we never free it */
first_thread
=
mem_alloc
(
sizeof
(
*
first_thread
)
);
assert
(
first_thread
);
current
=
first_thread
;
init_thread
(
first_thread
,
fd
);
first_thread
->
process
=
create_initial_process
();
add_process_thread
(
first_thread
->
process
,
first_thread
);
first_thread
->
client
=
add_client
(
fd
,
first_thread
);
select_loop
();
}
...
...
@@ -131,8 +132,7 @@ static struct thread *create_thread( int fd, void *pid, int suspend, int inherit
if
(
suspend
)
thread
->
suspend
++
;
thread
->
next
=
first_thread
;
first_thread
->
prev
=
thread
;
if
((
thread
->
next
=
first_thread
)
!=
NULL
)
thread
->
next
->
prev
=
thread
;
first_thread
=
thread
;
add_process_thread
(
process
,
thread
);
...
...
@@ -146,7 +146,7 @@ static struct thread *create_thread( int fd, void *pid, int suspend, int inherit
return
thread
;
error:
if
(
current
)
close_handle
(
current
->
process
,
*
handle
);
close_handle
(
current
->
process
,
*
handle
);
remove_process_thread
(
process
,
thread
);
release_object
(
thread
);
return
NULL
;
...
...
@@ -174,8 +174,8 @@ static void dump_thread( struct object *obj, int verbose )
struct
thread
*
thread
=
(
struct
thread
*
)
obj
;
assert
(
obj
->
ops
==
&
thread_ops
);
fprintf
(
stderr
,
"Thread pid=%d teb=%p
client=%p
\n
"
,
thread
->
unix_pid
,
thread
->
teb
,
thread
->
client
);
fprintf
(
stderr
,
"Thread pid=%d teb=%p
state=%d
\n
"
,
thread
->
unix_pid
,
thread
->
teb
,
thread
->
state
);
}
static
int
thread_signaled
(
struct
object
*
obj
,
struct
thread
*
thread
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment