Skip to content

Commit

Permalink
pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pbench committed May 17, 2022
1 parent 0a13130 commit 2f22e4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
url = https://github.com/jupp0r/prometheus-cpp
[submodule "source/third_party/flann"]
path = source/third_party/flann
url = https://github.com/mariusmuja/flann
url = https://github.com/flann-lib/flann
14 changes: 9 additions & 5 deletions source/kraken/kraken_zmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void respond(zmq::socket_t& socket,
socket.send(reply);
}

static pbnavitia::Response create_error_response(std::string error_message, pbnavitia::Error_error_id error_id) {
static pbnavitia::Response create_error_response(std::string error_message, pbnavitia::Error_error_id error_id) {
pbnavitia::Response response;
auto* error = response.mutable_error();
error->set_id(pbnavitia::Error::invalid_protobuf_request);
Expand Down Expand Up @@ -108,23 +108,26 @@ inline void doWork(zmq::context_t& context,
} catch (const zmq::error_t&) {
// on gére le cas du sighup durant un recv
LOG4CPLUS_WARN(logger, "Zmq error occured while receiving. I'll ignore this message.");
pbnavitia::Response response = create_error_response("zmq error occured while receiving", pbnavitia::Error::internal_error);
pbnavitia::Response response =
create_error_response("zmq error occured while receiving", pbnavitia::Error::internal_error);
respond(socket, {}, response);
continue;
}

// we should obtain at least 3 frames
if (frames.size() < 3) {
LOG4CPLUS_WARN(logger, "Received a zmq message with less than 3 frames. I'll ignore it.");
pbnavitia::Response response = create_error_response("Received a zmq message with less than 3 frames.", pbnavitia::Error::internal_error);
pbnavitia::Response response = create_error_response("Received a zmq message with less than 3 frames.",
pbnavitia::Error::internal_error);
respond(socket, {}, response);
continue;
}

// the penultimate frame should be empty
if (frames[frames.size() - 2] != "") {
LOG4CPLUS_WARN(logger, "Received a zmq message with a non empty penultimate frame. I'll ignore it.");
pbnavitia::Response response = create_error_response("Received a zmq message with a non empty penultimate frame.", pbnavitia::Error::internal_error);
pbnavitia::Response response = create_error_response(
"Received a zmq message with a non empty penultimate frame.", pbnavitia::Error::internal_error);
respond(socket, {}, response);
continue;
}
Expand All @@ -144,7 +147,8 @@ inline void doWork(zmq::context_t& context,
pbnavitia::API api = pbnavitia::UNKNOWN_API;
if (!pb_req.ParseFromArray(payload.data(), payload.size())) {
LOG4CPLUS_WARN(logger, "receive invalid protobuf");
pbnavitia::Response response = create_error_response("Receive invalid protobuf.", pbnavitia::Error::invalid_protobuf_request);
pbnavitia::Response response =
create_error_response("Receive invalid protobuf.", pbnavitia::Error::invalid_protobuf_request);
respond(socket, frames, response);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion source/utils
Submodule utils updated 1 files
+42 −64 zmq.cpp

0 comments on commit 2f22e4f

Please sign in to comment.