|
|
@@ -268,27 +268,35 @@ void Receive() |
|
|
|
cout << SSL_state_string(handler.second) << endl;
|
|
|
|
{
|
|
|
|
lock_guard<mutex> lock(WriteReadMutex);
|
|
|
|
cout << "SSL_read: start" << endl;
|
|
|
|
len_rcv = SSL_read(handler.second, buf, 1024);
|
|
|
|
// cout << "SSL_read: stop" << endl;
|
|
|
|
if( !handle_error_code(len_rcv, handler.second, len_rcv, "rcv") )
|
|
|
|
int flag = 1;
|
|
|
|
while( flag!=0 )
|
|
|
|
{
|
|
|
|
// dirty thing - if it has \n on the end - remove it
|
|
|
|
if( buf[len_rcv-1] == '\n' )
|
|
|
|
buf[len_rcv-1] = '\0';
|
|
|
|
cout << "SSL_read: start" << endl;
|
|
|
|
len_rcv = SSL_read(handler.second, buf, 1024);
|
|
|
|
flag = SSL_pending(handler.second);
|
|
|
|
cout << "PENDING: " << flag << endl;
|
|
|
|
|
|
|
|
cout << buf << endl;
|
|
|
|
// cout << "SSL_read: stop" << endl;
|
|
|
|
if( !handle_error_code(len_rcv, handler.second, len_rcv, "rcv") )
|
|
|
|
{
|
|
|
|
// add it back to the socket so that select can use it
|
|
|
|
lock_guard<mutex> guard(SocketSetMutex);
|
|
|
|
SocketSet.insert(handler);
|
|
|
|
|
|
|
|
// push handler ID and notify sender thread
|
|
|
|
WriteHandler = handler;
|
|
|
|
WaitForWrite.notify_one();
|
|
|
|
// dirty thing - if it has \n on the end - remove it
|
|
|
|
if( buf[len_rcv-1] == '\n' )
|
|
|
|
buf[len_rcv-1] = '\0';
|
|
|
|
|
|
|
|
cout << buf << endl;
|
|
|
|
{
|
|
|
|
// add it back to the socket so that select can use it
|
|
|
|
lock_guard<mutex> guard(SocketSetMutex);
|
|
|
|
SocketSet.insert(handler);
|
|
|
|
|
|
|
|
// push handler ID and notify sender thread
|
|
|
|
WriteHandler = handler;
|
|
|
|
WaitForWrite.notify_one();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|