]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Properly reset the port handle when closing
authorPascal Obry <obry@adacore.com>
Thu, 24 Mar 2022 10:30:05 +0000 (11:30 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Thu, 24 Mar 2022 10:34:28 +0000 (11:34 +0100)
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.

gcc/ada/libgnat/g-sercom__linux.adb
gcc/ada/libgnat/g-sercom__mingw.adb

index 87143e23531285c929a744c94ff7f0573998a1a7..aa3c013422289b1fa7d1aacf80b6ff69221bfd0d 100644 (file)
@@ -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;
 
index d5e2344524f4defe20bf63c19b0d49393a783315..51fc0ac895351d1332b2bbdb3ec201c81fe6fd87 100644 (file)
@@ -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");