diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-17 22:39:41 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-17 22:39:41 -0800 |
| commit | e54e2b1a98abfdb75232a9b3218714ce34c9a34f (patch) | |
| tree | 3476bf1c917a686677f538b0bcb2f753934bfbc0 /src | |
| parent | 6333c9cefb847231397128bb7b99f0055acd1632 (diff) | |
| download | nng-e54e2b1a98abfdb75232a9b3218714ce34c9a34f.tar.gz nng-e54e2b1a98abfdb75232a9b3218714ce34c9a34f.tar.bz2 nng-e54e2b1a98abfdb75232a9b3218714ce34c9a34f.zip | |
More url work. Undocument rawurl, and stop using it stats and logs.
Also expose nng_url_sprintf() for users who need it.
This avoids some need to do dynamic memory on some things. Soon
the entirety of nng_url will be allocation free in the usual case.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/dialer.c | 15 | ||||
| -rw-r--r-- | src/core/listener.c | 19 | ||||
| -rw-r--r-- | src/core/sockimpl.h | 2 | ||||
| -rw-r--r-- | src/core/url.h | 3 | ||||
| -rw-r--r-- | src/nng.c | 6 |
5 files changed, 15 insertions, 30 deletions
diff --git a/src/core/dialer.c b/src/core/dialer.c index 907da99d..d39eb99a 100644 --- a/src/core/dialer.c +++ b/src/core/dialer.c @@ -72,12 +72,6 @@ dialer_stats_init(nni_dialer *d) .si_desc = "socket for dialer", .si_type = NNG_STAT_ID, }; - static const nni_stat_info url_info = { - .si_name = "url", - .si_desc = "dialer url", - .si_type = NNG_STAT_STRING, - .si_alloc = true, - }; static const nni_stat_info pipes_info = { .si_name = "pipes", .si_desc = "open pipes", @@ -149,7 +143,6 @@ dialer_stats_init(nni_dialer *d) dialer_stat_init(d, &d->st_id, &id_info); dialer_stat_init(d, &d->st_sock, &socket_info); - dialer_stat_init(d, &d->st_url, &url_info); dialer_stat_init(d, &d->st_pipes, &pipes_info); dialer_stat_init(d, &d->st_connect, &connect_info); dialer_stat_init(d, &d->st_refused, &refused_info); @@ -165,7 +158,6 @@ dialer_stats_init(nni_dialer *d) nni_stat_set_id(&d->st_root, (int) d->d_id); nni_stat_set_id(&d->st_id, (int) d->d_id); nni_stat_set_id(&d->st_sock, (int) nni_sock_id(d->d_sock)); - nni_stat_set_string(&d->st_url, d->d_url->u_rawurl); nni_stat_register(&d->st_root); } #endif // NNG_ENABLE_STATS @@ -384,8 +376,7 @@ dialer_connect_cb(void *arg) case NNG_ETIMEDOUT: default: nng_log_warn("NNG-CONN-FAIL", - "Failed connecting socket<%u> to %s: %s", - nni_sock_id(d->d_sock), d->d_url->u_rawurl, + "Failed connecting socket<%u>: %s", nni_sock_id(d->d_sock), nng_strerror(rv)); nni_dialer_bump_error(d, rv); @@ -438,8 +429,8 @@ nni_dialer_start(nni_dialer *d, unsigned flags) nni_aio_free(aio); } - nng_log_info("NNG-DIAL", "Starting dialer for socket<%u> on %s", - nni_sock_id(d->d_sock), d->d_url->u_rawurl); + nng_log_info("NNG-DIAL", "Starting dialer for socket<%u>", + nni_sock_id(d->d_sock)); return (rv); } diff --git a/src/core/listener.c b/src/core/listener.c index 88729f56..e1cdf833 100644 --- a/src/core/listener.c +++ b/src/core/listener.c @@ -74,12 +74,6 @@ listener_stats_init(nni_listener *l) .si_desc = "socket id", .si_type = NNG_STAT_ID, }; - static const nni_stat_info url_info = { - .si_name = "url", - .si_desc = "listener url", - .si_type = NNG_STAT_STRING, - .si_alloc = true, - }; static const nni_stat_info pipes_info = { .si_name = "pipes", .si_desc = "open pipes", @@ -145,7 +139,6 @@ listener_stats_init(nni_listener *l) listener_stat_init(l, &l->st_id, &id_info); listener_stat_init(l, &l->st_sock, &sock_info); - listener_stat_init(l, &l->st_url, &url_info); listener_stat_init(l, &l->st_pipes, &pipes_info); listener_stat_init(l, &l->st_accept, &accept_info); listener_stat_init(l, &l->st_disconnect, &disconnect_info); @@ -160,7 +153,6 @@ listener_stats_init(nni_listener *l) nni_stat_set_id(&l->st_root, (int) l->l_id); nni_stat_set_id(&l->st_id, (int) l->l_id); nni_stat_set_id(&l->st_sock, (int) nni_sock_id(l->l_sock)); - nni_stat_set_string(&l->st_url, l->l_url->u_rawurl); nni_stat_register(&l->st_root); } #endif // NNG_ENABLE_STATS @@ -362,9 +354,8 @@ listener_accept_cb(void *arg) case NNG_ETIMEDOUT: // No need to sleep, we timed out already. case NNG_EPEERAUTH: // peer validation failure nng_log_warn("NNG-ACCEPT-FAIL", - "Failed accepting for socket<%u> on %s: %s", - nni_sock_id(l->l_sock), l->l_url->u_rawurl, - nng_strerror(rv)); + "Failed accepting for socket<%u>: %s", + nni_sock_id(l->l_sock), nng_strerror(rv)); nni_listener_bump_error(l, rv); listener_accept_start(l); break; @@ -404,10 +395,8 @@ nni_listener_start(nni_listener *l, int flags) } if ((rv = l->l_ops.l_bind(l->l_data)) != 0) { - nng_log_warn("NNG-BIND-FAIL", - "Failed binding socket<%u> to %s: %s", - nni_sock_id(l->l_sock), l->l_url->u_rawurl, - nng_strerror(rv)); + nng_log_warn("NNG-BIND-FAIL", "Failed binding socket<%u>: %s", + nni_sock_id(l->l_sock), nng_strerror(rv)); nni_listener_bump_error(l, rv); nni_atomic_flag_reset(&l->l_started); return (rv); diff --git a/src/core/sockimpl.h b/src/core/sockimpl.h index e568f37f..0a5114c0 100644 --- a/src/core/sockimpl.h +++ b/src/core/sockimpl.h @@ -42,7 +42,6 @@ struct nni_dialer { nni_stat_item st_root; nni_stat_item st_id; nni_stat_item st_sock; - nni_stat_item st_url; nni_stat_item st_pipes; nni_stat_item st_connect; nni_stat_item st_refused; @@ -78,7 +77,6 @@ struct nni_listener { nni_stat_item st_root; nni_stat_item st_id; nni_stat_item st_sock; - nni_stat_item st_url; nni_stat_item st_pipes; nni_stat_item st_accept; nni_stat_item st_disconnect; // aborted remotely diff --git a/src/core/url.h b/src/core/url.h index 71a093d0..f43d3db6 100644 --- a/src/core/url.h +++ b/src/core/url.h @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -17,6 +17,7 @@ extern int nni_url_parse(nni_url **, const char *path); extern void nni_url_free(nni_url *); extern int nni_url_clone(nni_url **, const nni_url *); extern uint16_t nni_url_default_port(const char *); +extern int nni_url_sprintf(char *, size_t, const nni_url *); extern int nni_url_asprintf(char **, const nni_url *); extern int nni_url_asprintf_port(char **, const nni_url *, int); extern size_t nni_url_decode(uint8_t *, const char *, size_t); @@ -2038,6 +2038,12 @@ nng_url_clone(nng_url **dstp, const nng_url *src) return (nni_url_clone(dstp, src)); } +int +nng_url_sprintf(char *buf, size_t bufsz, const nng_url *src) +{ + return (nni_url_sprintf(buf, bufsz, src)); +} + #define xstr(a) str(a) #define str(a) #a |
