THREAD_PROC ThreadedSSLSocketInitiator::socketThread(void *p) { ThreadPair *pair = reinterpret_cast< ThreadPair * >(p); ThreadedSSLSocketInitiator *pInitiator = pair->first; ThreadedSSLSocketConnection *pConnection = pair->second; FIX::SessionID sessionID = pConnection->getSession()->getSessionID(); FIX::Session *pSession = FIX::Session::lookupSession(sessionID); int socket = pConnection->getSocket(); delete pair; pInitiator->lock(); if (!pConnection->connect()) { pInitiator->getLog()->onEvent("Connection failed"); pConnection->disconnect(); SSL *ssl = pConnection->sslObject(); delete pConnection; pInitiator->removeThread(SocketKey(socket, ssl)); pInitiator->setDisconnected(sessionID); return 0; } // Do the SSL handshake. int rc = SSL_connect(pConnection->sslObject()); if (rc <= 0) { int err = SSL_get_error(pConnection->sslObject(), rc); pInitiator->getLog()->onEvent("SSL_connect failed with SSL error " + IntConvertor::convert(err)); pConnection->disconnect(); SSL *ssl = pConnection->sslObject(); delete pConnection; pInitiator->removeThread(SocketKey(socket, ssl)); pInitiator->setDisconnected(sessionID); return 0; } pInitiator->setConnected(sessionID); pInitiator->getLog()->onEvent("Connection succeeded"); pSession->next(); while (pConnection->read()) { } SSL *ssl = pConnection->sslObject(); delete pConnection; if (!pInitiator->isStopped()) pInitiator->removeThread(SocketKey(socket, ssl)); pInitiator->setDisconnected(sessionID); return 0; }
THREAD_PROC ThreadedSocketInitiator::socketThread( void* p ) { ThreadPair * pair = reinterpret_cast < ThreadPair* > ( p ); ThreadedSocketInitiator* pInitiator = pair->first; ThreadedSocketConnection* pConnection = pair->second; FIX::SessionID sessionID = pConnection->getSession()->getSessionID(); FIX::Session* pSession = FIX::Session::lookupSession( sessionID ); int socket = pConnection->getSocket(); delete pair; pInitiator->lock(); if( !pConnection->connect() ) { pInitiator->getLog()->onEvent( "Connection failed" ); pConnection->disconnect(); delete pConnection; pInitiator->removeThread( socket ); pInitiator->setDisconnected( sessionID ); return 0; } pInitiator->setConnected( sessionID ); pInitiator->getLog()->onEvent( "Connection succeeded" ); pSession->next(); while ( pConnection->read() ) {} delete pConnection; if( !pInitiator->isStopped() ) pInitiator->removeThread( socket ); pInitiator->setDisconnected( sessionID ); return 0; }