diff options
| -rw-r--r-- | docs/man/nng_options.5.adoc | 101 | ||||
| -rw-r--r-- | docs/ref/migrate/nanomsg.md | 2 | ||||
| -rw-r--r-- | docs/ref/migrate/nng1.md | 3 | ||||
| -rw-r--r-- | include/nng/nng.h | 1 | ||||
| -rw-r--r-- | src/core/sock_test.c | 81 | ||||
| -rw-r--r-- | src/core/socket.c | 40 | ||||
| -rw-r--r-- | src/core/stats_test.c | 10 |
7 files changed, 4 insertions, 234 deletions
diff --git a/docs/man/nng_options.5.adoc b/docs/man/nng_options.5.adoc index 94da37a0..6dc6154a 100644 --- a/docs/man/nng_options.5.adoc +++ b/docs/man/nng_options.5.adoc @@ -20,16 +20,8 @@ nng_options - socket, dialer, listener, and pipe options ---- #include <nng/nng.h> -#define NNG_OPT_SOCKNAME "socket-name" -#define NNG_OPT_RAW "raw" -#define NNG_OPT_PROTO "protocol" -#define NNG_OPT_PROTONAME "protocol-name" -#define NNG_OPT_PEER "peer" -#define NNG_OPT_PEERNAME "peer-name" #define NNG_OPT_RECVBUF "recv-buffer" #define NNG_OPT_SENDBUF "send-buffer" -#define NNG_OPT_RECVFD "recv-fd" -#define NNG_OPT_SENDFD "send-fd" #define NNG_OPT_RECVTIMEO "recv-timeout" #define NNG_OPT_SENDTIMEO "send-timeout" #define NNG_OPT_LOCADDR "local-address" @@ -153,36 +145,6 @@ This value must be an integer between 0 and 8192, inclusive. NOTE: Not all protocols support buffering received messages. For example xref:nng_req.7.adoc[_req_] can only deal with a single reply at a time. -[[NNG_OPT_RECVFD]] -((`NNG_OPT_RECVFD`)):: -(((poll))) -(((select))) -(((receive, polling))) -(`int`) -This read-only option is used to obtain an integer file descriptor suitable -for use with -http://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.html[`poll()`], -http://pubs.opengroup.org/onlinepubs/7908799/xsh/select.html[`select()`], -(or on Windows systems -https://msdn.microsoft.com/en-us/library/windows/desktop/ms741669(v=vs.85).aspx[`WSAPoll()`]) -and similar functions. -This descriptor will be *readable* when a message is available for receiving -on the socket. -When no message is ready for receiving, then this file descriptor will *not* -be readable. -+ -IMPORTANT: Applications should never attempt to read or write to the -returned file descriptor. -+ -IMPORTANT: This option is incompatible with -xref:nng_ctx.5.adoc[`nng_ctx`] contexts and should not be used on a socket -where they are in use. -+ -TIP: While this option may help applications integrate into existing polling -loops, it is more efficient, and often easier, to use the asynchronous I/O -objects instead. -See xref:nng_aio_alloc.3.adoc[`nng_aio_alloc()`]. - [[NNG_OPT_RECVMAXSZ]] ((`NNG_OPT_RECVMAXSZ`)):: (((receive, maximum size))) @@ -240,37 +202,6 @@ NOTE: Not all protocols support buffering sent messages. For example, xref:nng_req.7.adoc[_req_] can only have a single request outstanding at a time (per context). -[[NNG_OPT_SENDFD]] -((`NNG_OPT_SENDFD`)):: -(((poll))) -(((select))) -(((send, polling))) -(`int`) -This read-only option is used to obtain an integer file descriptor suitable -for use with -http://pubs.opengroup.org/onlinepubs/7908799/xsh/poll.html[`poll()`], -http://pubs.opengroup.org/onlinepubs/7908799/xsh/select.html[`select()`], -(or on Windows systems -https://msdn.microsoft.com/en-us/library/windows/desktop/ms741669(v=vs.85).aspx[`WSAPoll()`]) -and similar functions. -+ -This descriptor will be *readable* when the socket is able to accept a -message for sending without blocking. -When the socket is no longer able to accept such messages without blocking, -the descriptor will *not* be readable. -+ -IMPORTANT: Applications should never attempt to read or write to the -returned file descriptor; use should be limited to polling system calls only. -+ -IMPORTANT: This option is incompatible with -xref:nng_ctx.5.adoc[`nng_ctx`] contexts and should not be used on a socket -where they are in use. -+ -TIP: While this option may help applications integrate into existing polling -loops, it is more efficient, and often easier, to use the asynchronous I/O -objects instead. -See xref:nng_aio_alloc.3.adoc[`nng_aio_alloc()`]. - [[NNG_OPT_SENDTIMEO]] ((`NNG_OPT_SENDTIMEO`)):: (((send, timeout))) @@ -281,17 +212,6 @@ When a message cannot be queued for delivery by the socket for this period of time (such as if send buffers are full), the operation will fail with a return value of `NNG_ETIMEDOUT`. -[[NNG_OPT_SOCKNAME]] -((`NNG_OPT_SOCKNAME`)):: -(((name, socket))) -(string) -This the socket name. -By default, this is a string corresponding to the value of the socket. -The string must fit within 64-bytes, including the terminating -`NUL` byte. -The value is intended for application use, and is not used for anything -in the library itself. - [[NNG_OPT_MAXTTL]] ((`NNG_OPT_MAXTTL`)):: (`int`) @@ -321,17 +241,6 @@ Accordingly it can only be used with dialers, listeners, and pipes. NOTE: Some transports will canonify URLs before returning them to the application. -[[NNG_OPT_PROTO]] -((`NNG_OPT_PROTO`)):: -(`int`) -This read-only option is used to obtain the 16-bit number for the socket's protocol. - -[[NNG_OPT_PEER]] -((`NNG_OPT_PEER`)):: -(`int`) -This read-only option is used to obtain the 16-bit number of the -peer protocol for the socket. - [[NNG_OPT_PEER_GID]] ((`NNG_OPT_PEER_GID`)):: (`uint64_t`) @@ -365,16 +274,6 @@ This option is generally only available on POSIX systems, on certain transports. This read-only option provides a connected peer's the zone id. Zones (and this option) are only supported on Solaris and illumos systems, on select transports. -[[NNG_OPT_PEERNAME]] -((`NNG_OPT_PEERNAME`)):: -(string) -This read-only option is used to obtain the name of the peer protocol for the socket. - -[[NNG_OPT_PROTONAME]] -((`NNG_OPT_PROTONAME`)):: -(string) -This read-only option is used to obtain the name of the socket's protocol. - == SEE ALSO [.text-left] diff --git a/docs/ref/migrate/nanomsg.md b/docs/ref/migrate/nanomsg.md index be4d2665..bb668121 100644 --- a/docs/ref/migrate/nanomsg.md +++ b/docs/ref/migrate/nanomsg.md @@ -87,7 +87,7 @@ The following options are changed. | `NN_DOMAIN` | None | NNG options are not divided by domain or protocol. | | `NN_PROTOCOL` | [`nng_socket_proto_id`] | No longer an option. See also `nng_socket_proto_name`. | | `NN_IPV4ONLY` | None | Use URL such as `tcp4://` to obtain this functionality. | -| `NN_SOCKET_NAME` | `NNG_OPT_SOCKNAME` | +| `NN_SOCKET_NAME` | None | Removed from NNG. | | `NN_MAXTTL` | `NNG_OPT_MAXTTL` | | `NN_SUB_SUBSCRIBE` | [`nng_sub0_socket_subscribe`] | No longer an option, use a function call. | | `NN_SUB_UNSUBSCRIBE` | [`nng_sub0_socket_unsubscribe`] | No longer an option, use a function call. | diff --git a/docs/ref/migrate/nng1.md b/docs/ref/migrate/nng1.md index 2a1456b7..7bafb8f5 100644 --- a/docs/ref/migrate/nng1.md +++ b/docs/ref/migrate/nng1.md @@ -136,6 +136,9 @@ The `NNG_OPT_RAW` option has aso been replaced by a function, [`nng_socket_raw`] The `NNG_OPT_SENDFD` and `NNG_OPT_RECVFD` options have been replaced by [`nng_socket_get_send_poll_fd`] and [`nng_socket_get_recv_poll_fd`] respectively. +The `NNG_OPT_SOCKNAME` function is removed. This was provided for application use, and never used internally by NNG. +Applications should keep track of this information separately. + ## Subscriptions The `NNG_OPT_SUB_SUBSCRIBE` and `NNG_OPT_SUB_UNSUBCRIBE` options have been replaced by diff --git a/include/nng/nng.h b/include/nng/nng.h index 77122993..a6f5dc9a 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -713,7 +713,6 @@ NNG_DECL nng_listener nng_pipe_listener(nng_pipe); #define NNG_FLAG_NONBLOCK 2u // Non-blocking operations // Options. -#define NNG_OPT_SOCKNAME "socket-name" #define NNG_OPT_RECVBUF "recv-buffer" #define NNG_OPT_SENDBUF "send-buffer" #define NNG_OPT_RECVTIMEO "recv-timeout" diff --git a/src/core/sock_test.c b/src/core/sock_test.c index 1fe94e4c..4267704b 100644 --- a/src/core/sock_test.c +++ b/src/core/sock_test.c @@ -94,76 +94,6 @@ test_socket_base(void) } void -test_socket_name(void) -{ - nng_socket s1; - char *str; - long id; - char *end; - char *name; - - NUTS_OPEN(s1); - NUTS_PASS(nng_socket_get_string(s1, NNG_OPT_SOCKNAME, &name)); - NUTS_TRUE(strlen(name) > 0); - NUTS_TRUE(strlen(name) < 64); - id = strtol(name, &end, 10); - NUTS_TRUE(id == (long) s1.id); - NUTS_TRUE(end != NULL && *end == '\0'); - nng_strfree(name); - - NUTS_PASS(nng_socket_set_string(s1, NNG_OPT_SOCKNAME, "hello")); - NUTS_PASS(nng_socket_get_string(s1, NNG_OPT_SOCKNAME, &name)); - NUTS_MATCH(name, "hello"); - nng_strfree(name); - - char buf[128]; - memset(buf, 'A', 128); - buf[127] = 0; - - // strings must not be too long - NUTS_FAIL( - nng_socket_set_string(s1, NNG_OPT_SOCKNAME, buf), NNG_EINVAL); - memset(buf, 'A', 64); - buf[64] = 0; - NUTS_FAIL( - nng_socket_set_string(s1, NNG_OPT_SOCKNAME, buf), NNG_EINVAL); - buf[63] = 0; - NUTS_PASS(nng_socket_set_string(s1, NNG_OPT_SOCKNAME, buf)); - NUTS_PASS(nng_socket_set_string(s1, NNG_OPT_SOCKNAME, "hello")); - - NUTS_PASS(nng_socket_get_string(s1, NNG_OPT_SOCKNAME, &str)); - NUTS_ASSERT(str != NULL); - NUTS_TRUE(strlen(str) == 5); - NUTS_MATCH(str, "hello"); - nng_strfree(str); - - NUTS_CLOSE(s1); -} - -void -test_socket_name_oversize(void) -{ - nng_socket s1; - char buf[256]; // 64 is max - size_t sz = sizeof(buf); - char *name; - - memset(buf, 'A', sz); - NUTS_OPEN(s1); - - buf[sz - 1] = '\0'; - NUTS_FAIL( - nng_socket_set_string(s1, NNG_OPT_SOCKNAME, buf), NNG_EINVAL); - - strcpy(buf, "hello"); - NUTS_PASS(nng_socket_set_string(s1, NNG_OPT_SOCKNAME, buf)); - NUTS_PASS(nng_socket_get_string(s1, NNG_OPT_SOCKNAME, &name)); - NUTS_MATCH(name, "hello"); - nng_strfree(name); - NUTS_CLOSE(s1); -} - -void test_send_recv(void) { nng_socket s1; @@ -402,12 +332,7 @@ test_listener_options(void) nng_listener_set_bool(l, NNG_OPT_RECVMAXSZ, true), NNG_EBADTYPE); // Cannot set inappropriate options - NUTS_FAIL( - nng_listener_set_string(l, NNG_OPT_SOCKNAME, "1"), NNG_ENOTSUP); - NUTS_FAIL(nng_listener_set_ms(l, NNG_OPT_RECONNMINT, 1), NNG_ENOTSUP); - NUTS_FAIL(nng_listener_set_string(l, NNG_OPT_SOCKNAME, "bogus"), - NNG_ENOTSUP); // Read only options NUTS_FAIL(nng_listener_set_string(l, NNG_OPT_URL, "inproc://junk"), @@ -436,11 +361,7 @@ test_dialer_options(void) nng_dialer_set_bool(d, NNG_OPT_RECVMAXSZ, true), NNG_EBADTYPE); // Cannot set inappropriate options - NUTS_FAIL( - nng_dialer_set_string(d, NNG_OPT_SOCKNAME, "1"), NNG_ENOTSUP); NUTS_FAIL(nng_dialer_set_ms(d, NNG_OPT_SENDTIMEO, 1), NNG_ENOTSUP); - NUTS_FAIL( - nng_dialer_set_string(d, NNG_OPT_SOCKNAME, "bogus"), NNG_ENOTSUP); // Read only options NUTS_FAIL(nng_dialer_set_string(d, NNG_OPT_URL, "inproc://junk"), @@ -542,8 +463,6 @@ NUTS_TESTS = { { "send timeout", test_send_timeout }, { "send non-block", test_send_nonblock }, { "socket base", test_socket_base }, - { "socket name", test_socket_name }, - { "socket name oversize", test_socket_name_oversize }, { "send recv", test_send_recv }, { "send recv zero length", test_send_recv_zero_length }, { "connection refused", test_connection_refused }, diff --git a/src/core/socket.c b/src/core/socket.c index c92a1c3b..9b4ed308 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -93,7 +93,6 @@ struct nni_socket { nni_duration s_reconn; // reconnect time nni_duration s_reconnmax; // max reconnect time size_t s_rcvmaxsz; // max receive size - char s_name[64]; // socket name (legacy compat) nni_list s_listeners; // active listeners nni_list s_dialers; // active dialers @@ -109,7 +108,6 @@ struct nni_socket { #ifdef NNG_ENABLE_STATS nni_stat_item st_root; // socket scope nni_stat_item st_id; // socket id - nni_stat_item st_name; // socket name nni_stat_item st_protocol; // socket protocol nni_stat_item st_dialers; // number of dialers nni_stat_item st_listeners; // number of listeners @@ -255,27 +253,6 @@ sock_get_sendbuf(void *s, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(len, buf, szp, t)); } -static int -sock_get_sockname(void *s, void *buf, size_t *szp, nni_type t) -{ - return (nni_copyout_str(SOCK(s)->s_name, buf, szp, t)); -} - -static int -sock_set_sockname(void *s, const void *buf, size_t sz, nni_type t) -{ - int rv; - NNI_ARG_UNUSED(sz); - rv = - (nni_copyin_str(SOCK(s)->s_name, buf, sizeof(SOCK(s)->s_name), t)); -#ifdef NNG_ENABLE_STATS - if (rv == 0) { - nni_stat_set_string(&SOCK(s)->st_name, SOCK(s)->s_name); - } -#endif - return (rv); -} - static const nni_option sock_options[] = { { .o_name = NNG_OPT_RECVTIMEO, @@ -298,11 +275,6 @@ static const nni_option sock_options[] = { .o_set = sock_set_sendbuf, }, { - .o_name = NNG_OPT_SOCKNAME, - .o_get = sock_get_sockname, - .o_set = sock_set_sockname, - }, - { .o_name = NNG_OPT_RECONNMINT, .o_get = sock_get_reconnmint, .o_set = sock_set_reconnmint, @@ -423,12 +395,6 @@ sock_stats_init(nni_sock *s) .si_desc = "socket identifier", .si_type = NNG_STAT_ID, }; - static const nni_stat_info name_info = { - .si_name = "name", - .si_desc = "socket name", - .si_type = NNG_STAT_STRING, - .si_alloc = true, - }; static const nni_stat_info protocol_info = { .si_name = "protocol", .si_desc = "socket protocol", @@ -492,7 +458,6 @@ sock_stats_init(nni_sock *s) nni_stat_init(&s->st_root, &root_info); sock_stat_init(s, &s->st_id, &id_info); - sock_stat_init(s, &s->st_name, &name_info); sock_stat_init(s, &s->st_protocol, &protocol_info); sock_stat_init(s, &s->st_dialers, &dialers_info); sock_stat_init(s, &s->st_listeners, &listeners_info); @@ -504,7 +469,6 @@ sock_stats_init(nni_sock *s) sock_stat_init(s, &s->st_rx_bytes, &rx_bytes_info); nni_stat_set_id(&s->st_id, (int) s->s_id); - nni_stat_set_string(&s->st_name, s->s_name); nni_stat_set_string(&s->st_protocol, nni_sock_proto_name(s)); } #endif @@ -634,15 +598,11 @@ nni_sock_open(nni_sock **sockp, const nni_proto *proto) } nni_mtx_unlock(&sock_lk); - // Set the socket name. - (void) snprintf(s->s_name, sizeof(s->s_name), "%u", s->s_id); - #ifdef NNG_ENABLE_STATS // Set up basic stat values. The socket id wasn't // known at stat creation time, so we set it now. nni_stat_set_id(&s->st_id, (int) s->s_id); nni_stat_set_id(&s->st_root, (int) s->s_id); - nni_stat_set_string(&s->st_name, s->s_name); // Add our stats chain. nni_stat_register(&s->st_root); diff --git a/src/core/stats_test.c b/src/core/stats_test.c index e15b4001..8912d44e 100644 --- a/src/core/stats_test.c +++ b/src/core/stats_test.c @@ -25,7 +25,6 @@ test_stats_socket(void) NUTS_OPEN(s1); NUTS_OPEN(s2); - nng_socket_set_string(s2, NNG_OPT_SOCKNAME, "second"); NUTS_MARRY(s1, s2); NUTS_SEND(s1, "ping"); NUTS_RECV(s2, "ping"); @@ -37,14 +36,6 @@ test_stats_socket(void) NUTS_ASSERT(st1 != NULL); NUTS_ASSERT(st2 != NULL); NUTS_ASSERT(st1 != st2); - item = nng_stat_find(st1, "name"); - NUTS_ASSERT(item != NULL); - NUTS_ASSERT(nng_stat_string(item) != NULL); - NUTS_MATCH(nng_stat_string(item), "1"); - item = nng_stat_find(st2, "name"); - NUTS_ASSERT(item != NULL); - NUTS_ASSERT(nng_stat_string(item) != NULL); - NUTS_MATCH(nng_stat_string(item), "second"); item = nng_stat_find(st1, "tx_msgs"); NUTS_ASSERT(item != NULL); NUTS_ASSERT(nng_stat_value(item) == 1); @@ -71,7 +62,6 @@ test_stats_dump(void) NUTS_OPEN(s1); NUTS_OPEN(s2); - nng_socket_set_string(s2, NNG_OPT_SOCKNAME, "second"); NUTS_MARRY(s1, s2); NUTS_SEND(s1, "ping"); NUTS_RECV(s2, "ping"); |
