diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-10-03 10:04:27 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-10-03 10:04:27 +0200 |
commit | 3ada950b1073e2b45550378fcb563ab83943684b (patch) | |
tree | 7a65508dddfcf5173dca569b36d33f30549d1df5 /gcc/ada/g-socket.adb | |
parent | bd2e46c8255fad4e75e589b3286ead560e910b39 (diff) | |
download | gcc-3ada950b1073e2b45550378fcb563ab83943684b.zip gcc-3ada950b1073e2b45550378fcb563ab83943684b.tar.gz gcc-3ada950b1073e2b45550378fcb563ab83943684b.tar.bz2 |
[multiple changes]
2012-10-03 Yannick Moy <moy@adacore.com>
* checks.adb, sem_prag.adb, s-bignum.ads: Minor typo fixes.
2012-10-03 Thomas Quinot <quinot@adacore.com>
* g-socket.adb (Connect_Socket, version with timeout): When the
newly-connected socket is reported as available for writing, check
whether it has a pending asynchronous error prior to returning.
2012-10-03 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Check_Conformance): Additional info when subtype
conformance fails, due to a missing null exclusion indicatar in
a formal that must match a controlling access formal.
From-SVN: r192026
Diffstat (limited to 'gcc/ada/g-socket.adb')
-rw-r--r-- | gcc/ada/g-socket.adb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb index ac03f42..731919b 100644 --- a/gcc/ada/g-socket.adb +++ b/gcc/ada/g-socket.adb @@ -123,7 +123,7 @@ package body GNAT.Sockets is function Resolve_Error (Error_Value : Integer; From_Errno : Boolean := True) return Error_Type; - -- Associate an enumeration value (error_type) to en error value (errno). + -- Associate an enumeration value (error_type) to an error value (errno). -- From_Errno prevents from mixing h_errno with errno. function To_Name (N : String) return Name_Type; @@ -702,6 +702,13 @@ package body GNAT.Sockets is Req : Request_Type; -- Used to set Socket to non-blocking I/O + Conn_Err : aliased Integer; + -- Error status of the socket after completion of select(2) + + Res : C.int; + Conn_Err_Size : aliased C.int := Conn_Err'Size / 8; + -- For getsockopt(2) call + begin if Selector /= null and then not Is_Open (Selector.all) then raise Program_Error with "closed selector"; @@ -735,10 +742,32 @@ package body GNAT.Sockets is Selector => Selector, Status => Status); + -- Check error condition (the asynchronous connect may have terminated + -- with an error, e.g. ECONNREFUSED) if select(2) completed. + + if Status = Completed then + Res := C_Getsockopt + (C.int (Socket), SOSC.SOL_SOCKET, SOSC.SO_ERROR, + Conn_Err'Address, Conn_Err_Size'Access); + + if Res /= 0 then + Conn_Err := Socket_Errno; + end if; + + else + Conn_Err := 0; + end if; + -- Reset the socket to blocking I/O Req := (Name => Non_Blocking_IO, Enabled => False); Control_Socket (Socket, Request => Req); + + -- Report error condition if any + + if Conn_Err /= 0 then + Raise_Socket_Error (Conn_Err); + end if; end Connect_Socket; -------------------- |