Commit 56796d2f authored by legoc's avatar legoc
Browse files

More traces

parent 646859a5
......@@ -61,7 +61,7 @@ Server::Server(const std::string& endpoint, int timeoutMs) :
m_eventThread->start();
}
catch (...) {
// ...
cerr << "Error while opening event stream" << endl;
}
}
......
......@@ -49,6 +49,9 @@ void RequestSocketImpl::setTimeout(int timeout) {
}
void RequestSocketImpl::setSocketLinger() {
cerr << this << " RequestSocketImpl::setSocketLinger " << m_socket.get() << endl;
// Set the linger in case of timeout.
// If not, the context can block indefinitely.
// Does the value 100 can lead to a side-effect? A too small value like 1 has some side-effect.
......@@ -62,27 +65,37 @@ void RequestSocketImpl::setSocketLinger() {
void RequestSocketImpl::init() {
cerr << this << " RequestSocketImpl::init" << endl;
// Reset if the socket is null.
if (m_socket.get() == nullptr) {
cerr << this << " RequestSocketImpl::init null" << endl;
m_socket.reset(m_services->createRequestSocket(m_endpoint));
if (m_socket.get() == nullptr) {
cerr << this << " RequestSocketImpl::init null" << endl;
cerr << this << " RequestSocketImpl::init still null" << endl;
}
// Apply the linger to the socket.
setSocketLinger();
}
else {
cerr << this << " RequestSocketImpl::init already done" << endl;
}
}
void RequestSocketImpl::reset() {
m_socket.reset();
cerr << this << " RequestSocketImpl::reset" << endl;
cerr << this << " RequestSocketImpl::reset " << m_socket.get() << endl;
}
std::unique_ptr<zmq::message_t> RequestSocketImpl::request(const std::string& requestTypePart, const std::string& requestDataPart, int overrideTimeout) {
cerr << this << " RequestSocketImpl::request" << endl;
// Init if not already done or if a timeout occurred.
init();
......@@ -117,6 +130,9 @@ std::unique_ptr<zmq::message_t> RequestSocketImpl::request(const std::string& re
int rc = zmq::poll(items, 1, timeout);
if (rc == 0) {
cerr << this << " RequestSocketImpl::request timeout" << endl;
// Reset the socket. It is necessary if a new request is done.
reset();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment