Skip to content

Commit

Permalink
nng_msg_dup correctly duplicates pipe (mentioned in nanomsg#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-ruyi authored and gdamore committed Mar 13, 2019
1 parent 6f25aa4 commit fff2835
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ nni_msg_dup(nni_msg **dup, const nni_msg *src)
memcpy(newmo->mo_val, mo->mo_val, mo->mo_sz);
nni_list_append(&m->m_options, newmo);
}
m->m_pipe = src->m_pipe;

*dup = m;
return (0);
Expand Down
10 changes: 10 additions & 0 deletions tests/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ TestMain("Message Tests", {
So(strcmp(nng_msg_body(m2), "back2basics") == 0);
});

Convey("Message dup copies pipe", {
nng_pipe p = NNG_PIPE_INITIALIZER;
nng_msg *m2;
memset(&p, 0x22, sizeof(p));
nng_msg_set_pipe(msg, p);
So(nng_msg_dup(&m2, msg) == 0);
p = nng_msg_get_pipe(m2);
So(nng_pipe_id(p) == 0x22222222);
});

Convey("Missing option fails properly", {
char buf[128];
size_t sz = sizeof(buf);
Expand Down

0 comments on commit fff2835

Please sign in to comment.