Skip to content

Commit

Permalink
Merge pull request #606 from smukil/fill_in_nbuf_for_errors
Browse files Browse the repository at this point in the history
Error responses should contain mbufs with appropriate error strings
  • Loading branch information
ipapapa authored Sep 25, 2018
2 parents 874ed24 + 2b50e89 commit caa7995
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/dyn_dnode_peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ static void dnode_peer_ack_err(struct context *ctx, struct conn *conn,
// Create an appropriate response for the request so its propagated up;
// This response gets dropped in rsp_make_error anyways. But since this is
// an error path its ok with the overhead.
struct msg *rsp = msg_get(conn, false, __FUNCTION__);
struct msg *rsp = msg_get_error(conn, PEER_CONNECTION_REFUSE, conn->err);
if (rsp == NULL) {
// TODO: It's not clear how the peer should behave if we hit this error
// condition. Return an appropriate error instead.
log_warn("Could not allocate msg for notifying an error to peer");
return;
}
req->done = 1;
rsp->peer = req;
rsp->is_error = req->is_error = 1;
Expand Down
6 changes: 4 additions & 2 deletions src/dyn_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ static void server_ack_err(struct context *ctx, struct conn *conn,
// Create an appropriate response for the request so its propagated up;
// This response gets dropped in rsp_make_error anyways. But since this is
// an error path its ok with the overhead.
struct msg *rsp = msg_get(conn, false, __FUNCTION__);
struct msg *rsp = msg_get_error(conn, STORAGE_CONNECTION_REFUSE, conn->err);
if (rsp == NULL) {
log_warn("Could not allocate msg.");
// TODO: It's not clear how the client should behave if we hit this error
// condition. Return an appropriate error instead.
log_warn("Could not allocate msg for notifying an error to the client.");
return;
}
req->done = 1;
Expand Down

0 comments on commit caa7995

Please sign in to comment.