diff options
author | Kyle Fox <kylefox2@illinois.edu> | 2013-04-11 16:25:04 -0500 |
---|---|---|
committer | Pekka Lampila <pekka.lampila@iki.fi> | 2013-12-06 03:55:58 +0200 |
commit | 8511db5fb3becc41fa4d8e8d2015b06f7e56e112 (patch) | |
tree | 624722aa74cbebce68388fb927ef901c5f6de54b /crawl-ref/source/tileweb.cc | |
parent | d75cff3dac3bbe1633a5a764db8fc0922046461b (diff) | |
download | crawl-ref-8511db5fb3becc41fa4d8e8d2015b06f7e56e112.tar.gz crawl-ref-8511db5fb3becc41fa4d8e8d2015b06f7e56e112.zip |
Fix a crash when running a webtiles server in OS X.
Fixes #6083. The crash would occur when sending datagrams from crawl to
the python webserver. In OS X, there is very little space in memory to
send datagrams and drawing menus such as the list of commands would
exceed this memory. The crawl process would then die after receiving too
many ENOBUFS errors from sendto.
ENOBUFS will still occur unless we add artifical sleeps to the datagram
sending loop. Sleep responses to ENOBUFS have been changed to reduce the
lag this causes.
Diffstat (limited to 'crawl-ref/source/tileweb.cc')
-rw-r--r-- | crawl-ref/source/tileweb.cc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crawl-ref/source/tileweb.cc b/crawl-ref/source/tileweb.cc index 64b7d2d127..ae58af7acf 100644 --- a/crawl-ref/source/tileweb.cc +++ b/crawl-ref/source/tileweb.cc @@ -140,7 +140,8 @@ bool TilesFramework::initialise() int bufsize = 64 * 1024; if (setsockopt(m_sock, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize))) die("Can't set buffer size!"); - m_max_msg_size = bufsize; + // Need small maximum message size to avoid crashes in OS X + m_max_msg_size = 2048; if (m_await_connection) _await_connection(); @@ -205,8 +206,8 @@ void TilesFramework::finish_message() } else if (errno == ENOBUFS) { - // Wait for half a second, then try again - usleep(500 * 1000); + // Wait for up to half a second, then try again + usleep(retries <= 5 ? 500 * 1000 : 10 * 1000); } else die("Socket write error: %s", strerror(errno)); |