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
Hide 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
...
@@ -27,7 +27,8 @@ extern int duplicate_handle( struct process *src, int src_handle, struct process
unsigned
int
access
,
int
inherit
,
int
options
);
unsigned
int
access
,
int
inherit
,
int
options
);
extern
int
open_object
(
const
char
*
name
,
const
struct
object_ops
*
ops
,
extern
int
open_object
(
const
char
*
name
,
const
struct
object_ops
*
ops
,
unsigned
int
access
,
int
inherit
);
unsigned
int
access
,
int
inherit
);
extern
int
copy_handle_table
(
struct
process
*
process
,
struct
process
*
parent
);
extern
struct
object
*
alloc_handle_table
(
struct
process
*
process
,
int
count
);
extern
void
free_handles
(
struct
process
*
process
);
extern
struct
object
*
copy_handle_table
(
struct
process
*
process
,
struct
process
*
parent
);
extern
void
close_global_handles
(
void
);
#endif
/* __WINE_SERVER_HANDLE_H */
#endif
/* __WINE_SERVER_HANDLE_H */
server/process.c
View file @
eb2e77fd
...
@@ -24,8 +24,7 @@
...
@@ -24,8 +24,7 @@
/* process structure */
/* process structure */
static
struct
process
initial_process
;
static
struct
process
*
first_process
;
static
struct
process
*
first_process
=
&
initial_process
;
static
int
running_processes
;
static
int
running_processes
;
/* process operations */
/* process operations */
...
@@ -49,16 +48,20 @@ static const struct object_ops process_ops =
...
@@ -49,16 +48,20 @@ static const struct object_ops process_ops =
};
};
/* initialization of a process structure */
/* create a new process */
static
void
init_process
(
struct
process
*
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
->
next
=
NULL
;
process
->
prev
=
NULL
;
process
->
prev
=
NULL
;
process
->
thread_list
=
NULL
;
process
->
thread_list
=
NULL
;
process
->
debug_next
=
NULL
;
process
->
debug_next
=
NULL
;
process
->
debug_prev
=
NULL
;
process
->
debug_prev
=
NULL
;
process
->
debugger
=
NULL
;
process
->
debugger
=
NULL
;
process
->
handles
=
NULL
;
process
->
exit_code
=
0x103
;
/* STILL_ACTIVE */
process
->
exit_code
=
0x103
;
/* STILL_ACTIVE */
process
->
running_threads
=
0
;
process
->
running_threads
=
0
;
process
->
priority
=
NORMAL_PRIORITY_CLASS
;
process
->
priority
=
NORMAL_PRIORITY_CLASS
;
...
@@ -68,47 +71,15 @@ static void init_process( struct process *process )
...
@@ -68,47 +71,15 @@ static void init_process( struct process *process )
process
->
console_out
=
NULL
;
process
->
console_out
=
NULL
;
process
->
info
=
NULL
;
process
->
info
=
NULL
;
gettimeofday
(
&
process
->
start_time
,
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 */
if
(
req
->
inherit_all
)
struct
process
*
create_initial_process
(
void
)
process
->
handles
=
copy_handle_table
(
process
,
parent
);
{
else
struct
new_process_request
*
info
;
process
->
handles
=
alloc_handle_table
(
process
,
0
);
if
(
!
process
->
handles
)
goto
error
;
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
(
!
(
process
=
mem_alloc
(
sizeof
(
*
process
)
)))
return
NULL
;
/* alloc a handle for the process itself */
if
(
!
copy_handle_table
(
process
,
req
->
inherit_all
?
parent
:
NULL
))
alloc_handle
(
process
,
process
,
PROCESS_ALL_ACCESS
,
0
);
{
free
(
process
);
return
NULL
;
}
init_process
(
process
);
if
(
!
(
process
->
info
=
mem_alloc
(
sizeof
(
*
process
->
info
)
+
strlen
(
cmd_line
)
+
1
)))
goto
error
;
if
(
!
(
process
->
info
=
mem_alloc
(
sizeof
(
*
process
->
info
)
+
strlen
(
cmd_line
)
+
1
)))
goto
error
;
memcpy
(
process
->
info
,
req
,
sizeof
(
*
req
)
);
memcpy
(
process
->
info
,
req
,
sizeof
(
*
req
)
);
...
@@ -138,33 +109,60 @@ static struct process *create_process( struct new_process_request *req, const ch
...
@@ -138,33 +109,60 @@ static struct process *create_process( struct new_process_request *req, const ch
/* attach to the debugger if requested */
/* attach to the debugger if requested */
if
(
req
->
create_flags
&
DEBUG_PROCESS
)
if
(
req
->
create_flags
&
DEBUG_PROCESS
)
debugger_attach
(
process
,
current
);
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
);
debugger_attach
(
process
,
parent
->
debugger
);
process
->
next
=
first_process
;
if
((
process
->
next
=
first_process
)
!=
NULL
)
process
->
next
->
prev
=
process
;
first_process
->
prev
=
process
;
first_process
=
process
;
first_process
=
process
;
return
process
;
return
process
;
error:
error:
free_console
(
process
);
if
(
process
->
info
)
free
(
process
->
info
);
if
(
process
->
handles
)
release_object
(
process
->
handles
);
release_object
(
process
);
release_object
(
process
);
return
NULL
;
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 */
/* destroy a process when its refcount is 0 */
static
void
process_destroy
(
struct
object
*
obj
)
static
void
process_destroy
(
struct
object
*
obj
)
{
{
struct
process
*
process
=
(
struct
process
*
)
obj
;
struct
process
*
process
=
(
struct
process
*
)
obj
;
assert
(
obj
->
ops
==
&
process_ops
);
assert
(
obj
->
ops
==
&
process_ops
);
assert
(
process
!=
&
initial_process
);
/* we can't have a thread remaining */
/* we can't have a thread remaining */
assert
(
!
process
->
thread_list
);
assert
(
!
process
->
thread_list
);
if
(
process
->
next
)
process
->
next
->
prev
=
process
->
prev
;
if
(
process
->
next
)
process
->
next
->
prev
=
process
->
prev
;
if
(
process
->
prev
)
process
->
prev
->
next
=
process
->
next
;
if
(
process
->
prev
)
process
->
prev
->
next
=
process
->
next
;
else
first_process
=
process
->
next
;
else
first_process
=
process
->
next
;
free_console
(
process
);
free_handles
(
process
);
if
(
process
->
info
)
free
(
process
->
info
);
if
(
process
->
info
)
free
(
process
->
info
);
if
(
debug_level
)
memset
(
process
,
0xbb
,
sizeof
(
process
)
);
/* catch errors */
if
(
debug_level
)
memset
(
process
,
0xbb
,
sizeof
(
process
)
);
/* catch errors */
free
(
process
);
free
(
process
);
...
@@ -176,7 +174,9 @@ static void process_dump( struct object *obj, int verbose )
...
@@ -176,7 +174,9 @@ static void process_dump( struct object *obj, int verbose )
struct
process
*
process
=
(
struct
process
*
)
obj
;
struct
process
*
process
=
(
struct
process
*
)
obj
;
assert
(
obj
->
ops
==
&
process_ops
);
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
)
static
int
process_signaled
(
struct
object
*
obj
,
struct
thread
*
thread
)
...
@@ -209,8 +209,15 @@ static void process_killed( struct process *process, int exit_code )
...
@@ -209,8 +209,15 @@ static void process_killed( struct process *process, int exit_code )
assert
(
!
process
->
thread_list
);
assert
(
!
process
->
thread_list
);
process
->
exit_code
=
exit_code
;
process
->
exit_code
=
exit_code
;
gettimeofday
(
&
process
->
end_time
,
NULL
);
gettimeofday
(
&
process
->
end_time
,
NULL
);
release_object
(
process
->
handles
);
process
->
handles
=
NULL
;
free_console
(
process
);
wake_up
(
&
process
->
obj
,
0
);
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 */
/* add a thread to a process running threads list */
...
@@ -237,7 +244,6 @@ void remove_process_thread( struct process *process, struct thread *thread )
...
@@ -237,7 +244,6 @@ void remove_process_thread( struct process *process, struct thread *thread )
if
(
!--
process
->
running_threads
)
if
(
!--
process
->
running_threads
)
{
{
/* we have removed the last running thread, exit the process */
/* we have removed the last running thread, exit the process */
running_processes
--
;
process_killed
(
process
,
thread
->
exit_code
);
process_killed
(
process
,
thread
->
exit_code
);
}
}
release_object
(
thread
);
release_object
(
thread
);
...
@@ -366,7 +372,7 @@ DECL_HANDLER(new_process)
...
@@ -366,7 +372,7 @@ DECL_HANDLER(new_process)
char
*
cmd_line
=
(
char
*
)
data
;
char
*
cmd_line
=
(
char
*
)
data
;
CHECK_STRING
(
"new_process"
,
cmd_line
,
len
);
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
.
pid
=
process
;
reply
.
handle
=
alloc_handle
(
current
->
process
,
process
,
reply
.
handle
=
alloc_handle
(
current
->
process
,
process
,
...
...
server/process.h
View file @
eb2e77fd
...
@@ -15,8 +15,6 @@
...
@@ -15,8 +15,6 @@
/* process structures */
/* process structures */
struct
handle_entry
;
struct
process
struct
process
{
{
struct
object
obj
;
/* object header */
struct
object
obj
;
/* object header */
...
@@ -26,9 +24,7 @@ struct process
...
@@ -26,9 +24,7 @@ struct process
struct
process
*
debug_next
;
/* per-debugger process list */
struct
process
*
debug_next
;
/* per-debugger process list */
struct
process
*
debug_prev
;
struct
process
*
debug_prev
;
struct
thread
*
debugger
;
/* thread debugging this process */
struct
thread
*
debugger
;
/* thread debugging this process */
struct
handle_entry
*
entries
;
/* handle entries */
struct
object
*
handles
;
/* handle entries */
int
handle_last
;
/* last valid handle */
int
handle_count
;
/* allocated table entries */
int
exit_code
;
/* process exit code */
int
exit_code
;
/* process exit code */
int
running_threads
;
/* number of threads running in this process */
int
running_threads
;
/* number of threads running in this process */
struct
timeval
start_time
;
/* absolute time at process start */
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 =
...
@@ -74,8 +74,7 @@ static const struct object_ops thread_ops =
destroy_thread
destroy_thread
};
};
static
struct
thread
initial_thread
;
static
struct
thread
*
first_thread
;
static
struct
thread
*
first_thread
=
&
initial_thread
;
/* initialization of a thread structure */
/* initialization of a thread structure */
static
void
init_thread
(
struct
thread
*
thread
,
int
fd
)
static
void
init_thread
(
struct
thread
*
thread
,
int
fd
)
...
@@ -104,12 +103,14 @@ 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 */
/* create the initial thread and start the main server loop */
void
create_initial_thread
(
int
fd
)
void
create_initial_thread
(
int
fd
)
{
{
current
=
&
initial_thread
;
first_thread
=
mem_alloc
(
sizeof
(
*
first_thread
)
);
init_thread
(
&
initial_thread
,
fd
);
assert
(
first_thread
);
initial_thread
.
process
=
create_initial_process
();
add_process_thread
(
initial_thread
.
process
,
&
initial_thread
);
current
=
first_thread
;
initial_thread
.
client
=
add_client
(
fd
,
&
initial_thread
);
init_thread
(
first_thread
,
fd
);
grab_object
(
&
initial_thread
);
/* so that we never free it */
first_thread
->
process
=
create_initial_process
();
add_process_thread
(
first_thread
->
process
,
first_thread
);
first_thread
->
client
=
add_client
(
fd
,
first_thread
);
select_loop
();
select_loop
();
}
}
...
@@ -131,8 +132,7 @@ static struct thread *create_thread( int fd, void *pid, int suspend, int inherit
...
@@ -131,8 +132,7 @@ static struct thread *create_thread( int fd, void *pid, int suspend, int inherit
if
(
suspend
)
thread
->
suspend
++
;
if
(
suspend
)
thread
->
suspend
++
;
thread
->
next
=
first_thread
;
if
((
thread
->
next
=
first_thread
)
!=
NULL
)
thread
->
next
->
prev
=
thread
;
first_thread
->
prev
=
thread
;
first_thread
=
thread
;
first_thread
=
thread
;
add_process_thread
(
process
,
thread
);
add_process_thread
(
process
,
thread
);
...
@@ -146,7 +146,7 @@ static struct thread *create_thread( int fd, void *pid, int suspend, int inherit
...
@@ -146,7 +146,7 @@ static struct thread *create_thread( int fd, void *pid, int suspend, int inherit
return
thread
;
return
thread
;
error:
error:
if
(
current
)
close_handle
(
current
->
process
,
*
handle
);
close_handle
(
current
->
process
,
*
handle
);
remove_process_thread
(
process
,
thread
);
remove_process_thread
(
process
,
thread
);
release_object
(
thread
);
release_object
(
thread
);
return
NULL
;
return
NULL
;
...
@@ -174,8 +174,8 @@ static void dump_thread( struct object *obj, int verbose )
...
@@ -174,8 +174,8 @@ static void dump_thread( struct object *obj, int verbose )
struct
thread
*
thread
=
(
struct
thread
*
)
obj
;
struct
thread
*
thread
=
(
struct
thread
*
)
obj
;
assert
(
obj
->
ops
==
&
thread_ops
);
assert
(
obj
->
ops
==
&
thread_ops
);
fprintf
(
stderr
,
"Thread pid=%d teb=%p
client=%p
\n
"
,
fprintf
(
stderr
,
"Thread pid=%d teb=%p
state=%d
\n
"
,
thread
->
unix_pid
,
thread
->
teb
,
thread
->
client
);
thread
->
unix_pid
,
thread
->
teb
,
thread
->
state
);
}
}
static
int
thread_signaled
(
struct
object
*
obj
,
struct
thread
*
thread
)
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