diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-10-31 18:47:07 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-10-31 23:10:12 -0700 |
| commit | 452ecf5ae83adc9ae77518746f4f81171c42248c (patch) | |
| tree | d81730eef3c19775abf0715831dc18e3f9885d21 /src/core | |
| parent | 587bc765ee69acfabf3bc8b88a70806c07b61f87 (diff) | |
| download | nng-452ecf5ae83adc9ae77518746f4f81171c42248c.tar.gz nng-452ecf5ae83adc9ae77518746f4f81171c42248c.tar.bz2 nng-452ecf5ae83adc9ae77518746f4f81171c42248c.zip | |
fixes #1311 reduce wasted use for nni_aio
fixes #1317 IPv6 listener get port is incorrect
fixes #1319 Want symbolic service names
This is phase 1 of reducing the memory foot-print of aios, and
also of pipes. This removes the largest consumer the socket
address information, from the aio, which was only used by a few
consumers.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/aio.c | 12 | ||||
| -rw-r--r-- | src/core/aio.h | 17 | ||||
| -rw-r--r-- | src/core/platform.h | 17 |
3 files changed, 12 insertions, 34 deletions
diff --git a/src/core/aio.c b/src/core/aio.c index 97bb9153..6a390677 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -699,15 +699,3 @@ nni_aio_sys_init(void) nni_thr_run(thr); return (0); } - -void -nni_aio_set_sockaddr(nni_aio *aio, const nng_sockaddr *sa) -{ - memcpy(&aio->a_sockaddr, sa, sizeof(*sa)); -} - -void -nni_aio_get_sockaddr(nni_aio *aio, nng_sockaddr *sa) -{ - memcpy(sa, &aio->a_sockaddr, sizeof(*sa)); -}
\ No newline at end of file diff --git a/src/core/aio.h b/src/core/aio.h index c2776bc0..2f699245 100644 --- a/src/core/aio.h +++ b/src/core/aio.h @@ -155,12 +155,9 @@ extern void nni_aio_get_iov(nni_aio *, unsigned *, nni_iov **); extern void nni_aio_normalize_timeout(nni_aio *, nng_duration); extern void nni_aio_bump_count(nni_aio *, size_t); -extern void nni_aio_set_sockaddr(nni_aio *aio, const nng_sockaddr *); -extern void nni_aio_get_sockaddr(nni_aio *aio, nng_sockaddr *); - // nni_aio_schedule indicates that the AIO has begun, and is scheduled for -// asychronous completion. This also starts the expiration timer. Note that -// prior to this, the aio is uncancellable. If the operation has a zero +// asynchronous completion. This also starts the expiration timer. Note that +// prior to this, the aio cannot be canceled. If the operation has a zero // timeout (NNG_FLAG_NONBLOCK) then NNG_ETIMEDOUT is returned. If the // operation has already been canceled, or should not be run, then an error // is returned. (In that case the caller should probably either return an @@ -198,7 +195,7 @@ struct nng_aio { // User scratch data. Consumers may store values here, which // must be preserved by providers and the framework. - void *a_user_data[4]; + void *a_user_data[2]; // Operation inputs & outputs. Up to 4 inputs and 4 outputs may be // specified. The semantics of these will vary, and depend on the @@ -210,13 +207,7 @@ struct nng_aio { nni_aio_cancelfn a_cancel_fn; void * a_cancel_arg; nni_list_node a_prov_node; // Linkage on provider list. - void * a_prov_extra[4]; // Extra data used by provider - - // Socket address. This turns out to be very useful, as we wind up - // needing socket addresses for numerous connection related routines. - // It would be cleaner to not have this and avoid burning the space, - // but having this hear dramatically simplifies lots of code. - nng_sockaddr a_sockaddr; + void * a_prov_extra[2]; // Extra data used by provider // Expire node. nni_list_node a_expire_node; diff --git a/src/core/platform.h b/src/core/platform.h index 6eff2f7d..704e338d 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -287,7 +287,7 @@ extern void nni_tcp_dialer_close(nni_tcp_dialer *); // nni_tcp_dial attempts to create an outgoing connection, // asynchronously, to the address in the aio. On success, the first (and only) // output will be an nni_tcp_conn * associated with the remote server. -extern void nni_tcp_dial(nni_tcp_dialer *, nni_aio *); +extern void nni_tcp_dial(nni_tcp_dialer *, const nng_sockaddr *, nni_aio *); // nni_tcp_dialer_getopt gets an option from the dialer. extern int nni_tcp_dialer_setopt( @@ -331,17 +331,16 @@ extern int nni_tcp_listener_setopt( extern int nni_tcp_listener_getopt( nni_tcp_listener *, const char *, void *, size_t *, nni_type); -// nni_tcp_resolv resolves a TCP name asynchronously. The family -// should be one of NNG_AF_INET, NNG_AF_INET6, or NNG_AF_UNSPEC. The -// first two constrain the name to those families, while the third will +// nni_resolv_ip resolves a DNS host and service name asynchronously. +// The family should be one of NNG_AF_INET, NNG_AF_INET6, or NNG_AF_UNSPEC. +// The first two constrain the name to those families, while the third will // return names of either family. The passive flag indicates that the // name will be used for bind(), otherwise the name will be used with // connect(). The host part may be NULL only if passive is true. -extern void nni_tcp_resolv(const char *, const char *, int, int, nni_aio *); - -// nni_udp_resolv is just like nni_tcp_resolv, but looks up -// service names using UDP. -extern void nni_udp_resolv(const char *, const char *, int, int, nni_aio *); +// Symbolic service names will be looked up assuming SOCK_STREAM, so +// they may not work with UDP. +extern void nni_resolv_ip(const char *, const char *, int, bool, + nng_sockaddr *sa, nni_aio *); // nni_parse_ip parses an IP address, without a port. extern int nni_parse_ip(const char *, nng_sockaddr *); |
