Skip to content

Commit

Permalink
fixes nanomsg#136 consider eliminating nng_shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Oct 30, 2017
1 parent 296d74d commit b3a0d58
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 47 deletions.
14 changes: 0 additions & 14 deletions src/nng.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ nng_fini(void)
nni_fini();
}

int
nng_shutdown(nng_socket sid)
{
int rv;
nni_sock *sock;

if ((rv = nni_sock_find(&sock, sid)) != 0) {
return (rv);
}
rv = nni_sock_shutdown(sock);
nni_sock_rele(sock);
return (rv);
}

int
nng_close(nng_socket sid)
{
Expand Down
7 changes: 0 additions & 7 deletions src/nng.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,6 @@ NNG_DECL int nng_close(nng_socket);
// a library; it will affect all sockets.
NNG_DECL void nng_closeall(void);

// nng_shutdown shuts down the socket. This causes any threads doing
// work for the socket or blocked in socket functions to be woken (and
// return NNG_ECLOSED). The socket resources are still present, so it
// is safe to call other functions; they will just return NNG_ECLOSED.
// A call to nng_close is still required to release the resources.
NNG_DECL int nng_shutdown(nng_socket);

// nng_protocol returns the protocol number of the socket.
NNG_DECL uint16_t nng_protocol(nng_socket);

Expand Down
4 changes: 2 additions & 2 deletions tests/pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ TestMain("PIPELINE (PUSH/PULL) pattern", {
So(nng_listen(pull, addr, NULL, 0) == 0);
So(nng_dial(push, addr, NULL, 0) == 0);
So(nng_dial(what, addr, NULL, 0) == 0);
So(nng_shutdown(what) == 0);
So(nng_close(what) == 0);

nng_msleep(20);

Expand Down Expand Up @@ -146,7 +146,7 @@ TestMain("PIPELINE (PUSH/PULL) pattern", {
So(nng_dial(pull1, addr, NULL, 0) == 0);
So(nng_dial(pull2, addr, NULL, 0) == 0);
So(nng_dial(pull3, addr, NULL, 0) == 0);
So(nng_shutdown(pull3) == 0);
So(nng_close(pull3) == 0);

// So pull3 might not be done accepting yet, but pull1
// and pull2 definitely are, because otherwise the
Expand Down
24 changes: 0 additions & 24 deletions tests/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,6 @@ TestMain("Socket Operations", {

Reset({ nng_close(s1); });

Convey("And we can shut it down", {
char * buf;
size_t sz;
So(nng_shutdown(s1) == 0);
So(nng_shutdown(s1) == NNG_ECLOSED);
Convey("It can't receive", {
So(nng_recv(s1, &buf, &sz, NNG_FLAG_ALLOC) ==
NNG_ECLOSED);
});
Convey("It can't send",
{ So(nng_send(s1, "", 0, 0) == NNG_ECLOSED); });
Convey("Cannot create endpoints", {
nng_dialer d;
nng_listener l;
char * a = "inproc://closed";
So(nng_dialer_create(&d, s1, a) ==
NNG_ECLOSED);
So(nng_listener_create(&l, s1, a) ==
NNG_ECLOSED);
So(nng_dial(s1, a, &d, 0) == NNG_ECLOSED);
So(nng_listen(s1, a, &l, 0) == NNG_ECLOSED);
});
});

Convey("It's type & peer are still PAIR", {
So(nng_protocol(s1) == NNG_PROTO_PAIR);
So(nng_peer(s1) == NNG_PROTO_PAIR);
Expand Down

0 comments on commit b3a0d58

Please sign in to comment.