diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-17 10:58:39 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-17 10:58:39 +0000 |
commit | 06adcb1917b58134f15abefb11e49fd495f26971 (patch) | |
tree | 3d9d7c3ec8096deb2b799c9a49cf0de08d755268 /gcc/ada | |
parent | 6064d1cdef16f2eaee2bb8860e45f26ecaa67382 (diff) | |
download | gcc-06adcb1917b58134f15abefb11e49fd495f26971.tar.gz |
2009-09-17 Bob Duff <duff@adacore.com>
* g-socket.ads: Document the fact that Close_Selector has no effect on
a closed selector.
* g-socket.adb: Raise an exception when a Selector that should be open
is closed.
(Check_Selector): Declare RSig as a constant rather than a renames,
less confusing.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151798 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/ada/g-socket.adb | 41 | ||||
-rw-r--r-- | gcc/ada/g-socket.ads | 3 |
3 files changed, 53 insertions, 3 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3ef5e6df5e0..1e4d3db4f95 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,7 +1,17 @@ +2009-09-17 Bob Duff <duff@adacore.com> + + * g-socket.ads: Document the fact that Close_Selector has no effect on + a closed selector. + * g-socket.adb: Raise an exception when a Selector that should be open + is closed. + (Check_Selector): Declare RSig as a constant rather than a renames, + less confusing. + 2009-09-17 Robert Dewar <dewar@adacore.com> * exp_ch9.adb, exp_ch5.adb, exp_ch4.adb, prj-conf.adb, prj-env.ads, - prj-ext.adb: Minor reformatting + prj-ext.adb, prj-ext.ads, prj-pars.adb, prj-part.adb, prj-proc.adb, + prj-tree.ads: Minor reformatting 2009-09-17 Emmanuel Briot <briot@adacore.com> diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb index d32ebfc37a8..8afde3beec3 100644 --- a/gcc/ada/g-socket.adb +++ b/gcc/ada/g-socket.adb @@ -282,6 +282,12 @@ package body GNAT.Sockets is Res : C.int; begin + if Selector.R_Sig_Socket = No_Socket + or else Selector.W_Sig_Socket = No_Socket + then + raise Program_Error with "closed selector"; + end if; + -- Send one byte to unblock select system call Res := Signalling_Fds.Write (C.int (Selector.W_Sig_Socket)); @@ -330,6 +336,14 @@ package body GNAT.Sockets is Status : out Selector_Status) is begin + if Selector /= null + and then (Selector.R_Sig_Socket = No_Socket + or else + Selector.W_Sig_Socket = No_Socket) + then + raise Program_Error with "closed selector"; + end if; + -- Wait for socket to become available for reading Wait_On_Socket @@ -473,11 +487,17 @@ package body GNAT.Sockets is is Res : C.int; Last : C.int; - RSig : Socket_Type renames Selector.R_Sig_Socket; + RSig : constant Socket_Type := Selector.R_Sig_Socket; TVal : aliased Timeval; TPtr : Timeval_Access; begin + if Selector.R_Sig_Socket = No_Socket + or else Selector.W_Sig_Socket = No_Socket + then + raise Program_Error with "closed selector"; + end if; + Status := Completed; -- No timeout or Forever is indicated by a null timeval pointer @@ -563,6 +583,12 @@ package body GNAT.Sockets is procedure Close_Selector (Selector : in out Selector_Type) is begin + if Selector.R_Sig_Socket = No_Socket + or else Selector.W_Sig_Socket = No_Socket + then + return; + end if; + -- Close the signalling file descriptors used internally for the -- implementation of Abort_Selector. @@ -636,6 +662,13 @@ package body GNAT.Sockets is -- Used to set Socket to non-blocking I/O begin + if Selector /= null and then + (Selector.R_Sig_Socket = No_Socket + or else Selector.W_Sig_Socket = No_Socket) + then + raise Program_Error with "closed selector"; + end if; + -- Set the socket to non-blocking I/O Req := (Name => Non_Blocking_IO, Enabled => True); @@ -727,6 +760,12 @@ package body GNAT.Sockets is Res : C.int; begin + if Selector.R_Sig_Socket /= No_Socket + or else Selector.W_Sig_Socket /= No_Socket + then + raise Program_Error with "selector already open"; + end if; + -- We open two signalling file descriptors. One of them is used to send -- data to the other, which is included in a C_Select socket set. The -- communication is used to force a call to C_Select to complete, and diff --git a/gcc/ada/g-socket.ads b/gcc/ada/g-socket.ads index a6445e044ad..39a917a5480 100644 --- a/gcc/ada/g-socket.ads +++ b/gcc/ada/g-socket.ads @@ -1072,7 +1072,8 @@ package GNAT.Sockets is -- Close Selector and all internal descriptors associated; deallocate any -- associated resources. This subprogram may be called only when there is -- no other task still using Selector (i.e. still executing Check_Selector - -- or Abort_Selector on this Selector). + -- or Abort_Selector on this Selector). Has no effect if Selector is + -- already closed. procedure Check_Selector (Selector : in out Selector_Type; |