work around strange endianness bug in port number on Android
This commit is contained in:
parent
b0a6aa42b1
commit
f7d2523adc
3 changed files with 20 additions and 1 deletions
|
@ -36,6 +36,9 @@ import Blaze.ByteString.Builder (Builder)
|
|||
import Data.Monoid
|
||||
import Control.Arrow ((***))
|
||||
import Control.Concurrent
|
||||
#ifdef __ANDROID__
|
||||
import Data.Endian
|
||||
#endif
|
||||
|
||||
localhost :: HostName
|
||||
localhost = "localhost"
|
||||
|
@ -63,7 +66,16 @@ runWebApp :: Maybe HostName -> Wai.Application -> (SockAddr -> IO ()) -> IO ()
|
|||
runWebApp h app observer = do
|
||||
sock <- getSocket h
|
||||
void $ forkIO $ runSettingsSocket webAppSettings sock app
|
||||
observer =<< getSocketName sock
|
||||
sockaddr <- fixSockAddr <$> getSocketName sock
|
||||
observer sockaddr
|
||||
|
||||
fixSockAddr :: SockAddr -> SockAddr
|
||||
#ifdef __ANDROID__
|
||||
{- On Android, the port is currently incorrectly returned in network
|
||||
- byte order, which is wrong on little endian systems. -}
|
||||
fixSockAddr (SockAddrInet (PortNum port) addr) = SockAddrInet (PortNum $ swapEndian port) addr
|
||||
#endif
|
||||
fixSockAddr addr = addr
|
||||
|
||||
webAppSettings :: Settings
|
||||
webAppSettings = defaultSettings
|
||||
|
|
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -1,3 +1,9 @@
|
|||
git-annex (4.20130502) UNRELEASED; urgency=low
|
||||
|
||||
* Android: The webapp is ported and working.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Thu, 02 May 2013 20:39:19 -0400
|
||||
|
||||
git-annex (4.20130501) unstable; urgency=low
|
||||
|
||||
* sync, assistant: Behavior changes: Sync with remotes that have
|
||||
|
|
|
@ -100,6 +100,7 @@ Executable git-annex
|
|||
CPP-Options: -DWITH_ASSISTANT
|
||||
|
||||
if flag(Android)
|
||||
Build-Depends: data-endian
|
||||
CPP-Options: -D__ANDROID__
|
||||
|
||||
if os(linux) && flag(Inotify)
|
||||
|
|
Loading…
Reference in a new issue