aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--perf/perf.c8
-rw-r--r--src/nng.c23
-rw-r--r--src/nng.h8
-rw-r--r--tests/event.c2
-rw-r--r--tests/pipeline.c8
-rw-r--r--tests/pubsub.c8
-rw-r--r--tests/sock.c16
-rw-r--r--tests/survey.c6
8 files changed, 21 insertions, 58 deletions
diff --git a/perf/perf.c b/perf/perf.c
index 202a3712..40b9c1f3 100644
--- a/perf/perf.c
+++ b/perf/perf.c
@@ -282,7 +282,7 @@ do_inproc_thr(int argc, char **argv)
void
latency_client(const char *addr, int msgsize, int trips)
{
- nng_socket *s;
+ nng_socket s;
nng_msg *msg;
nni_time start, end;
int rv;
@@ -332,7 +332,7 @@ latency_client(const char *addr, int msgsize, int trips)
void
latency_server(const char *addr, int msgsize, int trips)
{
- nng_socket *s;
+ nng_socket s;
nng_msg *msg;
int rv;
int i;
@@ -375,7 +375,7 @@ latency_server(const char *addr, int msgsize, int trips)
void
throughput_server(const char *addr, int msgsize, int count)
{
- nng_socket *s;
+ nng_socket s;
nng_msg *msg;
int rv;
int i;
@@ -433,7 +433,7 @@ throughput_server(const char *addr, int msgsize, int count)
void
throughput_client(const char *addr, int msgsize, int count)
{
- nng_socket *s;
+ nng_socket s;
nng_msg *msg;
int rv;
int i;
diff --git a/src/nng.c b/src/nng.c
index 03d5a98c..587900bd 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -18,17 +18,6 @@
// Pretty much every function calls the nni_platform_init to check against
// fork related activity.
-#define NNI_INIT_INT() \
- do { \
- if (nni_init() != 0) { \
- return (NNG_ENOMEM); \
- } \
- } \
- while (0)
-
-#define NNI_INIT_VOID() \
- (void) nni_init()
-
int
nng_open(nng_socket *sidp, uint16_t proto)
{
@@ -351,7 +340,6 @@ nng_pipe_getopt(nng_pipe *pipe, int opt, void *val, size_t *sizep)
{
int rv;
- NNI_INIT_INT();
rv = nni_pipe_getopt(pipe, opt, val, sizep);
if (rv == ENOTSUP) {
// Maybe its a generic socket option.
@@ -364,7 +352,6 @@ nng_pipe_getopt(nng_pipe *pipe, int opt, void *val, size_t *sizep)
int
nng_pipe_close(nng_pipe *pipe)
{
- NNI_INIT_INT();
nni_pipe_close(pipe);
return (0);
}
@@ -377,7 +364,6 @@ nng_pipe_close(nng_pipe *pipe)
int
nng_msg_alloc(nng_msg **msgp, size_t size)
{
- NNI_INIT_VOID();
return (nni_msg_alloc(msgp, size));
}
@@ -488,10 +474,9 @@ nng_msg_getopt(nng_msg *msg, int opt, void *ptr, size_t *szp)
int
-nng_snapshot_create(nng_snapshot **snapp)
+nng_snapshot_create(nng_socket sock, nng_snapshot **snapp)
{
// Stats TBD.
- NNI_INIT_INT();
return (NNG_ENOTSUP);
}
@@ -499,16 +484,14 @@ nng_snapshot_create(nng_snapshot **snapp)
void
nng_snapshot_destroy(nng_snapshot *snap)
{
- NNI_INIT_VOID();
// Stats TBD.
}
int
-nng_snapshot_update(nng_socket sock, nng_snapshot *snap)
+nng_snapshot_update(nng_snapshot *snap)
{
// Stats TBD.
- NNI_INIT_INT();
return (NNG_ENOTSUP);
}
@@ -517,7 +500,6 @@ int
nng_snapshot_next(nng_snapshot *snap, nng_stat **statp)
{
// Stats TBD.
- NNI_INIT_INT();
*statp = NULL;
return (NNG_ENOTSUP);
}
@@ -551,6 +533,5 @@ int
nng_device(nng_socket sock1, nng_socket sock2)
{
// Device TBD.
- NNI_INIT_INT();
return (NNG_ENOTSUP);
}
diff --git a/src/nng.h b/src/nng.h
index 5eb0edea..0c7abde2 100644
--- a/src/nng.h
+++ b/src/nng.h
@@ -150,7 +150,7 @@ NNG_DECL int nng_dial(nng_socket, const char *, nng_endpoint *, int);
// nng_endpoint_create creates an endpoint on the socket, but does not
// start it either dialing or listening.
-NNG_DECL int nng_endpoint_create(nng_endpoint *, nng_socket, const char *);
+NNG_DECL int nng_endpoint_create(nng_socket, const char *, nng_endpoint *);
// nng_endpoint_dial starts the endpoint dialing. This is only possible if
// the endpoint is not already dialing or listening.
@@ -296,7 +296,7 @@ NNG_DECL int nng_pipe_close(nng_pipe);
// object must be deallocated expressly by the user, and may persist beyond
// the lifetime of any socket object used to update it. Note that the
// values of the statistics are initially unset.
-NNG_DECL int nng_snapshot_create(nng_snapshot **);
+NNG_DECL int nng_snapshot_create(nng_socket, nng_snapshot **);
// nng_snapshot_free frees a snapshot object. All statistic objects
// contained therein are destroyed as well.
@@ -304,9 +304,7 @@ NNG_DECL void nng_snapshot_free(nng_snapshot *);
// nng_snapshot_update updates a snapshot of all the statistics
// relevant to a particular socket. All prior values are overwritten.
-// It is acceptable to use the same snapshot object with different
-// sockets.
-NNG_DECL int nng_snapshot_update(nng_socket, nng_snapshot *);
+NNG_DECL int nng_snapshot_update(nng_snapshot *);
// nng_snapshot_next is used to iterate over the individual statistic
// objects inside the snapshot. Note that the statistic object, and the
diff --git a/tests/event.c b/tests/event.c
index f6e0ab3a..30e8f438 100644
--- a/tests/event.c
+++ b/tests/event.c
@@ -16,7 +16,7 @@
#define CHECKSTR(m, s) So(nng_msg_len(m) == strlen(s));\
So(memcmp(nng_msg_body(m), s, strlen(s)) == 0)
struct evcnt {
- nng_socket *sock;
+ nng_socket sock;
int readable;
int writeable;
int pipeadd;
diff --git a/tests/pipeline.c b/tests/pipeline.c
index 688c48bf..aa01c2d1 100644
--- a/tests/pipeline.c
+++ b/tests/pipeline.c
@@ -26,7 +26,6 @@ Main({
nng_socket push;
So(nng_open(&push, NNG_PROTO_PUSH) == 0);
- So(push != NULL);
Reset({
nng_close(push);
@@ -46,7 +45,6 @@ Main({
Convey("We can create a PULL socket", {
nng_socket pull;
So(nng_open(&pull, NNG_PROTO_PULL) == 0);
- So(pull != NULL);
Reset({
nng_close(pull);
@@ -66,9 +64,9 @@ Main({
})
Convey("We can create a linked PUSH/PULL pair", {
- nng_socket push = NULL;
- nng_socket pull = NULL;
- nng_socket what = NULL;
+ nng_socket push;
+ nng_socket pull;
+ nng_socket what;
So(nng_open(&push, NNG_PROTO_PUSH) == 0);
So(nng_open(&pull, NNG_PROTO_PULL) == 0);
diff --git a/tests/pubsub.c b/tests/pubsub.c
index 12355554..431d6980 100644
--- a/tests/pubsub.c
+++ b/tests/pubsub.c
@@ -27,7 +27,6 @@ Main({
nng_socket pub;
So(nng_open(&pub, NNG_PROTO_PUB) == 0);
- So(pub != NULL);
Reset({
nng_close(pub);
@@ -47,7 +46,6 @@ Main({
Convey("We can create a SUB socket", {
nng_socket sub;
So(nng_open(&sub, NNG_PROTO_SUB) == 0);
- So(sub != NULL);
Reset({
nng_close(sub);
@@ -70,11 +68,9 @@ Main({
nng_socket pub;
nng_socket sub;
- So((rv = nng_open(&pub, NNG_PROTO_PUB)) == 0);
- So(pub != NULL);
+ So(nng_open(&pub, NNG_PROTO_PUB) == 0);
- So((rv = nng_open(&sub, NNG_PROTO_SUB)) == 0);
- So(sub != NULL);
+ So(nng_open(&sub, NNG_PROTO_SUB) == 0);
Reset({
nng_close(pub);
diff --git a/tests/sock.c b/tests/sock.c
index 9ceb99cb..a41a0093 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -20,11 +20,9 @@ Main({
Convey("We are able to open a PAIR socket", {
int rv;
- nng_socket sock = NULL;
+ nng_socket sock;
- rv = nng_open(&sock, NNG_PROTO_PAIR);
- So(rv == 0);
- So(sock != NULL);
+ So(nng_open(&sock, NNG_PROTO_PAIR) == 0);
Reset({
nng_close(sock);
@@ -137,9 +135,8 @@ Main({
})
Convey("We can connect to it", {
- nng_socket *sock2 = NULL;
- rv = nng_open(&sock2, NNG_PROTO_PAIR);
- So(rv == 0);
+ nng_socket sock2;
+ So(nng_open(&sock2, NNG_PROTO_PAIR) == 0);
rv = nng_dial(sock2, "inproc://here", NULL, NNG_FLAG_SYNCH);
So(rv == 0);
nng_close(sock2);
@@ -147,13 +144,12 @@ Main({
})
Convey("We can send and receive messages", {
- nng_socket sock2 = NULL;
+ nng_socket sock2;
int len = 1;
nng_msg *msg;
uint64_t second = 1000000;
- rv = nng_open(&sock2, NNG_PROTO_PAIR);
- So(rv == 0);
+ So(nng_open(&sock2, NNG_PROTO_PAIR) == 0);
rv = nng_setopt(sock, NNG_OPT_RCVBUF, &len, sizeof (len));
So(rv == 0);
diff --git a/tests/survey.c b/tests/survey.c
index 9ce7f20b..a7dd3cca 100644
--- a/tests/survey.c
+++ b/tests/survey.c
@@ -27,7 +27,6 @@ Main({
nng_socket surv;
So(nng_open(&surv, NNG_PROTO_SURVEYOR) == 0);
- So(surv != NULL);
Reset({
nng_close(surv);
@@ -57,7 +56,6 @@ Main({
Convey("We can create a RESPONDENT socket", {
nng_socket resp;
So(nng_open(&resp, NNG_PROTO_RESPONDENT) == 0);
- So(resp != NULL);
Reset({
nng_close(resp);
@@ -83,11 +81,7 @@ Main({
uint64_t expire;
So(nng_open(&surv, NNG_PROTO_SURVEYOR) == 0);
- So(surv != NULL);
-
So(nng_open(&resp, NNG_PROTO_RESPONDENT) == 0);
- So(resp != NULL);
-
Reset({
nng_close(surv);