summaryrefslogtreecommitdiff
blob: e891831aeef440c0020d089ef42bde17192ee516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
commit 6bc6b666ba2a87001a825bd81088062307a51bae
Author: Sergei Trofimovich <slyfox@gentoo.org>
Date:   Sun Jan 13 23:50:21 2013 +0300

    MsgHdr.hsc: fix field 'struct msghdr::msg_namelen' size
    
    msg_namelen has a 'socklen_t' type on linux (always 32 bits).
    Using CSize there breaks 64-bit BE platforms.
    
      testSendManyTo: [Failed]
           ERROR: sendmsg: invalid argument (Destination address required)
    
    Caught by testSendManyTo test on ppc64:
    
    Gentoo-bug: http://bugs.gentoo.org/436640
    Reported-by: Anthony Basile <blueness@gentoo.org>
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

diff --git a/Network/Socket/ByteString/MsgHdr.hsc b/Network/Socket/ByteString/MsgHdr.hsc
index 24d7eb0..227e5ee 100644
--- a/Network/Socket/ByteString/MsgHdr.hsc
+++ b/Network/Socket/ByteString/MsgHdr.hsc
@@ -8,6 +8,7 @@ module Network.Socket.ByteString.MsgHdr
 #include <sys/types.h>
 #include <sys/socket.h>
 
+import Data.Word -- for used '#type's
 import Foreign.C.Types (CInt, CSize)
 import Foreign.Ptr (Ptr)
 import Foreign.Storable (Storable(..))
@@ -20,7 +21,7 @@ import Network.Socket.ByteString.IOVec (IOVec)
 -- don't exist on OpenSolaris.
 data MsgHdr = MsgHdr
     { msgName    :: Ptr SockAddr
-    , msgNameLen :: CSize
+    , msgNameLen :: (#type socklen_t) {- 32 bits even on amd64 and ppc64 -}
     , msgIov     :: Ptr IOVec
     , msgIovLen  :: CSize
     }