diff options
author | Dave Parks <davep@lindenlab.com> | 2011-10-14 11:58:35 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2011-10-14 11:58:35 -0500 |
commit | c0ca8e5e2e4d3f591db3175f09c0b64b6b2e10c5 (patch) | |
tree | 28ea7a212319b0bd452c68e54f374904bfe6ed8a /indra/llmessage/lliosocket.h | |
parent | fc2929bf4f6366c3a3386e4b79b0fda7bd0466ba (diff) | |
parent | 4331c112aba074562e9a8826fe6d271a94f790f0 (diff) |
Merge backout of b782a75c99e6
Diffstat (limited to 'indra/llmessage/lliosocket.h')
-rw-r--r-- | indra/llmessage/lliosocket.h | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h index f0a6f25657..d8ee4e9f98 100644 --- a/indra/llmessage/lliosocket.h +++ b/indra/llmessage/lliosocket.h @@ -38,6 +38,7 @@ */ #include "lliopipe.h" +#include "apr_pools.h" #include "apr_network_io.h" #include "llchainio.h" @@ -87,22 +88,34 @@ public: * socket. If you intend the socket to be known to external * clients without prior port notification, do not use * PORT_EPHEMERAL. + * @param pool The apr pool to use. A child pool will be created + * and associated with the socket. * @param type The type of socket to create * @param port The port for the socket * @return A valid socket shared pointer if the call worked. */ static ptr_t create( + apr_pool_t* pool, EType type, U16 port = PORT_EPHEMERAL); /** - * @brief Create a LLSocket by accepting a connection from a listen socket. + * @brief Create a LLSocket when you already have an apr socket. * - * @param status Output. Status of the accept if a valid listen socket was passed. - * @param listen_socket The listen socket to use. + * This method assumes an ephemeral port. This is typically used + * by calls which spawn a socket such as a call to + * <code>accept()</code> as in the server socket. This call should + * not fail if you have a valid apr socket. + * Because of the nature of how accept() works, you are expected + * to create a new pool for the socket, use that pool for the + * accept, and pass it in here where it will be bound with the + * socket and destroyed at the same time. + * @param socket The apr socket to use + * @param pool The pool used to create the socket. *NOTE: The pool + * passed in will be DESTROYED. * @return A valid socket shared pointer if the call worked. */ - static ptr_t create(apr_status_t& status, ptr_t& listen_socket); + static ptr_t create(apr_socket_t* socket, apr_pool_t* pool); /** * @brief Perform a blocking connect to a host. Do not use in production. @@ -136,7 +149,7 @@ public: * @brief Protected constructor since should only make sockets * with one of the two <code>create()</code> calls. */ - LLSocket(void); + LLSocket(apr_socket_t* socket, apr_pool_t* pool); /** * @brief Set default socket options, with SO_NONBLOCK = 0 and a timeout in us. @@ -167,8 +180,8 @@ protected: // The apr socket. apr_socket_t* mSocket; - // Our memory pool. - LLAPRPool mPool; + // our memory pool + apr_pool_t* mPool; // The port if we know it. U16 mPort; @@ -293,7 +306,7 @@ class LLIOServerSocket : public LLIOPipe public: typedef LLSocket::ptr_t socket_t; typedef boost::shared_ptr<LLChainIOFactory> factory_t; - LLIOServerSocket(socket_t listener, factory_t reactor); + LLIOServerSocket(apr_pool_t* pool, socket_t listener, factory_t reactor); virtual ~LLIOServerSocket(); /** @@ -325,6 +338,7 @@ protected: //@} protected: + apr_pool_t* mPool; socket_t mListenSocket; factory_t mReactor; bool mInitialized; @@ -358,7 +372,8 @@ public: */ LLIODataSocket( U16 suggested_port, - U16 start_discovery_port); + U16 start_discovery_port, + apr_pool_t* pool); virtual ~LLIODataSocket(); protected: |