From: Pascal Obry Date: Thu, 24 Mar 2022 10:30:05 +0000 (+0100) Subject: Properly reset the port handle when closing X-Git-Tag: releases/gcc-10.4.0~360 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d800a6f6c03e404a5f033299d9fd1c5caa3b7738;p=thirdparty%2Fgcc.git 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 --git a/gcc/ada/libgnat/g-sercom__linux.adb b/gcc/ada/libgnat/g-sercom__linux.adb index 87143e235312..aa3c01342228 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 d5e2344524f4..51fc0ac89535 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");