epoll init
This commit is contained in:
parent
f6b77e1b27
commit
aea977d6ea
1
withepoll/Makefile
Normal file
1
withepoll/Makefile
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
@ -103,14 +103,18 @@ void Client::receive()
|
|||||||
memset(buf,'\0',MAX_PACKET_SIZE);
|
memset(buf,'\0',MAX_PACKET_SIZE);
|
||||||
int len_rcv = 0;
|
int len_rcv = 0;
|
||||||
{
|
{
|
||||||
bool flag = true;
|
bool flag = 1;
|
||||||
while( flag )
|
while( flag )
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lock(WriteReadMutex);
|
lock_guard<mutex> lock(WriteReadMutex);
|
||||||
// cout << "SSL_read: start" << endl;
|
// cout << "SSL_read: start" << endl;
|
||||||
len_rcv = SSL_read(SSLHandler, buf, MAX_PACKET_SIZE);
|
len_rcv = SSL_read(SSLHandler, buf, MAX_PACKET_SIZE);
|
||||||
// cout << "SSL_read: stop" << endl;
|
// cout << "SSL_read: stop" << endl;
|
||||||
flag = handle_error_code(len_rcv, SSLHandler, len_rcv, "SSL_read");
|
flag = handle_error_code(len_rcv, SSLHandler, len_rcv, "SSL_read");
|
||||||
|
if( !flag )
|
||||||
|
flag = SSL_pending(SSLHandler);
|
||||||
|
cout << "PENDING: " << flag << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,8 +227,7 @@ void Client::renegotiate()
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cout << "SSL State: " << SSL_state_string(SSLHandler) << endl;
|
||||||
// cout << "SSL State: " << SSL_state_string(SSLHandler) << endl;
|
|
||||||
// if(SSL_do_handshake(SSLHandler) <= 0){
|
// if(SSL_do_handshake(SSLHandler) <= 0){
|
||||||
// cerr << "SSL_do_handshake() failed. STATE: "
|
// cerr << "SSL_do_handshake() failed. STATE: "
|
||||||
// << SSL_state_string(SSLHandler) << endl;
|
// << SSL_state_string(SSLHandler) << endl;
|
@ -1,5 +1,5 @@
|
|||||||
#define MAX_PACKET_SIZE 1024
|
#define MAX_PACKET_SIZE 1024
|
||||||
#define PORT 1420
|
#define PORT 5061
|
||||||
#define IP "127.0.0.1"
|
#define IP "127.0.0.1"
|
||||||
#define EXCHANGE_STRING "ABCDEFGHIJKLMNOPRSTUWXYZ"
|
#define EXCHANGE_STRING "ABCDEFGHIJKLMNOPRSTUWXYZ"
|
||||||
#define EXCHANGE_STRING_LEN sizeof(EXCHANGE_STRING)/sizeof(EXCHANGE_STRING[0])
|
#define EXCHANGE_STRING_LEN sizeof(EXCHANGE_STRING)/sizeof(EXCHANGE_STRING[0])
|
371114
withselect/out
Normal file
371114
withselect/out
Normal file
File diff suppressed because it is too large
Load Diff
@ -268,27 +268,35 @@ void Receive()
|
|||||||
cout << SSL_state_string(handler.second) << endl;
|
cout << SSL_state_string(handler.second) << endl;
|
||||||
{
|
{
|
||||||
lock_guard<mutex> lock(WriteReadMutex);
|
lock_guard<mutex> lock(WriteReadMutex);
|
||||||
cout << "SSL_read: start" << endl;
|
int flag = 1;
|
||||||
len_rcv = SSL_read(handler.second, buf, 1024);
|
while( flag!=0 )
|
||||||
// cout << "SSL_read: stop" << endl;
|
|
||||||
if( !handle_error_code(len_rcv, handler.second, len_rcv, "rcv") )
|
|
||||||
{
|
{
|
||||||
// dirty thing - if it has \n on the end - remove it
|
cout << "SSL_read: start" << endl;
|
||||||
if( buf[len_rcv-1] == '\n' )
|
len_rcv = SSL_read(handler.second, buf, 1024);
|
||||||
buf[len_rcv-1] = '\0';
|
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
|
// dirty thing - if it has \n on the end - remove it
|
||||||
lock_guard<mutex> guard(SocketSetMutex);
|
if( buf[len_rcv-1] == '\n' )
|
||||||
SocketSet.insert(handler);
|
buf[len_rcv-1] = '\0';
|
||||||
|
|
||||||
// push handler ID and notify sender thread
|
cout << buf << endl;
|
||||||
WriteHandler = handler;
|
{
|
||||||
WaitForWrite.notify_one();
|
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user