1
0
Fork 0

fix add multiple payloads for VppMessageNoOwnBuffer

This commit is contained in:
Jan Christoph Uhde 2016-09-07 14:42:51 +02:00
parent 2d1fbfb291
commit 99f592bae1
2 changed files with 26 additions and 4 deletions

View File

@ -176,8 +176,11 @@ void VppCommTask::addResponse(VppResponse* response) {
std::vector<VPackSlice> slices;
slices.push_back(response_message._header);
if (response->generateBody()) {
slices.push_back(response_message._payload);
for (auto& payload : response_message._payloads) {
slices.push_back(payload);
}
}
LOG_TOPIC(DEBUG, Logger::COMMUNICATION) << "VppCommTask: "

View File

@ -29,6 +29,7 @@
#include <velocypack/Slice.h>
#include <velocypack/velocypack-aliases.h>
#include <iterator>
#include <vector>
#include "Basics/StringBuffer.h"
namespace arangodb {
@ -92,11 +93,29 @@ struct VppInputMessage {
};
struct VPackMessageNoOwnBuffer {
VPackMessageNoOwnBuffer(VPackSlice head, VPackSlice pay, uint64_t id,
VPackMessageNoOwnBuffer(VPackSlice head, std::vector<VPackSlice> payloads,
uint64_t id, bool generateBody = true)
: _header(head),
_payloads(std::move(payloads)),
_id(id),
_generateBody(generateBody) {}
VPackMessageNoOwnBuffer(VPackSlice head, VPackSlice payload, uint64_t id,
bool generateBody = true)
: _header(head), _payload(pay), _id(id), _generateBody(generateBody) {}
: _header(head), _payloads(), _id(id), _generateBody(generateBody) {
_payloads.push_back(payload);
}
VPackSlice firstPayload() {
if (_payloads.size() && _generateBody) {
return _payloads.front();
}
}
std::vector<VPackSlice> payloads() { return _payloads; }
VPackSlice _header;
VPackSlice _payload;
std::vector<VPackSlice> _payloads;
uint64_t _id;
bool _generateBody;
};