diff options
author | Andrew Stitcher <astitcher@apache.org> | 2012-10-24 05:51:31 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2012-10-24 05:51:31 +0000 |
commit | 5d1d8481c376435051d5b24171dbb209c779b9ab (patch) | |
tree | da83a8d381028880ab45f6486ade1cf8baa096b3 /cpp/src/qpid/sys/ssl/SslSocket.cpp | |
parent | c61f7c0c79717b0eb842d0c4c88deeda9f7672e6 (diff) | |
download | qpid-python-5d1d8481c376435051d5b24171dbb209c779b9ab.tar.gz |
QPID-4272: Large amounts of code are duplicated between the SSL and TCP transports
Lift Socket into an interface with concrete implementations
- BSDSocket, WinSocket and SslSocket
- As a side effect completely change the approach we use for platform
specific handles: IOHandle now directly carries the platform handle
but its real type is only exposed to platform specific code.
- Modified RDMA code for the new IOHandle approach
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1401559 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/ssl/SslSocket.cpp')
-rw-r--r-- | cpp/src/qpid/sys/ssl/SslSocket.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/cpp/src/qpid/sys/ssl/SslSocket.cpp b/cpp/src/qpid/sys/ssl/SslSocket.cpp index 6b6f326492..22f9f63fff 100644 --- a/cpp/src/qpid/sys/ssl/SslSocket.cpp +++ b/cpp/src/qpid/sys/ssl/SslSocket.cpp @@ -98,16 +98,16 @@ SslSocket::SslSocket(const std::string& certName, bool clientAuth) : * returned from accept. Because we use posix accept rather than * PR_Accept, we have to reset the handshake. */ -SslSocket::SslSocket(IOHandlePrivate* ioph, PRFileDesc* model) : Socket(ioph), nssSocket(0), prototype(0) +SslSocket::SslSocket(int fd, PRFileDesc* model) : BSDSocket(fd), nssSocket(0), prototype(0) { - nssSocket = SSL_ImportFD(model, PR_ImportTCPSocket(impl->fd)); + nssSocket = SSL_ImportFD(model, PR_ImportTCPSocket(fd)); NSS_CHECK(SSL_ResetHandshake(nssSocket, PR_TRUE)); } void SslSocket::setNonblocking() const { if (!nssSocket) { - Socket::setNonblocking(); + BSDSocket::setNonblocking(); return; } PRSocketOptionData option; @@ -119,7 +119,7 @@ void SslSocket::setNonblocking() const void SslSocket::setTcpNoDelay() const { if (!nssSocket) { - Socket::setTcpNoDelay(); + BSDSocket::setTcpNoDelay(); return; } PRSocketOptionData option; @@ -130,9 +130,9 @@ void SslSocket::setTcpNoDelay() const void SslSocket::connect(const SocketAddress& addr) const { - Socket::connect(addr); + BSDSocket::connect(addr); - nssSocket = SSL_ImportFD(0, PR_ImportTCPSocket(impl->fd)); + nssSocket = SSL_ImportFD(0, PR_ImportTCPSocket(fd)); void* arg; // Use the connection's cert-name if it has one; else use global cert-name @@ -155,12 +155,12 @@ void SslSocket::connect(const SocketAddress& addr) const void SslSocket::close() const { if (!nssSocket) { - Socket::close(); + BSDSocket::close(); return; } - if (impl->fd > 0) { + if (fd > 0) { PR_Close(nssSocket); - impl->fd = -1; + fd = -1; } } @@ -176,15 +176,15 @@ int SslSocket::listen(const SocketAddress& sa, int backlog) const SECKEY_DestroyPrivateKey(key); CERT_DestroyCertificate(cert); - return Socket::listen(sa, backlog); + return BSDSocket::listen(sa, backlog); } -SslSocket* SslSocket::accept() const +Socket* SslSocket::accept() const { QPID_LOG(trace, "Accepting SSL connection."); - int afd = ::accept(impl->fd, 0, 0); + int afd = ::accept(fd, 0, 0); if ( afd >= 0) { - return new SslSocket(new IOHandlePrivate(afd), prototype); + return new SslSocket(afd, prototype); } else if (errno == EAGAIN) { return 0; } else { @@ -275,15 +275,15 @@ SslMuxSocket::SslMuxSocket(const std::string& certName, bool clientAuth) : Socket* SslMuxSocket::accept() const { - int afd = ::accept(impl->fd, 0, 0); + int afd = ::accept(fd, 0, 0); if (afd >= 0) { QPID_LOG(trace, "Accepting connection with optional SSL wrapper."); if (isSslStream(afd)) { QPID_LOG(trace, "Accepted SSL connection."); - return new SslSocket(new IOHandlePrivate(afd), prototype); + return new SslSocket(afd, prototype); } else { QPID_LOG(trace, "Accepted Plaintext connection."); - return new Socket(new IOHandlePrivate(afd)); + return new BSDSocket(afd); } } else if (errno == EAGAIN) { return 0; |