fail/cpn: removed USE_SIZE_PREFIX from SocketComm

This removes the ability to directly parse protobufs from the socket, because
google::protobuf::Message::ParseFromFileDescriptor() needs a EOF after each message;
thus preventing us from sending multiple Message objects over a single socket.

Change-Id: I67c0f631071470d6e0ae597e42848036a6db3656
This commit is contained in:
Michael Lenz
2014-01-13 15:01:25 +01:00
parent 34065fea60
commit abd9decf0b
2 changed files with 0 additions and 14 deletions

View File

@ -15,7 +15,6 @@ void SocketComm::init()
bool SocketComm::sendMsg(int sockfd, google::protobuf::Message& msg)
{
#ifdef USE_SIZE_PREFIX
int size = htonl(msg.ByteSize());
std::string buf;
if (safe_write(sockfd, &size, sizeof(size)) == -1
@ -23,19 +22,11 @@ bool SocketComm::sendMsg(int sockfd, google::protobuf::Message& msg)
|| safe_write(sockfd, buf.c_str(), buf.size()) == -1) {
return false;
}
#else
char c = 0;
if (!msg.SerializeToFileDescriptor(sockfd)
|| safe_write(sockfd, &c, 1) == -1) {
return false;
}
#endif
return true;
}
bool SocketComm::rcvMsg(int sockfd, google::protobuf::Message& msg)
{
#ifdef USE_SIZE_PREFIX
int size;
if (safe_read(sockfd, &size, sizeof(size)) == -1) {
return false;
@ -49,9 +40,6 @@ bool SocketComm::rcvMsg(int sockfd, google::protobuf::Message& msg)
std::string st(buf, size);
delete [] buf;
return msg.ParseFromString(st);
#else
return msg.ParseFromFileDescriptor(sockfd);
#endif
}
ssize_t SocketComm::safe_write(int fd, const void *buf, size_t count)

View File

@ -15,8 +15,6 @@
#include <fstream>
#include <google/protobuf/message.h>
#define USE_SIZE_PREFIX
namespace fail {
class SocketComm {