Skip to content

Commit

Permalink
Abort failed TCP_CORK experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorycollins committed May 18, 2010
1 parent 9a86058 commit 6884408
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 87 deletions.
3 changes: 0 additions & 3 deletions src/Snap/Internal/Http/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,11 @@ httpServe bindAddress bindPort localHostname alogPath elogPath handler =
let rport = Backend.getRemotePort conn
let laddr = Backend.getLocalAddr conn
let lport = Backend.getLocalPort conn
Backend.cork conn

runHTTP localHostname laddr lport raddr rport
alog elog readEnd writeEnd (Backend.sendFile conn)
handler

Backend.uncork conn

debug "Server.httpServe.runHTTP: finished"


Expand Down
42 changes: 0 additions & 42 deletions src/Snap/Internal/Http/Server/LibevBackend.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ module Snap.Internal.Http.Server.LibevBackend
, getRemotePort
, getLocalAddr
, getLocalPort
, cork
, uncork
) where

---------------------------
Expand Down Expand Up @@ -58,46 +56,6 @@ import Snap.Iteratee
import Snap.Internal.Debug


#if defined(LINUX)

# include <netinet/tcp.h>

solTCP, tcpCork, tcpNoDelay :: CInt

tcpCork = #const TCP_CORK
solTCP = #const SOL_TCP
tcpNoDelay = #const TCP_NODELAY

foreign import ccall unsafe "setsockopt"
setsockopt :: CInt -> CInt -> CInt -> Ptr CInt -> CInt -> IO ()

cork :: Connection -> IO ()
cork conn = do
let fd = _socketFd conn
alloca $ \ptr -> do
poke ptr 0
setsockopt fd solTCP tcpNoDelay ptr $ toEnum $ sizeOf (0::CInt)
poke ptr 1
setsockopt fd solTCP tcpCork ptr $ toEnum $ sizeOf (0::CInt)

uncork :: Connection -> IO ()
uncork conn = do
let fd = _socketFd conn
alloca $ \ptr -> do
poke ptr 0
setsockopt fd solTCP tcpCork ptr $ toEnum $ sizeOf (0::CInt)
poke ptr 1
setsockopt fd solTCP tcpNoDelay ptr $ toEnum $ sizeOf (0::CInt)

#else
uncork :: Connection -> IO ()
uncork = const $ return ()

cork :: Connection -> IO ()
cork = const $ return ()
#endif


data Backend = Backend
{ _acceptSocket :: Socket
, _acceptFd :: CInt
Expand Down
42 changes: 0 additions & 42 deletions src/Snap/Internal/Http/Server/SimpleBackend.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ module Snap.Internal.Http.Server.SimpleBackend
, getRemotePort
, getLocalAddr
, getLocalPort
, cork
, uncork
) where

------------------------------------------------------------------------------
Expand Down Expand Up @@ -64,46 +62,6 @@ foreign import ccall unsafe "set_fd_timeout"
set_fd_timeout :: CInt -> IO ()


#if defined(LINUX)

# include <netinet/tcp.h>

solTCP, tcpCork, tcpNoDelay :: CInt

tcpCork = #const TCP_CORK
solTCP = #const SOL_TCP
tcpNoDelay = #const TCP_NODELAY

foreign import ccall unsafe "setsockopt"
setsockopt :: CInt -> CInt -> CInt -> Ptr CInt -> CInt -> IO ()

cork :: Connection -> IO ()
cork conn = do
let fd = fdSocket $ _socket conn
alloca $ \ptr -> do
poke ptr 0
setsockopt fd solTCP tcpNoDelay ptr $ toEnum $ sizeOf (0::CInt)
poke ptr 1
setsockopt fd solTCP tcpCork ptr $ toEnum $ sizeOf (0::CInt)

uncork :: Connection -> IO ()
uncork conn = do
let fd = fdSocket $ _socket conn
alloca $ \ptr -> do
poke ptr 0
setsockopt fd solTCP tcpCork ptr $ toEnum $ sizeOf (0::CInt)
poke ptr 1
setsockopt fd solTCP tcpNoDelay ptr $ toEnum $ sizeOf (0::CInt)

#else
uncork :: Connection -> IO ()
uncork = const $ return ()

cork :: Connection -> IO ()
cork = const $ return ()
#endif


data Backend = Backend
{ _acceptSocket :: Socket }

Expand Down

0 comments on commit 6884408

Please sign in to comment.