Skip to content

Commit

Permalink
ntdll, server: Specify EFD_SEMAPHORE on the server side.
Browse files Browse the repository at this point in the history
This just makes things cleaner; since we already pass the type to the server
there's no reason to pass this as well.
  • Loading branch information
zfigura authored and aeikum committed Jan 22, 2020
1 parent 47331f3 commit 2c3de14
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 25 deletions.
21 changes: 7 additions & 14 deletions dlls/ntdll/esync.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@
# include <sys/poll.h>
#endif
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_SYS_EVENTFD_H
# include <sys/eventfd.h>
#endif
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
Expand All @@ -51,10 +49,6 @@
#include "ntdll_misc.h"
#include "esync.h"

#ifndef EFD_SEMAPHORE
#define EFD_SEMAPHORE 1
#endif

WINE_DEFAULT_DEBUG_CHANNEL(esync);

int do_esync(void)
Expand Down Expand Up @@ -115,7 +109,7 @@ static int shm_addrs_size; /* length of the allocated shm_addrs array */
static long pagesize;

static NTSTATUS create_esync( enum esync_type type, HANDLE *handle,
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval, int flags );
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval );

void esync_init(void)
{
Expand All @@ -127,7 +121,7 @@ void esync_init(void)
HANDLE handle;
NTSTATUS ret;

ret = create_esync( 0, &handle, 0, NULL, 0, 0 );
ret = create_esync( 0, &handle, 0, NULL, 0 );
if (ret != STATUS_NOT_IMPLEMENTED)
{
ERR("Server is running with WINEESYNC but this process is not, please enable WINEESYNC or restart wineserver.\n");
Expand Down Expand Up @@ -326,7 +320,7 @@ NTSTATUS esync_close( HANDLE handle )
}

static NTSTATUS create_esync( enum esync_type type, HANDLE *handle,
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval, int flags )
ACCESS_MASK access, const OBJECT_ATTRIBUTES *attr, int initval )
{
NTSTATUS ret;
data_size_t len;
Expand All @@ -345,7 +339,6 @@ static NTSTATUS create_esync( enum esync_type type, HANDLE *handle,
{
req->access = access;
req->initval = initval;
req->flags = flags;
req->type = type;
wine_server_add_data( req, objattr, len );
ret = wine_server_call( req );
Expand Down Expand Up @@ -437,7 +430,7 @@ NTSTATUS esync_create_semaphore(HANDLE *handle, ACCESS_MASK access,
* before anyone else can open the object. */
RtlEnterCriticalSection( &shm_init_section );

ret = create_esync( ESYNC_SEMAPHORE, handle, access, attr, initial, EFD_SEMAPHORE );
ret = create_esync( ESYNC_SEMAPHORE, handle, access, attr, initial );
if (!ret)
{
/* Initialize the shared memory portion.
Expand Down Expand Up @@ -538,7 +531,7 @@ NTSTATUS esync_create_event( HANDLE *handle, ACCESS_MASK access,

RtlEnterCriticalSection( &shm_init_section );

ret = create_esync( type, handle, access, attr, initial, 0 );
ret = create_esync( type, handle, access, attr, initial );

if (!ret)
{
Expand Down Expand Up @@ -735,7 +728,7 @@ NTSTATUS esync_create_mutex( HANDLE *handle, ACCESS_MASK access,

RtlEnterCriticalSection( &shm_init_section );

ret = create_esync( ESYNC_MUTEX, handle, access, attr, initial ? 0 : 1, 0 );
ret = create_esync( ESYNC_MUTEX, handle, access, attr, initial ? 0 : 1 );
if (!ret)
{
/* Initialize the shared memory portion. */
Expand Down
4 changes: 1 addition & 3 deletions include/wine/server_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -5802,10 +5802,8 @@ struct create_esync_request
struct request_header __header;
unsigned int access;
int initval;
int flags;
int type;
/* VARARG(objattr,object_attributes); */
char __pad_28[4];
};
struct create_esync_reply
{
Expand Down Expand Up @@ -6791,6 +6789,6 @@ union generic_reply
struct get_esync_apc_fd_reply get_esync_apc_fd_reply;
};

#define SERVER_PROTOCOL_VERSION 606
#define SERVER_PROTOCOL_VERSION 607

#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
11 changes: 8 additions & 3 deletions server/esync.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int type_matches( enum esync_type type1, enum esync_type type2 )
}

static struct esync *create_esync( struct object *root, const struct unicode_str *name,
unsigned int attr, int initval, int flags, enum esync_type type,
unsigned int attr, int initval, enum esync_type type,
const struct security_descriptor *sd )
{
#ifdef HAVE_SYS_EVENTFD_H
Expand All @@ -188,8 +188,13 @@ static struct esync *create_esync( struct object *root, const struct unicode_str
{
if (get_error() != STATUS_OBJECT_NAME_EXISTS)
{
int flags = EFD_CLOEXEC | EFD_NONBLOCK;

if (type == ESYNC_SEMAPHORE)
flags |= EFD_SEMAPHORE;

/* initialize it if it didn't already exist */
esync->fd = eventfd( initval, flags | EFD_CLOEXEC | EFD_NONBLOCK );
esync->fd = eventfd( initval, flags );
if (esync->fd == -1)
{
perror( "eventfd" );
Expand Down Expand Up @@ -407,7 +412,7 @@ DECL_HANDLER(create_esync)

if (!objattr) return;

if ((esync = create_esync( root, &name, objattr->attributes, req->initval, req->flags, req->type, sd )))
if ((esync = create_esync( root, &name, objattr->attributes, req->initval, req->type, sd )))
{
if (get_error() == STATUS_OBJECT_NAME_EXISTS)
reply->handle = alloc_handle( current->process, esync, req->access, objattr->attributes );
Expand Down
1 change: 0 additions & 1 deletion server/protocol.def
Original file line number Diff line number Diff line change
Expand Up @@ -3961,7 +3961,6 @@ struct handle_info
@REQ(create_esync)
unsigned int access; /* wanted access rights */
int initval; /* initial value */
int flags; /* flags (EFD_SEMAPHORE or 0) */
int type; /* type of esync object (see below) */
VARARG(objattr,object_attributes); /* object attributes */
@REPLY
Expand Down
5 changes: 2 additions & 3 deletions server/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -2455,9 +2455,8 @@ C_ASSERT( FIELD_OFFSET(struct resume_process_request, handle) == 12 );
C_ASSERT( sizeof(struct resume_process_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_esync_request, access) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_esync_request, initval) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_esync_request, flags) == 20 );
C_ASSERT( FIELD_OFFSET(struct create_esync_request, type) == 24 );
C_ASSERT( sizeof(struct create_esync_request) == 32 );
C_ASSERT( FIELD_OFFSET(struct create_esync_request, type) == 20 );
C_ASSERT( sizeof(struct create_esync_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, handle) == 8 );
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, type) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_esync_reply, shm_idx) == 16 );
Expand Down
2 changes: 1 addition & 1 deletion server/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4612,7 +4612,6 @@ static void dump_create_esync_request( const struct create_esync_request *req )
{
fprintf( stderr, " access=%08x", req->access );
fprintf( stderr, ", initval=%d", req->initval );
fprintf( stderr, ", flags=%d", req->flags );
fprintf( stderr, ", type=%d", req->type );
dump_varargs_object_attributes( ", objattr=", cur_size );
}
Expand Down Expand Up @@ -5632,6 +5631,7 @@ static const struct
{ "INVALID_LOCK_SEQUENCE", STATUS_INVALID_LOCK_SEQUENCE },
{ "INVALID_OWNER", STATUS_INVALID_OWNER },
{ "INVALID_PARAMETER", STATUS_INVALID_PARAMETER },
{ "INVALID_PARAMETER_4", STATUS_INVALID_PARAMETER_4 },
{ "INVALID_PIPE_STATE", STATUS_INVALID_PIPE_STATE },
{ "INVALID_READ_MODE", STATUS_INVALID_READ_MODE },
{ "INVALID_SECURITY_DESCR", STATUS_INVALID_SECURITY_DESCR },
Expand Down

0 comments on commit 2c3de14

Please sign in to comment.