ASF Bugzilla – Attachment 20599 Details for
Bug 43035
Add ability to wrap ssl around pre-existing sockets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Adds ability to wrap ssl around pre-existing sockets
patch.txt (text/plain), 4.76 KB, created by
Nathan Mittler
on 2007-08-04 13:06:30 UTC
(
hide
)
Description:
Adds ability to wrap ssl around pre-existing sockets
Filename:
MIME Type:
Creator:
Nathan Mittler
Created:
2007-08-04 13:06:30 UTC
Size:
4.76 KB
patch
obsolete
>Index: /Users/nmittler/workspace/apr-util/include/apr_ssl.h >=================================================================== >--- /Users/nmittler/workspace/apr-util/include/apr_ssl.h (revision 562748) >+++ /Users/nmittler/workspace/apr-util/include/apr_ssl.h (working copy) >@@ -110,7 +110,29 @@ > int, int, int, > apr_ssl_factory_t *, > apr_pool_t *); >+ > /** >+ * @fn apr_status_t apr_ssl_socket_create_wrapper(apr_ssl_socket_t **newSock, >+ apr_socket_t *plain, >+ int ownSocket, >+ apr_ssl_factory_t *factory, >+ apr_pool_t *pool) >+ * @brief Create an ssl socket that wraps around another apr_socket_t. >+ * @param newSock The new ssl socket that has been set up. >+ * @param plain The plain socket that the ssl socket is to wrap around. >+ * @param ownSocket Flag to control lifetime of plain socket. (0=do not control lifetime) >+ * @param factory The factory that it will be produced from >+ * @param pool The pool for the apr_socket_t and associated storage. >+ * @return APR_SUCCESS on succesful creation. >+ * @see apr_socket_create >+ */ >+APU_DECLARE(apr_status_t) apr_ssl_socket_create_wrapper(apr_ssl_socket_t **, >+ apr_socket_t *, >+ int, >+ apr_ssl_factory_t *, >+ apr_pool_t *); >+ >+/** > * @fn apr_status_t apr_ssl_socket_close(apr_ssl_socket_t *sock) > * @brief Close a socket. This terminates the SSL connections as well > * as closing the system socket. >Index: /Users/nmittler/workspace/apr-util/include/private/apr_ssl_private.h >=================================================================== >--- /Users/nmittler/workspace/apr-util/include/private/apr_ssl_private.h (revision 562748) >+++ /Users/nmittler/workspace/apr-util/include/private/apr_ssl_private.h (working copy) >@@ -50,6 +50,7 @@ > struct apr_ssl_socket { > apr_pool_t *pool; /**< pool to use for memory allocations */ > apr_socket_t *plain; /**< the apr_socket_t we're based on (if required) */ >+ int ownSocket; /**< flag to determine if controlling the lifetime of plain */ > apr_ssl_factory_t *factory; /**< pointer to the factory we were created from */ > apr_pollset_t *pollset; /**< pollset */ > apr_pollfd_t *poll; /**< poll fd */ >Index: /Users/nmittler/workspace/apr-util/ssl/apr_ssl_socket.c >=================================================================== >--- /Users/nmittler/workspace/apr-util/ssl/apr_ssl_socket.c (revision 562748) >+++ /Users/nmittler/workspace/apr-util/ssl/apr_ssl_socket.c (working copy) >@@ -60,6 +60,7 @@ > != APR_SUCCESS) { > return -1; > } >+ sslSock->ownSocket = 1; > sslSock->pool = thepool; > sslSock->factory = asf; > if (apu_ssl_socket_create(sslSock, asf) != APR_SUCCESS) { >@@ -71,6 +72,43 @@ > return APR_SUCCESS; > } > >+APU_DECLARE(apr_status_t) apr_ssl_socket_create_wrapper(apr_ssl_socket_t **sock, >+ apr_socket_t *plain, >+ int own_socket, >+ apr_ssl_factory_t *asf, >+ apr_pool_t *p) >+{ >+ apr_ssl_socket_t *sslSock; >+ apr_pool_t *thepool; >+ >+ if (!asf) >+ return -1; >+ >+ if (!plain) >+ return -1; >+ >+ thepool = p ? p : asf->pool; >+ if (!thepool) >+ return APR_ENOPOOL; >+ >+ sslSock = apr_pcalloc(thepool, sizeof(*sslSock)); >+ if (!sslSock) >+ return ENOMEM; >+ >+ sslSock->plain = plain; >+ sslSock->ownSocket = own_socket; >+ sslSock->pool = thepool; >+ sslSock->factory = asf; >+ if (apu_ssl_socket_create(sslSock, asf) != APR_SUCCESS) { >+ if( sslSock->ownSocket ) >+ apr_socket_close(sslSock->plain); >+ return -1; >+ } >+ >+ *sock = sslSock; >+ return APR_SUCCESS; >+} >+ > APU_DECLARE(apr_status_t) apr_ssl_socket_close(apr_ssl_socket_t *sock) > { > apr_status_t rv; >@@ -79,7 +117,11 @@ > > if ((rv = apu_ssl_socket_close(sock)) != APR_SUCCESS) > return rv; >- return apr_socket_close(sock->plain); >+ >+ if( sock->ownSocket ) >+ return apr_socket_close(sock->plain); >+ >+ return APR_SUCCESS; > } > > APU_DECLARE(apr_status_t) apr_ssl_socket_connect(apr_ssl_socket_t *sock,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 43035
: 20599