From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/unix/server.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 53308fb4c8c..451bed1110b 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -235,7 +235,7 @@ static unsigned int send_request( const struct __server_request_info *req ) } }
- if (errno == EPIPE) abort_thread(0); + if (errno == EPIPE) return STATUS_THREAD_IS_TERMINATING; if (errno == EFAULT) return STATUS_ACCESS_VIOLATION; server_protocol_perror( "write" ); } @@ -246,7 +246,7 @@ static unsigned int send_request( const struct __server_request_info *req ) * * Read data from the reply buffer; helper for wait_reply. */ -static void read_reply_data( void *buffer, size_t size ) +static UINT read_reply_data( void *buffer, size_t size ) { int ret;
@@ -254,13 +254,13 @@ static void read_reply_data( void *buffer, size_t size ) { if ((ret = read( ntdll_get_thread_data()->reply_fd, buffer, size )) > 0) { - if (!(size -= ret)) return; + if (!(size -= ret)) return STATUS_SUCCESS; buffer = (char *)buffer + ret; continue; } if (!ret) break; if (errno == EINTR) continue; - if (errno == EPIPE) break; + if (errno == EPIPE) return STATUS_THREAD_IS_TERMINATING; server_protocol_perror("read"); } /* the server closed the connection; time to die... */ @@ -275,9 +275,10 @@ static void read_reply_data( void *buffer, size_t size ) */ static inline unsigned int wait_reply( struct __server_request_info *req ) { - read_reply_data( &req->u.reply, sizeof(req->u.reply) ); - if (req->u.reply.reply_header.reply_size) - read_reply_data( req->reply_data, req->u.reply.reply_header.reply_size ); + unsigned int ret; + if ((ret = read_reply_data( &req->u.reply, sizeof(req->u.reply) ))) return ret; + if (!req->u.reply.reply_header.reply_size) return req->u.reply.reply_header.error; + if ((ret = read_reply_data( req->reply_data, req->u.reply.reply_header.reply_size ))) return ret; return req->u.reply.reply_header.error; }
@@ -307,6 +308,7 @@ unsigned int CDECL wine_server_call( void *req_ptr )
pthread_sigmask( SIG_BLOCK, &server_block_set, &old_set ); ret = server_call_unlocked( req_ptr ); + if (ret == STATUS_THREAD_IS_TERMINATING) abort_thread(0); pthread_sigmask( SIG_SETMASK, &old_set, NULL ); return ret; } @@ -339,6 +341,7 @@ void server_enter_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigse void server_leave_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigset, NTSTATUS status ) { mutex_unlock( mutex ); + if (status == STATUS_THREAD_IS_TERMINATING) abort_thread(0); pthread_sigmask( SIG_SETMASK, sigset, NULL ); }