Changeset - 346e24d182b1
[Not reviewed]
1 2 0
Jan Kaluza - 13 years ago 2012-03-06 11:00:57
hanzz.k@gmail.com
Fixed header corruption on 64bit windows
3 files changed with 4 insertions and 141 deletions:
0 comments (0 inline, 0 general)
plugin/src/networkplugin.cpp
Show inline comments
 
@@ -550,26 +550,26 @@ void NetworkPlugin::handleDataRead(std::string &data) {
 
				handleFTContinuePayload(wrapper.payload());
 
				break;
 
			case pbnetwork::WrapperMessage_Type_TYPE_EXIT:
 
				handleExitRequest();
 
				break;
 
			default:
 
				return;
 
		}
 
	}
 
}
 

	
 
void NetworkPlugin::send(const std::string &data) {
 
	char header[4];
 
	*((int*)(header)) = htonl(data.size());
 
	uint32_t size = htonl(data.size());
 
	char *header = (char *) &size;
 
	sendData(std::string(header, 4) + data);
 
}
 

	
 
void NetworkPlugin::checkPing() {
 
	if (m_pingReceived == false) {
 
		handleExitRequest();
 
	}
 
	m_pingReceived = false;
 
}
 

	
 
void NetworkPlugin::sendPong() {
 
	m_pingReceived = true;
plugin/src/pbnetwork.proto
Show inline comments
 
deleted file
src/networkpluginserver.cpp
Show inline comments
 
@@ -795,26 +795,26 @@ void NetworkPluginServer::handleDataRead(Backend *c, boost::shared_ptr<Swift::Sa
 
				break;
 
			case pbnetwork::WrapperMessage_Type_TYPE_FT_DATA:
 
				handleFTDataPayload(c, wrapper.payload());
 
				break;
 
			default:
 
				return;
 
		}
 
	}
 
}
 

	
 
void NetworkPluginServer::send(boost::shared_ptr<Swift::Connection> &c, const std::string &data) {
 
	// generate header - size of wrapper message
 
	char header[4];
 
	*((int*)(header)) = htonl(data.size());
 
	uint32_t size = htonl(data.size());
 
	char *header = (char *) &size;
 

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

	
 
void NetworkPluginServer::pingTimeout() {
 
	// 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;
0 comments (0 inline, 0 general)