From 3f09ec5263983c5f741dcc4afd8873394b4aaa80 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 28 Feb 1999 19:25:51 +0000 Subject: [PATCH] CLIENT_WaitReply: don't clear last error on success; fixed callers accordingly (based on a patch by Juergen Schmied). --- files/file.c | 3 +++ scheduler/client.c | 2 +- scheduler/event.c | 1 + scheduler/mutex.c | 4 ++-- scheduler/semaphore.c | 1 + server/file.c | 1 + win32/console.c | 1 + 7 files changed, 10 insertions(+), 3 deletions(-) diff --git a/files/file.c b/files/file.c index e0937775db3..8936215c967 100644 --- a/files/file.c +++ b/files/file.c @@ -344,6 +344,7 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing, CLIENT_SendRequest( REQ_CREATE_FILE, -1, 2, &req, sizeof(req), filename, strlen(filename) + 1 ); + SetLastError(0); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); /* If write access failed, retry without GENERIC_WRITE */ @@ -359,6 +360,7 @@ HFILE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing, CLIENT_SendRequest( REQ_CREATE_FILE, -1, 2, &req, sizeof(req), filename, strlen(filename) + 1 ); + SetLastError(0); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); } } @@ -380,6 +382,7 @@ HFILE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa ) req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); req.id = client_id; CLIENT_SendRequest( REQ_CREATE_DEVICE, -1, 1, &req, sizeof(req) ); + SetLastError(0); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); return reply.handle; } diff --git a/scheduler/client.c b/scheduler/client.c index ae9a1c09ad2..2a9229d4880 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -210,7 +210,7 @@ static unsigned int CLIENT_WaitReply_v( int *len, int *passed_fd, remaining -= addlen; } - SetLastError( head.type ); + if (head.type) SetLastError( head.type ); return head.type; /* error code */ } diff --git a/scheduler/event.c b/scheduler/event.c index fbdd4b863b0..04f5778e621 100644 --- a/scheduler/event.c +++ b/scheduler/event.c @@ -27,6 +27,7 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, req.initial_state = initial_state; req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); CLIENT_SendRequest( REQ_CREATE_EVENT, -1, 2, &req, sizeof(req), name, len ); + SetLastError(0); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); if (reply.handle == -1) return 0; return reply.handle; diff --git a/scheduler/mutex.c b/scheduler/mutex.c index 180d28f8afb..7bbe6a8f82e 100644 --- a/scheduler/mutex.c +++ b/scheduler/mutex.c @@ -15,8 +15,7 @@ /*********************************************************************** * CreateMutex32A (KERNEL32.166) */ -HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, - LPCSTR name ) +HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name ) { struct create_mutex_request req; struct create_mutex_reply reply; @@ -25,6 +24,7 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, req.owned = owner; req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); CLIENT_SendRequest( REQ_CREATE_MUTEX, -1, 2, &req, sizeof(req), name, len ); + SetLastError(0); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); if (reply.handle == -1) return 0; return reply.handle; diff --git a/scheduler/semaphore.c b/scheduler/semaphore.c index b321331d93b..298df02e787 100644 --- a/scheduler/semaphore.c +++ b/scheduler/semaphore.c @@ -35,6 +35,7 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); CLIENT_SendRequest( REQ_CREATE_SEMAPHORE, -1, 2, &req, sizeof(req), name, len ); + SetLastError(0); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); if (reply.handle == -1) return 0; return reply.handle; diff --git a/server/file.c b/server/file.c index 3bb61686950..6d992bdc287 100644 --- a/server/file.c +++ b/server/file.c @@ -140,6 +140,7 @@ struct object *create_file( int fd, const char *name, unsigned int access, case GENERIC_READ|GENERIC_WRITE: flags |= O_RDWR; break; } + /* FIXME: should set error to ERROR_ALREADY_EXISTS if file existed before */ if ((fd = open( name, flags | O_NONBLOCK, (attrs & FILE_ATTRIBUTE_READONLY) ? 0444 : 0666 )) == -1) { diff --git a/win32/console.c b/win32/console.c index aeb68442a59..414a40ac036 100644 --- a/win32/console.c +++ b/win32/console.c @@ -444,6 +444,7 @@ HANDLE CONSOLE_OpenHandle( BOOL output, DWORD access, LPSECURITY_ATTRIBUTES sa ) req.access = access; req.inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle); CLIENT_SendRequest( REQ_OPEN_CONSOLE, -1, 1, &req, sizeof(req) ); + SetLastError(0); CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL ); return reply.handle; }