Skip to content

Commit

Permalink
Changing recv max should not affect open pipes.
Browse files Browse the repository at this point in the history
dev zero test.
  • Loading branch information
gdamore committed Dec 29, 2023
1 parent c40aee7 commit e775488
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/platform/posix/posix_peerid.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include "core/nng_impl.h"
#include <sys/types.h>

int
nni_posix_peerid(int fd,
uint64_t *euid, uint64_t *egid, uint64_t *prid, uint64_t *znid);
int nni_posix_peerid(
int fd, uint64_t *euid, uint64_t *egid, uint64_t *prid, uint64_t *znid);

#endif // PLATFORM_POSIX_PEERID_H
10 changes: 0 additions & 10 deletions src/sp/transport/socket/sockfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,18 +873,8 @@ sfd_tran_ep_set_recvmaxsz(void *arg, const void *v, size_t sz, nni_opt_type t)
size_t val;
int rv;
if ((rv = nni_copyin_size(&val, v, sz, 0, NNI_MAXSZ, t)) == 0) {
sfd_tran_pipe *p;
nni_mtx_lock(&ep->mtx);
ep->rcvmax = val;
NNI_LIST_FOREACH (&ep->waitpipes, p) {
p->rcvmax = val;
}
NNI_LIST_FOREACH (&ep->negopipes, p) {
p->rcvmax = val;
}
NNI_LIST_FOREACH (&ep->busypipes, p) {
p->rcvmax = val;
}
nni_mtx_unlock(&ep->mtx);
#ifdef NNG_ENABLE_STATS
nni_stat_set_value(&ep->st_rcv_max, val);
Expand Down
21 changes: 21 additions & 0 deletions src/sp/transport/socket/sockfd_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#ifdef NNG_PLATFORM_POSIX
#include <unistd.h>
#include <fcntl.h>
#ifdef NNG_PLATFORM_SUNOS
#include <zone.h>
#endif
Expand Down Expand Up @@ -417,6 +418,25 @@ test_sfd_fd_option_type(void)
NUTS_CLOSE(s);
}

void
test_sfd_fd_dev_zero(void)
{
#ifdef NNG_PLATFORM_POSIX
nng_socket s;
nng_listener l;
int fd;

// dev/zero produces a stream of zero bytes leading to protocol error
NUTS_ASSERT((fd = open("/dev/zero", O_RDONLY, 0777)) >= 0);

NUTS_OPEN(s);
NUTS_PASS(nng_listener_create(&l, s, "socket://"));
NUTS_PASS(nng_listener_set_int(l, NNG_OPT_SOCKET_FD, fd));
nng_msleep(100);
NUTS_CLOSE(s);
#endif
}

NUTS_TESTS = {
{ "socket connect fail", test_sfd_connect_fail },
{ "socket malformed address", test_sfd_malformed_address },
Expand All @@ -434,6 +454,7 @@ NUTS_TESTS = {
{ "socket pipe peer id", test_sockfd_pipe_peer },
{ "socket listen full", test_sfd_listen_full },
{ "socket bad fd type", test_sfd_fd_option_type },
{ "socket dev zero", test_sfd_fd_dev_zero },
#endif

{ NULL, NULL },
Expand Down

0 comments on commit e775488

Please sign in to comment.