Skip to content

Commit

Permalink
rename fdconn to socket
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Dec 28, 2023
1 parent 441ce89 commit 7925933
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion include/nng/nng.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
2 changes: 1 addition & 1 deletion src/core/fdconn.c → src/core/sockfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#include <nng/nng.h>

#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
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/core/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "core/nng_impl.h"
#include <nng/supplemental/tls/tls.h>

#include "core/fdconn.h"
#include "core/sockfd.h"
#include "core/tcp.h"
#include "supplemental/tls/tls_api.h"
#include "supplemental/websocket/websocket.h"
Expand Down
2 changes: 1 addition & 1 deletion src/platform/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ 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
posix_pipe.c
posix_resolv_gai.c
posix_sockaddr.c
posix_socketpair.c
posix_sockfd.c
posix_tcpconn.c
posix_tcpdial.c
posix_tcplisten.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <sys/uio.h>
#include <unistd.h>

#include "core/fdconn.h"
#include "core/sockfd.h"
#include "platform/posix/posix_aio.h"

struct nni_sfd_conn {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -161,7 +161,7 @@ fdc_doread(nni_sfd_conn *c)
}

static void
fdc_error(void *arg, int err)
sfd_error(void *arg, int err)

Check warning on line 164 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L164

Added line #L164 was not covered by tests
{
nni_sfd_conn *c = arg;

Check warning on line 166 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L166

Added line #L166 was not covered by tests
nni_aio * aio;
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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;

Check warning on line 234 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L233-L234

Added lines #L233 - L234 were not covered by tests
}
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);

Check warning on line 241 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L241

Added line #L241 was not covered by tests
}
events = 0;
if (!nni_list_empty(&c->writeq)) {
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -277,15 +277,15 @@ 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;

Check warning on line 283 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L281-L283

Added lines #L281 - L283 were not covered by tests
}
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.
Expand All @@ -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;
Expand All @@ -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;

Check warning on line 313 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L311-L313

Added lines #L311 - L313 were not covered by tests
Expand All @@ -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.
Expand All @@ -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)

Check warning on line 340 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L340

Added line #L340 was not covered by tests
{
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));

Check warning on line 343 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L342-L343

Added lines #L342 - L343 were not covered by tests
}

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)

Check warning on line 347 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L347

Added line #L347 was not covered by tests
{
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));

Check warning on line 350 in src/platform/posix/posix_sockfd.c

View check run for this annotation

Codecov / codecov/patch

src/platform/posix/posix_sockfd.c#L349-L350

Added lines #L349 - L350 were not covered by tests
}

int
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/sp/transport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Transports.
nng_directory(transport)

add_subdirectory(fdconn)
add_subdirectory(socket)
add_subdirectory(inproc)
add_subdirectory(ipc)
add_subdirectory(tcp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
nng_test(sockfd_test)
File renamed without changes.
File renamed without changes.

0 comments on commit 7925933

Please sign in to comment.