| 1 |
Description: Correctly retrieve the type of the socket |
| 2 |
On mips, `SOCK_STREAM` and `SOCK_DGRAM` have different values than on |
| 3 |
x86_64. Modify `getSockType` to use functions from the Network library |
| 4 |
to retrieve the type of the socket, instead of relying on hard-coded |
| 5 |
values. |
| 6 |
Author: Ilias Tsitsimpis <[email protected]> |
| 7 |
Bug: https://github.com/snapframework/io-streams-haproxy/issues/18 |
| 8 |
|
| 9 |
Index: b/src/System/IO/Streams/Network/HAProxy.hs |
| 10 |
=================================================================== |
| 11 |
--- a/src/System/IO/Streams/Network/HAProxy.hs |
| 12 |
+++ b/src/System/IO/Streams/Network/HAProxy.hs |
| 13 |
@@ -72,15 +72,8 @@ socketToProxyInfo s sa = do |
| 14 |
!sty <- getSockType |
| 15 |
return $! makeProxyInfo sa da (addrFamily sa) sty |
| 16 |
where |
| 17 |
-#if MIN_VERSION_network(2,7,0) |
| 18 |
- getSockType = do |
| 19 |
- c <- N.getSocketOption s N.Type |
| 20 |
- -- This is a kludge until network has better support for returning |
| 21 |
- -- SocketType |
| 22 |
- case c of |
| 23 |
- 1 -> return N.Stream |
| 24 |
- 2 -> return N.Datagram |
| 25 |
- _ -> error ("bad socket type: " ++ show c) |
| 26 |
+#if MIN_VERSION_network(3,0,1) |
| 27 |
+ getSockType = N.getSocketType s |
| 28 |
#else |
| 29 |
getSockType = let (N.MkSocket _ _ sty _ _) = s in return sty |
| 30 |
#endif |