diff options
author | Squire <squire@lindenlab.com> | 2011-06-28 11:55:27 -0700 |
---|---|---|
committer | Squire <squire@lindenlab.com> | 2011-06-28 11:55:27 -0700 |
commit | 7db0cdefe044ce61f35de1ea421f0f5fb3fc09bf (patch) | |
tree | e3f74b73bf58d7ba56571e57ba70b72f39d8b038 | |
parent | 03969822f5cff99c124772466bf4e86da9fa05aa (diff) | |
parent | c91d6962337e3394038d72b173431dceffb44317 (diff) |
STORM-1447, STORM-1446
merged from
https://bitbucket.org/stone_linden/viewer-development-storm-1368
-rw-r--r-- | autobuild.xml | 15 | ||||
-rw-r--r-- | indra/llmessage/lliosocket.cpp | 26 | ||||
-rw-r--r-- | indra/llmessage/lliosocket.h | 11 |
3 files changed, 33 insertions, 19 deletions
diff --git a/autobuild.xml b/autobuild.xml index 63701dae79..d1a7107319 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -1907,11 +1907,8 @@ <map> <key>build</key> <map> - <key>arguments</key> + <key>filters</key> <array> - <string>|</string> - <string>grep</string> - <string>-v</string> <string>setenv</string> </array> <key>command</key> @@ -1964,11 +1961,8 @@ <map> <key>build</key> <map> - <key>arguments</key> + <key>filters</key> <array> - <string>|</string> - <string>grep</string> - <string>-v</string> <string>setenv</string> </array> <key>command</key> @@ -2023,11 +2017,8 @@ <map> <key>build</key> <map> - <key>arguments</key> + <key>filters</key> <array> - <string>|</string> - <string>grep</string> - <string>-v</string> <string>setenv</string> </array> <key>command</key> diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index ca84fa8bb8..8c752fbe30 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -191,7 +191,7 @@ LLSocket::ptr_t LLSocket::create(apr_pool_t* pool, EType type, U16 port) port = PORT_EPHEMERAL; } rv->mPort = port; - rv->setOptions(); + rv->setNonBlocking(); return rv; } @@ -206,7 +206,7 @@ LLSocket::ptr_t LLSocket::create(apr_socket_t* socket, apr_pool_t* pool) } rv = ptr_t(new LLSocket(socket, pool)); rv->mPort = PORT_EPHEMERAL; - rv->setOptions(); + rv->setNonBlocking(); return rv; } @@ -227,10 +227,10 @@ bool LLSocket::blockingConnect(const LLHost& host) { return false; } - apr_socket_timeout_set(mSocket, 1000); + setBlocking(1000); ll_debug_socket("Blocking connect", mSocket); if(ll_apr_warn_status(apr_socket_connect(mSocket, sa))) return false; - setOptions(); + setNonBlocking(); return true; } @@ -258,11 +258,27 @@ LLSocket::~LLSocket() } } -void LLSocket::setOptions() +// See http://dev.ariel-networks.com/apr/apr-tutorial/html/apr-tutorial-13.html#ss13.4 +// for an explanation of how to get non-blocking sockets and timeouts with +// consistent behavior across platforms. + +void LLSocket::setBlocking(S32 timeout) +{ + LLMemType m1(LLMemType::MTYPE_IO_TCP); + // set up the socket options + ll_apr_warn_status(apr_socket_timeout_set(mSocket, timeout)); + ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_NONBLOCK, 0)); + ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_SNDBUF, LL_SEND_BUFFER_SIZE)); + ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_RCVBUF, LL_RECV_BUFFER_SIZE)); + +} + +void LLSocket::setNonBlocking() { LLMemType m1(LLMemType::MTYPE_IO_TCP); // set up the socket options ll_apr_warn_status(apr_socket_timeout_set(mSocket, 0)); + ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_NONBLOCK, 1)); ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_SNDBUF, LL_SEND_BUFFER_SIZE)); ll_apr_warn_status(apr_socket_opt_set(mSocket, APR_SO_RCVBUF, LL_RECV_BUFFER_SIZE)); diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h index 6806e5084a..e0f6c1e34d 100644 --- a/indra/llmessage/lliosocket.h +++ b/indra/llmessage/lliosocket.h @@ -153,9 +153,16 @@ protected: LLSocket(apr_socket_t* socket, apr_pool_t* pool); /** - * @brief Set default socket options. + * @brief Set default socket options, with SO_NONBLOCK = 0 and a timeout in us. + * @param timeout Number of microseconds to wait on this socket. Any + * negative number means block-forever. TIMEOUT OF 0 IS NON-PORTABLE. */ - void setOptions(); + void setBlocking(S32 timeout); + + /** + * @brief Set default socket options, with SO_NONBLOCK = 1 and timeout = 0. + */ + void setNonBlocking(); public: /** |