From patchwork Tue Feb 28 19:44:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65811 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F07C3858281 for ; Tue, 28 Feb 2023 19:44:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F07C3858281 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677613490; bh=vLDJKL0SaqbD0dWQaE/rDByDNz50cP5n4IoyuL7WmME=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=WdwVzkWqWQoFL0x6TyOLZvXXJly5dioHPD+K2Nht2cj5lVpJUY+0p1vqFbl/OnhAi SGRks+t+HkbYWImqNxrzJyuLTOB5iiZKW9sg6u9VIy5Q+PCTjhMXHOOdgvyBa/JQkY gdJwERa9n1u8lRzTSqdn4KEgYgcJSNPyhBeRoAuc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id 0EF0D3858D33 for ; Tue, 28 Feb 2023 19:44:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0EF0D3858D33 Received: by mail-lf1-x12d.google.com with SMTP id n2so14650908lfb.12 for ; Tue, 28 Feb 2023 11:44:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677613458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vLDJKL0SaqbD0dWQaE/rDByDNz50cP5n4IoyuL7WmME=; b=OyONZV0RfIYrNghgGL9rZa3XHBj5xE9wqXbZ3FLZ1iFwsxYzNG/GIh/yx6MDc1zd5b /p36CqI1iqMQkbNJof//CbnXAGr7MnoCsbG/TA6Qvo3fvEODynVEdEeg8QmIiwVl0F7E sjWmuyCnmbB31Le/PB6nDajzXp2RZBL4BGYw+A6NGgdhituUFfNyzY839GC7vnJJ8hpq BC1yhsyuqpjJEz6CXBqUXutwYSI/BEnpabiCTXP2Tw3MwAw7B8Ig3l3nGDxLh66WCC1h I9gJaQ1dUwWKbbhKv8EAJKID5vpGEStxs8tStp7mDYCGri6PmCHddiIxpFlasjwqekp4 w1tQ== X-Gm-Message-State: AO0yUKUNUBanzcsaSnSZkKOv/7IAylxUnmr+3C5zwE0i4f7gfiuDvYiy Gzueib1Nz82ph9rrZqm0qck08/8x4TM= X-Google-Smtp-Source: AK7set8ytYNhoQQlju/QYo+XI+UvDy86d8PoBOAohpN5VzmYJzz3kt8CBzGTQqUs7g+MfPH9xhJOXQ== X-Received: by 2002:ac2:48a7:0:b0:4dc:4b70:a723 with SMTP id u7-20020ac248a7000000b004dc4b70a723mr1056222lfg.30.1677613458253; Tue, 28 Feb 2023 11:44:18 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:95f6:9b5e:bc83:32e1]) by smtp.gmail.com with ESMTPSA id c7-20020a05651221a700b004db44e91e34sm1445518lft.43.2023.02.28.11.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 11:44:17 -0800 (PST) To: Samuel Thibault , bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: Sergey Bugaev Subject: [PATCH 1/2] hurd: Fully remove the ecx kludge Date: Tue, 28 Feb 2023 22:44:08 +0300 Message-Id: <20230228194409.379949-1-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" "We don't need it any more" The INTR_MSG_TRAP macro in intr-msg.h used to play little trick with the stack pointer: it would temporarily save the "real" stack pointer into ecx, while setting esp to point to just before the message buffer, and then invoke the mach_msg trap. This way, INTR_MSG_TRAP reused the on-stack arguments laid out for the containing call of _hurd_intr_rpc_mach_msg (), passing them to the mach_msg trap directly. This, however, required special support in hurdsig.c and trampoline.c, since they now had to recognize when a thread is inside the piece of code where esp doesn't point to the real tip of the stack, and handle this situation specially. Commit 1d20f33ff4fb634310f27493b7b87d0b20f4a0b0 has removed the actual temporary change of esp by actually re-pushing mach_msg arguments onto the stack, and popping them back at end. It did not, however, deal with the rest of "the ecx kludge" code in other files, resulting in potential crashes if a signal arrives in the middle of pushing arguments onto the stack. This was made more confusing because of a comment in hurdsig.c, which seemed to indicate that if a thread is about to enter the mach_msg trap, the trap has to be skipped while setting the return code as if the thread has already entered the trap and the operation has been interrupted. In fact, skipping the trap was not a goal in and of itself, but rather a way to get the thread back into a consistent state with respect to what the value of esp is and what the code expects it to be. So it is fine to remove this, since the value of esp is no longer inconsistent. Fix the issue by removing all traces of "the ecx kludge", which also simplifies things nicely and paves the way for a future x86_64 port of this code. Signed-off-by: Sergey Bugaev --- hurd/hurdsig.c | 23 +++++---------------- sysdeps/mach/hurd/i386/intr-msg.h | 31 ++++++----------------------- sysdeps/mach/hurd/i386/trampoline.c | 21 ------------------- 3 files changed, 11 insertions(+), 64 deletions(-) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index ea79ffb5..3e759ae5 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -414,7 +414,6 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread, struct machine_thread_all_state *state, int *state_change, void (*reply) (void)) { - extern const void _hurd_intr_rpc_msg_about_to; extern const void _hurd_intr_rpc_msg_in_trap; mach_port_t rcv_port = MACH_PORT_NULL; mach_port_t intr_port; @@ -430,23 +429,11 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread, receive completes immediately or aborts. */ abort_thread (ss, state, reply); - if (state->basic.PC >= (uintptr_t) &_hurd_intr_rpc_msg_about_to - && state->basic.PC < (uintptr_t) &_hurd_intr_rpc_msg_in_trap) - { - /* The thread is about to do the RPC, but hasn't yet entered - mach_msg. Mutate the thread's state so it knows not to try - the RPC. */ - INTR_MSG_BACK_OUT (&state->basic); - MACHINE_THREAD_STATE_SET_PC (&state->basic, - &_hurd_intr_rpc_msg_in_trap); - state->basic.SYSRETURN = MACH_SEND_INTERRUPTED; - *state_change = 1; - } - else if (state->basic.PC == (uintptr_t) &_hurd_intr_rpc_msg_in_trap - /* The thread was blocked in the system call. After thread_abort, - the return value register indicates what state the RPC was in - when interrupted. */ - && state->basic.SYSRETURN == MACH_RCV_INTERRUPTED) + if (state->basic.PC == (uintptr_t) &_hurd_intr_rpc_msg_in_trap + /* The thread was blocked in the system call. After thread_abort, the + return value register indicates what state the RPC was in when + interrupted. */ + && state->basic.SYSRETURN == MACH_RCV_INTERRUPTED) { /* The RPC request message was sent and the thread was waiting for the reply message; now the message receive has been aborted, so diff --git a/sysdeps/mach/hurd/i386/intr-msg.h b/sysdeps/mach/hurd/i386/intr-msg.h index 29cb4620..953e4553 100644 --- a/sysdeps/mach/hurd/i386/intr-msg.h +++ b/sysdeps/mach/hurd/i386/intr-msg.h @@ -24,12 +24,7 @@ #define INTR_MSG_TRAP(msg, option, send_size, rcv_size, rcv_name, timeout, notify, cancel_p, intr_port_p) \ ({ \ error_t err; \ - asm (".globl _hurd_intr_rpc_msg_about_to\n" \ - ".globl _hurd_intr_rpc_msg_cx_sp\n" \ - ".globl _hurd_intr_rpc_msg_do_trap\n" \ - ".globl _hurd_intr_rpc_msg_in_trap\n" \ - ".globl _hurd_intr_rpc_msg_sp_restored\n" \ - "_hurd_intr_rpc_msg_about_to:" \ + asm (".globl _hurd_intr_rpc_msg_in_trap\n" \ /* We need to make a last check of cancel, in case we got interrupted right before _hurd_intr_rpc_msg_about_to. */ \ " cmpl $0, %5\n" \ @@ -37,7 +32,7 @@ /* We got interrupted, note so and return EINTR. */ \ " movl $0, %3\n" \ " movl %6, %%eax\n" \ - " jmp _hurd_intr_rpc_msg_sp_restored\n" \ + " jmp _hurd_intr_rpc_msg_out\n" \ "_hurd_intr_rpc_msg_do:" \ /* Ok, push the mach_msg_trap arguments. */ \ " pushl 24(%4)\n" \ @@ -48,10 +43,8 @@ " pushl %1\n" \ " pushl (%4)\n" \ " pushl $0\n" \ - /* TODO: remove this ecx kludge, we don't need it any more */ \ - " movl %%esp, %%ecx\n" \ - "_hurd_intr_rpc_msg_cx_sp: movl $-25, %%eax\n" \ - "_hurd_intr_rpc_msg_do_trap: lcall $7, $0 # status in %0\n" \ + " movl $-25, %%eax\n" \ + " lcall $7, $0 # status in %0\n" \ "_hurd_intr_rpc_msg_in_trap:" \ /* Ok, clean the arguments and update OPTION and TIMEOUT. */ \ " addl $8, %%esp\n" \ @@ -59,23 +52,11 @@ " addl $12, %%esp\n" \ " popl %2\n" \ " addl $4, %%esp\n" \ - "_hurd_intr_rpc_msg_sp_restored:" \ + "_hurd_intr_rpc_msg_out:" \ : "=a" (err), "+r" (option), "+r" (timeout), "=m" (*intr_port_p) \ - : "r" (&msg), "m" (*cancel_p), "i" (EINTR) \ - : "ecx"); \ + : "r" (&msg), "m" (*cancel_p), "i" (EINTR)); \ err; \ }) - - -static void inline -INTR_MSG_BACK_OUT (struct i386_thread_state *state) -{ - extern const void _hurd_intr_rpc_msg_cx_sp; - if (state->eip >= (natural_t) &_hurd_intr_rpc_msg_cx_sp) - state->uesp = state->ecx; - else - state->ecx = state->uesp; -} #include "hurdfault.h" diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c index 42c9d732..8f481e79 100644 --- a/sysdeps/mach/hurd/i386/trampoline.c +++ b/sysdeps/mach/hurd/i386/trampoline.c @@ -89,8 +89,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action void trampoline (void); void rpc_wait_trampoline (void); void firewall (void); - extern const void _hurd_intr_rpc_msg_cx_sp; - extern const void _hurd_intr_rpc_msg_sp_restored; void *volatile sigsp; struct sigcontext *scp; struct @@ -146,25 +144,6 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action interrupted RPC frame. */ state->basic.esp = state->basic.uesp; - /* This code has intimate knowledge of the special mach_msg system call - done in intr-msg.c; that code does (see intr-msg.h): - movl %esp, %ecx - leal ARGS, %esp - _hurd_intr_rpc_msg_cx_sp: movl $-25, %eax - _hurd_intr_rpc_msg_do_trap: lcall $7, $0 - _hurd_intr_rpc_msg_in_trap: movl %ecx, %esp - _hurd_intr_rpc_msg_sp_restored: - We must check for the window during which %esp points at the - mach_msg arguments. The space below until %ecx is used by - the _hurd_intr_rpc_mach_msg frame, and must not be clobbered. */ - if (state->basic.eip >= (int) &_hurd_intr_rpc_msg_cx_sp - && state->basic.eip < (int) &_hurd_intr_rpc_msg_sp_restored) - /* The SP now points at the mach_msg args, but there is more stack - space used below it. The real SP is saved in %ecx; we must push the - new frame below there (if not on the altstack), and restore that value as - the SP on sigreturn. */ - state->basic.uesp = state->basic.ecx; - if ((action->sa_flags & SA_ONSTACK) && !(ss->sigaltstack.ss_flags & (SS_DISABLE|SS_ONSTACK))) { From patchwork Tue Feb 28 19:44:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 65812 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 755003858031 for ; Tue, 28 Feb 2023 19:44:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 755003858031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677613492; bh=g/Wwv9zCvb2hX+429EVgaOp0F2s7QyQ1IftcziCJcko=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=pBPNujbd+xSOrk1ItQVmZ9to6emf+cSHTwNZ5u94yDaIkzp9APGKfNSQ5SEJ3GwO6 Wb6qJIunekf6HFJn/Jhk1YsPAq1ZfG/s1tYX75gEh2xTuxpr/V1GWVYhhMIEcrSLDU pRt0NE0/duS6GbtKjSwKhUkgevfP9s38BeE4h1R0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 221833858D39 for ; Tue, 28 Feb 2023 19:44:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 221833858D39 Received: by mail-lf1-x12c.google.com with SMTP id k14so14671717lfj.7 for ; Tue, 28 Feb 2023 11:44:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677613460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g/Wwv9zCvb2hX+429EVgaOp0F2s7QyQ1IftcziCJcko=; b=S+Twx0Jlz14P6YPiPNyyi9hjKkn+vig4RRL/DtqsnB4xrW5nFZxwVT+rvuu+72u+pq A18veTY4lmlfrG7P3Kr2UUlCv1qBygHoHYapJJLQybDMZXaJHP+o+mpGXmn7e8LOLlIb 4B4z0K9lk40MKL2cqzdXH3obt9UcVl3SNtDbpUwMqj+1yRZ9EyRCuMgYHeWS1hvBWGni fzQ3IvaFJTR78DohT6FFf+/8q7nOFWEGiA7rpCPchtY+XEzH0VtwpGfEdgohusPB21+V OWNWMrlqfqdChuJPbIcyli6xuo8sNxRfI2s1HFMnyKMqyW5DbVRpxAjmXmTA/y/D3Vzh hCVg== X-Gm-Message-State: AO0yUKWLDtgxlQBStJZZnluH73CtD0fXZKO2dal5UOX8NJtrDnjeD7Rr GpepHxJe/OJTvtYK3t2U2qkjCEZm9kg= X-Google-Smtp-Source: AK7set8yr+jEvtzatr/5Ij5btyWK3h5iCQdaKeMmidaV7yhKs/asBwS/u4BhL75p/Mh6jchGuZr24g== X-Received: by 2002:a05:6512:118d:b0:4a4:68b7:deb7 with SMTP id g13-20020a056512118d00b004a468b7deb7mr1325681lfr.19.1677613460045; Tue, 28 Feb 2023 11:44:20 -0800 (PST) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:95f6:9b5e:bc83:32e1]) by smtp.gmail.com with ESMTPSA id c7-20020a05651221a700b004db44e91e34sm1445518lft.43.2023.02.28.11.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 11:44:19 -0800 (PST) To: Samuel Thibault , bug-hurd@gnu.org, libc-alpha@sourceware.org Cc: Sergey Bugaev Subject: [PATCH 2/2] hurd: Fix some broken indentation Date: Tue, 28 Feb 2023 22:44:09 +0300 Message-Id: <20230228194409.379949-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230228194409.379949-1-bugaevc@gmail.com> References: <20230228194409.379949-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Also, fix a couple of typos. No functional change. Signed-off-by: Sergey Bugaev --- hurd/hurdsig.c | 93 +++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 3e759ae5..1c85b29f 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -202,7 +202,7 @@ _hurd_sigstate_unlock (struct hurd_sigstate *ss) } libc_hidden_def (_hurd_sigstate_set_global_rcv) -/* Retreive a thread's full set of pending signals, including the global +/* Retrieve a thread's full set of pending signals, including the global ones if appropriate. SS must be locked. */ sigset_t _hurd_sigstate_pending (const struct hurd_sigstate *ss) @@ -233,7 +233,7 @@ sigstate_clear_pending (struct hurd_sigstate *ss, int signo) libc_hidden_def (_hurd_sigstate_lock) libc_hidden_def (_hurd_sigstate_unlock) -/* Retreive a thread's action vector. SS must be locked. */ +/* Retrieve a thread's action vector. SS must be locked. */ struct sigaction * _hurd_sigstate_actions (struct hurd_sigstate *ss) { @@ -434,50 +434,51 @@ _hurdsig_abort_rpcs (struct hurd_sigstate *ss, int signo, int sigthread, return value register indicates what state the RPC was in when interrupted. */ && state->basic.SYSRETURN == MACH_RCV_INTERRUPTED) - { - /* The RPC request message was sent and the thread was waiting for - the reply message; now the message receive has been aborted, so - the mach_msg call will return MACH_RCV_INTERRUPTED. We must tell - the server to interrupt the pending operation. The thread must - wait for the reply message before running the signal handler (to - guarantee that the operation has finished being interrupted), so - our nonzero return tells the trampoline code to finish the message - receive operation before running the handler. */ - - mach_port_t *reply = interrupted_reply_port_location (ss->thread, - state, - sigthread); - error_t err = __interrupt_operation (intr_port, _hurdsig_interrupt_timeout); - - if (err) - { - if (reply) - { - /* The interrupt didn't work. - Destroy the receive right the thread is blocked on. */ - __mach_port_destroy (__mach_task_self (), *reply); - *reply = MACH_PORT_NULL; - } - - /* The system call return value register now contains - MACH_RCV_INTERRUPTED; when mach_msg resumes, it will retry the - call. Since we have just destroyed the receive right, the - retry will fail with MACH_RCV_INVALID_NAME. Instead, just - change the return value here to EINTR so mach_msg will not - retry and the EINTR error code will propagate up. */ - state->basic.SYSRETURN = EINTR; - *state_change = 1; - } - else if (reply) - rcv_port = *reply; - - /* All threads whose RPCs were interrupted by the interrupt_operation - call above will retry their RPCs unless we clear SS->intr_port. - So we clear it for the thread taking a signal when SA_RESTART is - clear, so that its call returns EINTR. */ - if (! signo || !(_hurd_sigstate_actions (ss) [signo].sa_flags & SA_RESTART)) - ss->intr_port = MACH_PORT_NULL; - } + { + /* The RPC request message was sent and the thread was waiting for the + reply message; now the message receive has been aborted, so the + mach_msg call will return MACH_RCV_INTERRUPTED. We must tell the + server to interrupt the pending operation. The thread must wait for + the reply message before running the signal handler (to guarantee that + the operation has finished being interrupted), so our nonzero return + tells the trampoline code to finish the message receive operation + before running the handler. */ + + mach_port_t *reply = interrupted_reply_port_location (ss->thread, + state, + sigthread); + error_t err = __interrupt_operation (intr_port, + _hurdsig_interrupt_timeout); + + if (err) + { + if (reply) + { + /* The interrupt didn't work. + Destroy the receive right the thread is blocked on. */ + __mach_port_destroy (__mach_task_self (), *reply); + *reply = MACH_PORT_NULL; + } + + /* The system call return value register now contains + MACH_RCV_INTERRUPTED; when mach_msg resumes, it will retry the + call. Since we have just destroyed the receive right, the retry + will fail with MACH_RCV_INVALID_NAME. Instead, just change the + return value here to EINTR so mach_msg will not retry and the + EINTR error code will propagate up. */ + state->basic.SYSRETURN = EINTR; + *state_change = 1; + } + else if (reply) + rcv_port = *reply; + + /* All threads whose RPCs were interrupted by the interrupt_operation + call above will retry their RPCs unless we clear SS->intr_port. So we + clear it for the thread taking a signal when SA_RESTART is clear, so + that its call returns EINTR. */ + if (! signo || !(_hurd_sigstate_actions (ss) [signo].sa_flags & SA_RESTART)) + ss->intr_port = MACH_PORT_NULL; + } return rcv_port; }