Skip to content

Commit

Permalink
Restore changed ancillary reception semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
rauhma authored Mar 16, 2023
1 parent ce5e7c1 commit 2a60380
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
15 changes: 0 additions & 15 deletions src/tcp_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,12 @@ static void destroy_ancillary_data(ancillary_data_t *data)
}

FSTRACE_DECL(ASYNC_TCP_RECEIVE_ANCILLARY, "UID=%64u SIZE=%z");
FSTRACE_DECL(ASYNC_TCP_RECEIVE_ANCILLARY_FD, "UID=%64u FD=%d");
FSTRACE_DECL(ASYNC_TCP_RECEIVE_ANCILLARY_DUMP, "UID=%64u DATA=%A");

static void receive_ancillary_data(tcp_conn_t *conn, struct cmsghdr *cp)
{
size_t anclen = cp->cmsg_len;
FSTRACE(ASYNC_TCP_RECEIVE_ANCILLARY, conn->uid, anclen);
int level;
int type;
size_t size = ancillary_data_info(cp, &level, &type);
if (level == SOL_SOCKET && type == SCM_RIGHTS) {
int *fds = (int *) CMSG_DATA(cp);
int remaining_fds = size / sizeof(int);
while (remaining_fds--) {
int fd = *fds++;
ancillary_data_t *data = make_fd_ancillary(fd);
list_append(conn->input.ancillary_list, data);
FSTRACE(ASYNC_TCP_RECEIVE_ANCILLARY_FD, conn->uid, fd);
}
return;
}
struct cmsghdr *anc = fsalloc(anclen);
memcpy(anc, cp, anclen);
ancillary_data_t *data = make_raw_ancillary(anc);
Expand Down
6 changes: 3 additions & 3 deletions test/asynctest-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static void tcp_probe_down_world(TCP_CONTEXT *context)
int level = 999, type = 999, fd = 999;
count = tcp_peek_ancillary_data(context->conn, &level, &type);
if (count < 0) {
tlog("No ancillary data received");
tlog("No ancillary data received (errno %d)", errno);
async_quit_loop(context->async);
return;
}
Expand All @@ -246,8 +246,8 @@ static void tcp_probe_down_world(TCP_CONTEXT *context)
async_quit_loop(context->async);
return;
}
count = tcp_recv_ancillary_data(context->conn, &fd, sizeof fd);
if (count != sizeof fd) {
fd = tcp_recv_fd(context->conn);
if (fd < 0) {
tlog("Bad ancillary data size received");
async_quit_loop(context->async);
return;
Expand Down

0 comments on commit 2a60380

Please sign in to comment.