diff options
Diffstat (limited to 'indra/llmessage/lliosocket.h')
-rw-r--r-- | indra/llmessage/lliosocket.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h index f0a6f25657..be0f7dfcc6 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. @@ -133,12 +146,6 @@ public: apr_socket_t* getSocket() const { return mSocket; } /** - * @brief Protected constructor since should only make sockets - * with one of the two <code>create()</code> calls. - */ - LLSocket(void); - - /** * @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. @@ -167,8 +174,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 +300,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 +332,7 @@ protected: //@} protected: + apr_pool_t* mPool; socket_t mListenSocket; factory_t mReactor; bool mInitialized; @@ -358,7 +366,8 @@ public: */ LLIODataSocket( U16 suggested_port, - U16 start_discovery_port); + U16 start_discovery_port, + apr_pool_t* pool); virtual ~LLIODataSocket(); protected: |