From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 35F923858C2C; Thu, 24 Mar 2022 10:34:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35F923858C2C MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10511] Properly reset the port handle when closing X-Act-Checkin: gcc X-Git-Author: Pascal Obry X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: aeb06b4fd1ed685fc7ad67d6118457cd4a00b292 X-Git-Newrev: d800a6f6c03e404a5f033299d9fd1c5caa3b7738 Message-Id: <20220324103439.35F923858C2C@sourceware.org> Date: Thu, 24 Mar 2022 10:34:39 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 10:34:39 -0000 https://gcc.gnu.org/g:d800a6f6c03e404a5f033299d9fd1c5caa3b7738 commit r10-10511-gd800a6f6c03e404a5f033299d9fd1c5caa3b7738 Author: Pascal Obry Date: Thu Mar 24 11:30:05 2022 +0100 Properly reset the port handle when closing When the serial port is closed, we need to ensure that the port handle is properly reset for it to be detected as closed. gcc/ada/ PR ada/104767 * libgnat/g-sercom__mingw.adb (Close): Reset port handle to -1. * libgnat/g-sercom__linux.adb (Close): Likewise. Diff: --- gcc/ada/libgnat/g-sercom__linux.adb | 1 + gcc/ada/libgnat/g-sercom__mingw.adb | 1 + 2 files changed, 2 insertions(+) diff --git a/gcc/ada/libgnat/g-sercom__linux.adb b/gcc/ada/libgnat/g-sercom__linux.adb index 87143e23531..aa3c0134222 100644 --- a/gcc/ada/libgnat/g-sercom__linux.adb +++ b/gcc/ada/libgnat/g-sercom__linux.adb @@ -318,6 +318,7 @@ package body GNAT.Serial_Communications is begin if Port.H /= -1 then Res := close (int (Port.H)); + Port.H := -1; end if; end Close; diff --git a/gcc/ada/libgnat/g-sercom__mingw.adb b/gcc/ada/libgnat/g-sercom__mingw.adb index d5e2344524f..51fc0ac8953 100644 --- a/gcc/ada/libgnat/g-sercom__mingw.adb +++ b/gcc/ada/libgnat/g-sercom__mingw.adb @@ -70,6 +70,7 @@ package body GNAT.Serial_Communications is begin if Port.H /= -1 then Success := CloseHandle (HANDLE (Port.H)); + Port.H := -1; if Success = Win32.FALSE then Raise_Error ("error closing the port");