Changeset - 899d6fe53fdb
[Not reviewed]
0 2 0
Jan Kaluza - 10 years ago 2016-02-11 14:42:17
jkaluza@redhat.com
Libtransport: Debug lost PING to backend
2 files changed with 8 insertions and 0 deletions:
0 comments (0 inline, 0 general)
libtransport/NetworkPluginServer.cpp
Show inline comments
 
@@ -1302,12 +1302,13 @@ void NetworkPluginServer::send(boost::shared_ptr<Swift::Connection> &c, const st
 

	
 
	// send header together with wrapper message
 
	c->write(Swift::createSafeByteArray(std::string(header, 4) + data));
 
}
 

	
 
void NetworkPluginServer::pingTimeout() {
 
	LOG4CXX_INFO(logger, "Sending PING to backends");
 
	// TODO: move to separate timer, those 2 loops could be expensive
 
	// Some users are connected for weeks and they are blocking backend to be destroyed and its memory
 
	// to be freed. We are finding users who are inactive for more than "idle_reconnect_time" seconds and
 
	// reconnect them to long-running backend, where they can idle hapilly till the end of ages.
 
	time_t now = time(NULL);
 
	std::vector<User *> usersToMove;
 
@@ -1347,12 +1348,15 @@ void NetworkPluginServer::pingTimeout() {
 
		if ((*it)->pongReceived || (*it)->pongReceived == -1) {
 
			// Don't send another ping if pongReceived == -1, because we've already sent one
 
			// when registering backend.
 
			if ((*it)->pongReceived) {
 
				sendPing((*it));
 
			}
 
			else {
 
				LOG4CXX_INFO(logger, "Tried to send PING to backend without pongReceived= " << (*it)->pongReceived << ": (ID=" << (*it)->id << ")");
 
			}
 
		}
 
		else {
 
			LOG4CXX_INFO(logger, "Disconnecting backend " << (*it) << " (ID=" << (*it)->id << "). PING response not received.");
 
			toRemove.push_back(*it);
 

	
 
#ifndef WIN32
 
@@ -1963,12 +1967,15 @@ void NetworkPluginServer::sendPing(Backend *c) {
 

	
 
	if (c->connection) {
 
		LOG4CXX_INFO(logger, "PING to " << c << " (ID=" << c->id << ")");
 
		send(c->connection, message);
 
		c->pongReceived = false;
 
	}
 
	else {
 
		LOG4CXX_WARN(logger, "Tried to send PING to backend without connection: " << c << " (ID=" << c->id << ")");
 
	}
 
// 	LOG4CXX_INFO(logger, "PING to " << c);
 
}
 

	
 
void NetworkPluginServer::sendAPIVersion(Backend *c) {
 

	
 
	pbnetwork::APIVersion apiver;
plugin/cpp/networkplugin.cpp
Show inline comments
 
@@ -673,12 +673,13 @@ void NetworkPlugin::send(const std::string &data) {
 
	char *header = (char *) &size;
 
	sendData(std::string(header, 4) + data);
 
}
 

	
 
void NetworkPlugin::checkPing() {
 
	if (m_pingReceived == false) {
 
		LOG4CXX_ERROR(logger, "PING request not received - exiting...");
 
		handleExitRequest();
 
	}
 
	m_pingReceived = false;
 
}
 

	
 
void NetworkPlugin::sendPong() {
0 comments (0 inline, 0 general)