diff --git a/include/nng/nng.h b/include/nng/nng.h index 08c2326e9..57e8d847e 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -895,7 +895,7 @@ NNG_DECL nng_listener nng_pipe_listener(nng_pipe); // NNG_OPT_SOCKET_FD is a write-only integer property that is used to // file descriptors (or FILE HANDLE objects on Windows) to a -// fdconn:// based listener. This file descriptor will be taken +// socket:// based listener. This file descriptor will be taken // over and used as a stream connection. The protocol is compatible // with SP over TCP. This facility is experimental, and intended to // allow use with descriptors created via socketpair() or similar. diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 85d044fa3..9e5a6bec2 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -24,8 +24,8 @@ nng_sources( device.h dialer.c dialer.h - fdconn.c - fdconn.h + sockfd.c + sockfd.h file.c file.h idhash.c diff --git a/src/core/platform.h b/src/core/platform.h index 7da9c57af..0b5ec6344 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -440,10 +440,10 @@ extern int nni_plat_udp_sockname(nni_plat_udp *, nni_sockaddr *); // an array of HANDLEs.) If not supported, this returns NNG_ENOTSUP. // // This API can only create a pair of open file descriptors, suitable for use -// with the fdconn transport, each bound to the other. The transport must be +// with the socket transport, each bound to the other. The transport must be // a bidirectional reliable byte stream. This should be suitable for use // in APIs to transport file descriptors, or across a fork/exec boundary (so -// that child processes may use these with fdconn to inherit a socket that is +// that child processes may use these with socket to inherit a socket that is // connected to the parent.) extern int nni_socket_pair(int *); diff --git a/src/core/fdconn.c b/src/core/sockfd.c similarity index 99% rename from src/core/fdconn.c rename to src/core/sockfd.c index e50fd70db..42a41e5e9 100644 --- a/src/core/fdconn.c +++ b/src/core/sockfd.c @@ -12,8 +12,8 @@ #include -#include "core/fdconn.h" #include "core/nng_impl.h" +#include "core/sockfd.h" // We will accept up to this many FDs to be queued up for // accept, before we start rejecting with NNG_ENOSPC. Once diff --git a/src/core/fdconn.h b/src/core/sockfd.h similarity index 100% rename from src/core/fdconn.h rename to src/core/sockfd.h diff --git a/src/core/stream.c b/src/core/stream.c index 0ea184e4f..99002fcdf 100644 --- a/src/core/stream.c +++ b/src/core/stream.c @@ -15,7 +15,7 @@ #include "core/nng_impl.h" #include -#include "core/fdconn.h" +#include "core/sockfd.h" #include "core/tcp.h" #include "supplemental/tls/tls_api.h" #include "supplemental/websocket/websocket.h" diff --git a/src/platform/posix/CMakeLists.txt b/src/platform/posix/CMakeLists.txt index b9ea443b4..0a88419e9 100644 --- a/src/platform/posix/CMakeLists.txt +++ b/src/platform/posix/CMakeLists.txt @@ -76,7 +76,6 @@ if (NNG_PLATFORM_POSIX) posix_clock.c posix_debug.c posix_file.c - posix_fdconn.c posix_ipcconn.c posix_ipcdial.c posix_ipclisten.c @@ -84,6 +83,7 @@ if (NNG_PLATFORM_POSIX) posix_resolv_gai.c posix_sockaddr.c posix_socketpair.c + posix_sockfd.c posix_tcpconn.c posix_tcpdial.c posix_tcplisten.c diff --git a/src/platform/posix/posix_fdconn.c b/src/platform/posix/posix_sockfd.c similarity index 85% rename from src/platform/posix/posix_fdconn.c rename to src/platform/posix/posix_sockfd.c index 78a6231d9..2642ac205 100644 --- a/src/platform/posix/posix_fdconn.c +++ b/src/platform/posix/posix_sockfd.c @@ -17,7 +17,7 @@ #include #include -#include "core/fdconn.h" +#include "core/sockfd.h" #include "platform/posix/posix_aio.h" struct nni_sfd_conn { @@ -31,7 +31,7 @@ struct nni_sfd_conn { }; static void -fdc_dowrite(nni_sfd_conn *c) +sfd_dowrite(nni_sfd_conn *c) { nni_aio *aio; int fd; @@ -96,7 +96,7 @@ fdc_dowrite(nni_sfd_conn *c) } static void -fdc_doread(nni_sfd_conn *c) +sfd_doread(nni_sfd_conn *c) { nni_aio *aio; int fd; @@ -161,7 +161,7 @@ fdc_doread(nni_sfd_conn *c) } static void -fdc_error(void *arg, int err) +sfd_error(void *arg, int err) { nni_sfd_conn *c = arg; nni_aio * aio; @@ -179,7 +179,7 @@ fdc_error(void *arg, int err) } static void -fdc_close(void *arg) +sfd_close(void *arg) { nni_sfd_conn *c = arg; nni_mtx_lock(&c->mtx); @@ -198,13 +198,13 @@ fdc_close(void *arg) nni_mtx_unlock(&c->mtx); } -// fdc_fini may block briefly waiting for the pollq thread. +// sfd_fini may block briefly waiting for the pollq thread. // To get that out of our context, we simply reap this. static void -fdc_fini(void *arg) +sfd_fini(void *arg) { nni_sfd_conn *c = arg; - fdc_close(c); + sfd_close(c); if (c->pfd != NULL) { nni_posix_pfd_fini(c->pfd); } @@ -213,32 +213,32 @@ fdc_fini(void *arg) NNI_FREE_STRUCT(c); } -static nni_reap_list fdc_reap_list = { +static nni_reap_list sfd_reap_list = { .rl_offset = offsetof(nni_sfd_conn, reap), - .rl_func = fdc_fini, + .rl_func = sfd_fini, }; static void -fdc_free(void *arg) +sfd_free(void *arg) { struct nni_sfd_conn *c = arg; - nni_reap(&fdc_reap_list, c); + nni_reap(&sfd_reap_list, c); } static void -fdc_cb(nni_posix_pfd *pfd, unsigned events, void *arg) +sfd_cb(nni_posix_pfd *pfd, unsigned events, void *arg) { struct nni_sfd_conn *c = arg; if (events & (NNI_POLL_HUP | NNI_POLL_ERR | NNI_POLL_INVAL)) { - fdc_error(c, NNG_ECONNSHUT); + sfd_error(c, NNG_ECONNSHUT); return; } nni_mtx_lock(&c->mtx); if ((events & NNI_POLL_IN) != 0) { - fdc_doread(c); + sfd_doread(c); } if ((events & NNI_POLL_OUT) != 0) { - fdc_dowrite(c); + sfd_dowrite(c); } events = 0; if (!nni_list_empty(&c->writeq)) { @@ -254,7 +254,7 @@ fdc_cb(nni_posix_pfd *pfd, unsigned events, void *arg) } static void -fdc_cancel(nni_aio *aio, void *arg, int rv) +sfd_cancel(nni_aio *aio, void *arg, int rv) { nni_sfd_conn *c = arg; @@ -267,7 +267,7 @@ fdc_cancel(nni_aio *aio, void *arg, int rv) } static void -fdc_send(void *arg, nni_aio *aio) +sfd_send(void *arg, nni_aio *aio) { nni_sfd_conn *c = arg; int rv; @@ -277,7 +277,7 @@ fdc_send(void *arg, nni_aio *aio) } nni_mtx_lock(&c->mtx); - if ((rv = nni_aio_schedule(aio, fdc_cancel, c)) != 0) { + if ((rv = nni_aio_schedule(aio, sfd_cancel, c)) != 0) { nni_mtx_unlock(&c->mtx); nni_aio_finish_error(aio, rv); return; @@ -285,7 +285,7 @@ fdc_send(void *arg, nni_aio *aio) nni_aio_list_append(&c->writeq, aio); if (nni_list_first(&c->writeq) == aio) { - fdc_dowrite(c); + sfd_dowrite(c); // If we are still the first thing on the list, that // means we didn't finish the job, so arm the poller to // complete us. @@ -297,7 +297,7 @@ fdc_send(void *arg, nni_aio *aio) } static void -fdc_recv(void *arg, nni_aio *aio) +sfd_recv(void *arg, nni_aio *aio) { nni_sfd_conn *c = arg; int rv; @@ -307,7 +307,7 @@ fdc_recv(void *arg, nni_aio *aio) } nni_mtx_lock(&c->mtx); - if ((rv = nni_aio_schedule(aio, fdc_cancel, c)) != 0) { + if ((rv = nni_aio_schedule(aio, sfd_cancel, c)) != 0) { nni_mtx_unlock(&c->mtx); nni_aio_finish_error(aio, rv); return; @@ -319,7 +319,7 @@ fdc_recv(void *arg, nni_aio *aio) // many cases. We also need not arm a list if it was already // armed. if (nni_list_first(&c->readq) == aio) { - fdc_doread(c); + sfd_doread(c); // If we are still the first thing on the list, that // means we didn't finish the job, so arm the poller to // complete us. @@ -330,24 +330,24 @@ fdc_recv(void *arg, nni_aio *aio) nni_mtx_unlock(&c->mtx); } -static const nni_option fdc_options[] = { +static const nni_option sfd_options[] = { { .o_name = NULL, }, }; static int -fdc_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t) +sfd_get(void *arg, const char *name, void *buf, size_t *szp, nni_type t) { nni_sfd_conn *c = arg; - return (nni_getopt(fdc_options, name, c, buf, szp, t)); + return (nni_getopt(sfd_options, name, c, buf, szp, t)); } static int -fdc_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t) +sfd_set(void *arg, const char *name, const void *buf, size_t sz, nni_type t) { nni_sfd_conn *c = arg; - return (nni_setopt(fdc_options, name, c, buf, sz, t)); + return (nni_setopt(sfd_options, name, c, buf, sz, t)); } int @@ -369,14 +369,14 @@ nni_sfd_conn_alloc(nni_sfd_conn **cp, int fd) nni_aio_list_init(&c->readq); nni_aio_list_init(&c->writeq); - c->stream.s_free = fdc_free; - c->stream.s_close = fdc_close; - c->stream.s_recv = fdc_recv; - c->stream.s_send = fdc_send; - c->stream.s_get = fdc_get; - c->stream.s_set = fdc_set; + c->stream.s_free = sfd_free; + c->stream.s_close = sfd_close; + c->stream.s_recv = sfd_recv; + c->stream.s_send = sfd_send; + c->stream.s_get = sfd_get; + c->stream.s_set = sfd_set; - nni_posix_pfd_set_cb(c->pfd, fdc_cb, c); + nni_posix_pfd_set_cb(c->pfd, sfd_cb, c); *cp = c; return (0); diff --git a/src/sp/transport/CMakeLists.txt b/src/sp/transport/CMakeLists.txt index 95d67101f..0de80015d 100644 --- a/src/sp/transport/CMakeLists.txt +++ b/src/sp/transport/CMakeLists.txt @@ -10,7 +10,7 @@ # Transports. nng_directory(transport) -add_subdirectory(fdconn) +add_subdirectory(socket) add_subdirectory(inproc) add_subdirectory(ipc) add_subdirectory(tcp) diff --git a/src/sp/transport/fdconn/CMakeLists.txt b/src/sp/transport/socket/CMakeLists.txt similarity index 83% rename from src/sp/transport/fdconn/CMakeLists.txt rename to src/sp/transport/socket/CMakeLists.txt index 264dd455c..d79b261e1 100644 --- a/src/sp/transport/fdconn/CMakeLists.txt +++ b/src/sp/transport/socket/CMakeLists.txt @@ -8,8 +8,8 @@ # # File Descriptor (or Handle) based connections -nng_directory(fdconn) +nng_directory(socket) -nng_sources_if(NNG_TRANSPORT_FDC fdconn.c) +nng_sources_if(NNG_TRANSPORT_FDC sockfd.c) nng_defines_if(NNG_TRANSPORT_FDC NNG_TRANSPORT_FDC) -nng_test(fdc_test) \ No newline at end of file +nng_test(sockfd_test) \ No newline at end of file diff --git a/src/sp/transport/fdconn/fdconn.c b/src/sp/transport/socket/sockfd.c similarity index 100% rename from src/sp/transport/fdconn/fdconn.c rename to src/sp/transport/socket/sockfd.c diff --git a/src/sp/transport/fdconn/fdc_test.c b/src/sp/transport/socket/sockfd_test.c similarity index 100% rename from src/sp/transport/fdconn/fdc_test.c rename to src/sp/transport/socket/sockfd_test.c