It sometimes stucks on beginning
This commit is contained in:
parent
614f82a7d7
commit
ec012d960b
2
Makefile
2
Makefile
@ -2,7 +2,7 @@ EXECUTABLE = server
|
||||
EXECUTABLECLI = client
|
||||
|
||||
CC=g++ -lboost_system -lboost_thread
|
||||
CFLAGS=-Wall -O2 -DDEBUG -Wreorder
|
||||
CFLAGS=-Wall -DDEBUG -Wreorder
|
||||
COMPILE=$(CC) $(CFLAGS)
|
||||
|
||||
all: server client
|
||||
|
14
client.cpp
14
client.cpp
@ -44,7 +44,7 @@ void Sender()
|
||||
lock_guard<mutex> lock(WriteReadMutex);
|
||||
len+=SSL_write(SSLHandler, buf.c_str()+len, buf.size()-len);
|
||||
// for debugging re-neg
|
||||
// cout << "SSL STATE: " << SSL_state_string(handler.second) << endl;
|
||||
cout << "SSL STATE: " << SSL_state_string(SSLHandler) << endl;
|
||||
} while( len != static_cast<int>(buf.size()) );
|
||||
}
|
||||
};
|
||||
@ -52,6 +52,7 @@ void Sender()
|
||||
void Client::receive()
|
||||
{
|
||||
char buf[MAX_PACKET_SIZE];
|
||||
cout << "R " << endl;
|
||||
|
||||
// TODO: this way it takes 100% CPU, some signal would be usefull
|
||||
memset(buf,'\0',MAX_PACKET_SIZE);
|
||||
@ -97,6 +98,13 @@ void Client::connect()
|
||||
}
|
||||
|
||||
SSLHandler = SSL_new(_ctx);
|
||||
|
||||
long mode = SSL_CTX_set_mode(_ctx, SSL_MODE_AUTO_RETRY);
|
||||
if( ( mode & SSL_MODE_AUTO_RETRY) != SSL_MODE_AUTO_RETRY )
|
||||
{
|
||||
throw runtime_error("SSL_MODE_AUTO_RETRY couldn't be set");
|
||||
}
|
||||
|
||||
SSL_set_fd(SSLHandler, _handler);
|
||||
|
||||
if( SSL_connect(SSLHandler) <= 0)
|
||||
@ -105,7 +113,9 @@ void Client::connect()
|
||||
exit(1);
|
||||
}
|
||||
// bug reproduces even if call is blocking, so not need to uncommet this line
|
||||
// fcntl(_handler, F_SETFL, O_NONBLOCK);
|
||||
int opts = fcntl(_handler,F_GETFL);
|
||||
opts = opts & ( ~O_NONBLOCK );
|
||||
fcntl(_handler, F_SETFL, opts);
|
||||
}
|
||||
|
||||
void Client::start()
|
||||
|
Loading…
Reference in New Issue
Block a user