Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
63411dbd
Commit
63411dbd
authored
Dec 22, 2000
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid dup'ing file descriptors when not necessary.
Do not send fd to the client if ops->get_fd() fails.
parent
2930b9c4
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
31 additions
and
25 deletions
+31
-25
async.c
server/async.c
+1
-1
console.c
server/console.c
+3
-3
file.c
server/file.c
+8
-3
handle.c
server/handle.c
+0
-1
mapping.c
server/mapping.c
+7
-7
pipe.c
server/pipe.c
+1
-1
registry.c
server/registry.c
+2
-2
request.c
server/request.c
+4
-1
serial.c
server/serial.c
+1
-1
sock.c
server/sock.c
+1
-5
thread.c
server/thread.c
+3
-0
No files found.
server/async.c
View file @
63411dbd
...
...
@@ -117,7 +117,7 @@ static int async_get_fd( struct object *obj )
{
struct
async
*
async
=
(
struct
async
*
)
obj
;
assert
(
obj
->
ops
==
&
async_ops
);
return
dup
(
async
->
obj
.
fd
)
;
return
async
->
obj
.
fd
;
}
static
int
async_get_info
(
struct
object
*
obj
,
struct
get_file_info_request
*
req
)
{
...
...
server/console.c
View file @
63411dbd
...
...
@@ -354,7 +354,7 @@ static int console_input_get_fd( struct object *obj )
{
struct
console_input
*
console
=
(
struct
console_input
*
)
obj
;
assert
(
obj
->
ops
==
&
console_input_ops
);
return
dup
(
console
->
obj
.
fd
)
;
return
console
->
obj
.
fd
;
}
static
int
console_get_info
(
struct
object
*
obj
,
struct
get_file_info_request
*
req
)
...
...
@@ -395,7 +395,7 @@ static int screen_buffer_get_fd( struct object *obj )
{
struct
screen_buffer
*
console
=
(
struct
screen_buffer
*
)
obj
;
assert
(
obj
->
ops
==
&
screen_buffer_ops
);
return
dup
(
console
->
obj
.
fd
)
;
return
console
->
obj
.
fd
;
}
static
void
screen_buffer_destroy
(
struct
object
*
obj
)
...
...
@@ -481,7 +481,7 @@ DECL_HANDLER(set_console_fd)
if
(
!
(
obj
=
get_handle_obj
(
current
->
process
,
req
->
file_handle
,
GENERIC_READ
|
GENERIC_WRITE
,
NULL
)))
return
;
if
((
fd_in
=
obj
->
ops
->
get_fd
(
obj
))
==
-
1
)
if
((
fd_in
=
dup
(
obj
->
ops
->
get_fd
(
obj
)
))
==
-
1
)
{
release_object
(
obj
);
return
;
...
...
server/file.c
View file @
63411dbd
...
...
@@ -235,7 +235,7 @@ static int file_get_fd( struct object *obj )
{
struct
file
*
file
=
(
struct
file
*
)
obj
;
assert
(
obj
->
ops
==
&
file_ops
);
return
dup
(
file
->
obj
.
fd
)
;
return
file
->
obj
.
fd
;
}
static
int
file_flush
(
struct
object
*
obj
)
...
...
@@ -474,8 +474,13 @@ DECL_HANDLER(get_handle_fd)
req
->
fd
=
-
1
;
if
((
obj
=
get_handle_obj
(
current
->
process
,
req
->
handle
,
req
->
access
,
NULL
)))
{
if
((
req
->
fd
=
get_handle_fd
(
current
->
process
,
req
->
handle
,
req
->
access
))
==
-
1
)
send_client_fd
(
current
,
obj
->
ops
->
get_fd
(
obj
),
req
->
handle
);
int
fd
=
get_handle_fd
(
current
->
process
,
req
->
handle
,
req
->
access
);
if
(
fd
!=
-
1
)
req
->
fd
=
fd
;
else
if
(
!
get_error
())
{
if
((
fd
=
obj
->
ops
->
get_fd
(
obj
))
!=
-
1
)
send_client_fd
(
current
,
fd
,
req
->
handle
);
}
release_object
(
obj
);
}
}
...
...
server/handle.c
View file @
63411dbd
...
...
@@ -362,7 +362,6 @@ int get_handle_fd( struct process *process, int handle, unsigned int access )
{
struct
handle_entry
*
entry
;
if
(
HANDLE_IS_GLOBAL
(
handle
))
return
-
1
;
/* no fd cache for global handles */
if
(
!
(
entry
=
get_handle
(
process
,
handle
)))
return
-
1
;
if
((
entry
->
access
&
access
)
!=
access
)
{
...
...
server/mapping.c
View file @
63411dbd
...
...
@@ -91,7 +91,11 @@ static void init_page_size(void)
inline
static
int
get_mmap_fd
(
struct
file
*
file
)
{
struct
object
*
obj
;
if
(
!
(
obj
=
(
struct
object
*
)
file
))
return
-
1
;
if
(
!
(
obj
=
(
struct
object
*
)
file
))
{
set_error
(
STATUS_INVALID_HANDLE
);
return
-
1
;
}
return
obj
->
ops
->
get_fd
(
obj
);
}
...
...
@@ -100,8 +104,8 @@ static int build_shared_mapping( struct mapping *mapping, int fd,
IMAGE_SECTION_HEADER
*
sec
,
int
nb_sec
)
{
int
i
,
max_size
,
total_size
,
pos
;
char
*
buffer
=
NULL
;
int
shared_fd
=
-
1
;
char
*
buffer
=
NULL
;
int
shared_fd
;
long
toread
;
/* compute the total size of the shared mapping */
...
...
@@ -147,12 +151,10 @@ static int build_shared_mapping( struct mapping *mapping, int fd,
}
if
(
write
(
shared_fd
,
buffer
,
sec
[
i
].
SizeOfRawData
)
!=
sec
[
i
].
SizeOfRawData
)
goto
error
;
}
close
(
shared_fd
);
free
(
buffer
);
return
1
;
error:
if
(
shared_fd
!=
-
1
)
close
(
shared_fd
);
if
(
buffer
)
free
(
buffer
);
return
0
;
}
...
...
@@ -193,13 +195,11 @@ static int get_image_params( struct mapping *mapping )
if
(
mapping
->
header_size
>
mapping
->
size_low
)
goto
error
;
lseek
(
fd
,
filepos
,
SEEK_SET
);
close
(
fd
);
free
(
sec
);
return
1
;
error:
lseek
(
fd
,
filepos
,
SEEK_SET
);
close
(
fd
);
if
(
sec
)
free
(
sec
);
set_error
(
STATUS_INVALID_FILE_FOR_SECTION
);
return
0
;
...
...
server/pipe.c
View file @
63411dbd
...
...
@@ -122,7 +122,7 @@ static int pipe_get_fd( struct object *obj )
set_error
(
STATUS_PIPE_BROKEN
);
return
-
1
;
}
return
dup
(
pipe
->
obj
.
fd
)
;
return
pipe
->
obj
.
fd
;
}
static
int
pipe_get_info
(
struct
object
*
obj
,
struct
get_file_info_request
*
req
)
...
...
server/registry.c
View file @
63411dbd
...
...
@@ -1340,7 +1340,7 @@ static void load_registry( struct key *key, int handle )
int
fd
;
if
(
!
(
obj
=
get_handle_obj
(
current
->
process
,
handle
,
GENERIC_READ
,
NULL
)))
return
;
fd
=
obj
->
ops
->
get_fd
(
obj
);
fd
=
dup
(
obj
->
ops
->
get_fd
(
obj
)
);
release_object
(
obj
);
if
(
fd
!=
-
1
)
{
...
...
@@ -1435,7 +1435,7 @@ static void save_registry( struct key *key, int handle )
return
;
}
if
(
!
(
obj
=
get_handle_obj
(
current
->
process
,
handle
,
GENERIC_WRITE
,
NULL
)))
return
;
fd
=
obj
->
ops
->
get_fd
(
obj
);
fd
=
dup
(
obj
->
ops
->
get_fd
(
obj
)
);
release_object
(
obj
);
if
(
fd
!=
-
1
)
{
...
...
server/request.c
View file @
63411dbd
...
...
@@ -259,6 +259,9 @@ int send_client_fd( struct thread *thread, int fd, int handle )
{
int
ret
;
if
(
debug_level
)
fprintf
(
stderr
,
"%08x: *fd* %d = %d
\n
"
,
(
unsigned
int
)
thread
,
handle
,
fd
);
#ifdef HAVE_MSGHDR_ACCRIGHTS
msghdr
.
msg_accrightslen
=
sizeof
(
fd
);
msghdr
.
msg_accrights
=
(
void
*
)
&
fd
;
...
...
@@ -272,7 +275,6 @@ int send_client_fd( struct thread *thread, int fd, int handle )
myiovec
.
iov_len
=
sizeof
(
handle
);
ret
=
sendmsg
(
thread
->
obj
.
fd
,
&
msghdr
,
0
);
close
(
fd
);
if
(
ret
>
0
)
return
0
;
if
(
errno
==
EPIPE
)
...
...
@@ -381,6 +383,7 @@ struct object *create_request_socket( struct thread *thread )
}
sock
->
thread
=
thread
;
send_client_fd
(
thread
,
fd
[
1
],
-
1
);
close
(
fd
[
1
]
);
set_select_events
(
&
sock
->
obj
,
POLLIN
);
return
&
sock
->
obj
;
}
...
...
server/serial.c
View file @
63411dbd
...
...
@@ -154,7 +154,7 @@ static int serial_get_fd( struct object *obj )
{
struct
serial
*
serial
=
(
struct
serial
*
)
obj
;
assert
(
obj
->
ops
==
&
serial_ops
);
return
dup
(
serial
->
obj
.
fd
)
;
return
serial
->
obj
.
fd
;
}
static
int
serial_get_info
(
struct
object
*
obj
,
struct
get_file_info_request
*
req
)
...
...
server/sock.c
View file @
63411dbd
...
...
@@ -255,12 +255,8 @@ static int sock_get_poll_events( struct object *obj )
static
int
sock_get_fd
(
struct
object
*
obj
)
{
struct
sock
*
sock
=
(
struct
sock
*
)
obj
;
int
fd
;
assert
(
obj
->
ops
==
&
sock_ops
);
fd
=
dup
(
sock
->
obj
.
fd
);
if
(
fd
==-
1
)
sock_set_error
();
return
fd
;
return
sock
->
obj
.
fd
;
}
static
void
sock_destroy
(
struct
object
*
obj
)
...
...
server/thread.c
View file @
63411dbd
...
...
@@ -109,6 +109,8 @@ static int alloc_client_buffer( struct thread *thread )
send_client_fd
(
thread
,
fd_pipe
[
0
],
-
1
);
send_client_fd
(
thread
,
fd
,
-
1
);
send_reply
(
thread
);
close
(
fd_pipe
[
0
]
);
close
(
fd
);
return
1
;
error:
...
...
@@ -691,6 +693,7 @@ DECL_HANDLER(new_thread)
THREAD_ALL_ACCESS
,
req
->
inherit
))
!=
-
1
)
{
send_client_fd
(
current
,
sock
[
1
],
req
->
handle
);
close
(
sock
[
1
]
);
/* thread object will be released when the thread gets killed */
add_process_thread
(
current
->
process
,
thread
);
return
;
...
...
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