diff options
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/g-socthi-mingw.adb | 19 |
2 files changed, 21 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 01b0076807b..94c025b310c 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2010-06-22 Pascal Obry <obry@adacore.com> + + * g-socthi-mingw.adb: Properly honor MSG_WAITALL in recvmsg. + (C_Recvmsg): Propely honor the MSG_WAITALL flag in Windows + recvmsg emulation. + 2010-06-22 Robert Dewar <dewar@adacore.com> * sem_ch4.adb (Analyze_Conditional_Expression): Defend against diff --git a/gcc/ada/g-socthi-mingw.adb b/gcc/ada/g-socthi-mingw.adb index 6d7ca23f0b8..f1c8edd1e1c 100644 --- a/gcc/ada/g-socthi-mingw.adb +++ b/gcc/ada/g-socthi-mingw.adb @@ -276,6 +276,10 @@ package body GNAT.Sockets.Thin is is use type C.size_t; + Fill : constant Boolean := + (C.unsigned (Flags) and SOSC.MSG_WAITALL) /= 0; + -- Is the MSG_WAITALL flag set? If so we need to fully fill all vectors + Res : C.int; Count : C.int := 0; @@ -327,7 +331,7 @@ package body GNAT.Sockets.Thin is if Res < 0 then return System.CRTL.ssize_t (Res); - elsif Res = 0 then + elsif Res = 0 and then not Fill then exit; else @@ -342,9 +346,16 @@ package body GNAT.Sockets.Thin is -- If all the data that was initially available read, do not -- attempt to receive more, since this might block, or merge data - -- from successive datagrams for a datagram-oriented socket. - - exit when Natural (Count) >= Req.Size; + -- from successive datagrams for a datagram-oriented + -- socket. We still try to receive more if we need to fill all + -- vectors (MSG_WAITALL flag is set). + + exit when Natural (Count) >= Req.Size + and then + (not Fill -- either we are not in fill mode + or else -- or last vector filled + (Interfaces.C.size_t (Iov_Index) = Iovec'Last + and then Current_Iovec.Length = 0)); end if; end loop; |