aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-02 12:08:44 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-02 12:08:44 -0800
commit546c0d6ecc4267b9178f6eecb134e45c16b839cf (patch)
tree230b95a73300b4df32d352f01d6e7841875f3c1b /src/core
parent9eb080db1c450228169cc58f14d946211378fcf7 (diff)
downloadnng-546c0d6ecc4267b9178f6eecb134e45c16b839cf.tar.gz
nng-546c0d6ecc4267b9178f6eecb134e45c16b839cf.tar.bz2
nng-546c0d6ecc4267b9178f6eecb134e45c16b839cf.zip
Rename nni_socket to nni_sock.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/defs.h7
-rw-r--r--src/core/endpt.c6
-rw-r--r--src/core/endpt.h4
-rw-r--r--src/core/pipe.c6
-rw-r--r--src/core/pipe.h2
-rw-r--r--src/core/protocol.h25
-rw-r--r--src/core/socket.c38
-rw-r--r--src/core/socket.h34
8 files changed, 57 insertions, 65 deletions
diff --git a/src/core/defs.h b/src/core/defs.h
index 0fe894b1..7c9090d0 100644
--- a/src/core/defs.h
+++ b/src/core/defs.h
@@ -18,11 +18,14 @@
#define NNI_ARG_UNUSED(x) ((void) x);
// These types are common but have names shared with user space.
-typedef struct nng_socket nni_socket;
-typedef struct nng_endpt nni_endpt;
+typedef struct nng_socket nni_sock;
+typedef struct nng_endpt nni_ep;
typedef struct nng_pipe nni_pipe;
typedef struct nng_msg nni_msg;
+// REMOVE THESE
+typedef struct nng_endpt nni_endpt;
+
// These are our own names.
typedef struct nni_transport nni_transport;
typedef struct nni_endpt_ops nni_endpt_ops;
diff --git a/src/core/endpt.c b/src/core/endpt.c
index 034e1a3d..0ff31380 100644
--- a/src/core/endpt.c
+++ b/src/core/endpt.c
@@ -16,7 +16,7 @@
// Functionality realited to end points.
int
-nni_endpt_create(nni_endpt **epp, nni_socket *sock, const char *addr)
+nni_endpt_create(nni_endpt **epp, nni_sock *sock, const char *addr)
{
nni_transport *tran;
nni_endpt *ep;
@@ -47,7 +47,7 @@ nni_endpt_create(nni_endpt **epp, nni_socket *sock, const char *addr)
(void) snprintf(ep->ep_addr, sizeof (ep->ep_addr), "%s", addr);
ep->ep_ops = *tran->tran_ep_ops;
- rv = ep->ep_ops.ep_create(&ep->ep_data, addr, nni_socket_proto(sock));
+ rv = ep->ep_ops.ep_create(&ep->ep_data, addr, nni_sock_proto(sock));
if (rv != 0) {
nni_cv_fini(&ep->ep_cv);
NNI_FREE_STRUCT(ep);
@@ -133,7 +133,7 @@ nni_dial_once(nni_endpt *ep)
}
-// nni_socket_dialer is the thread worker that dials in the background.
+// nni_dialer is the thread worker that dials in the background.
static void
nni_dialer(void *arg)
{
diff --git a/src/core/endpt.h b/src/core/endpt.h
index 28a52e81..695ef79a 100644
--- a/src/core/endpt.h
+++ b/src/core/endpt.h
@@ -19,7 +19,7 @@ struct nng_endpt {
nni_endpt_ops ep_ops;
void * ep_data; // Transport private
nni_list_node ep_node; // Per socket list
- nni_socket * ep_sock;
+ nni_sock * ep_sock;
char ep_addr[NNG_MAXADDRLEN];
nni_thr ep_thr;
int ep_mode;
@@ -33,7 +33,7 @@ struct nng_endpt {
#define NNI_EP_MODE_DIAL 1
#define NNI_EP_MODE_LISTEN 2
-extern int nni_endpt_create(nni_endpt **, nni_socket *, const char *);
+extern int nni_endpt_create(nni_endpt **, nni_sock *, const char *);
extern int nni_endpt_accept(nni_endpt *, nni_pipe **);
extern void nni_endpt_close(nni_endpt *);
extern int nni_endpt_dial(nni_endpt *, int);
diff --git a/src/core/pipe.c b/src/core/pipe.c
index 177216bd..8cf83179 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -42,7 +42,7 @@ nni_pipe_recv(nni_pipe *p, nng_msg **msgp)
void
nni_pipe_close(nni_pipe *p)
{
- nni_socket *sock = p->p_sock;
+ nni_sock *sock = p->p_sock;
if (p->p_trandata != NULL) {
p->p_ops.p_close(p->p_trandata);
@@ -87,7 +87,7 @@ int
nni_pipe_create(nni_pipe **pp, nni_endpt *ep)
{
nni_pipe *p;
- nni_socket *sock = ep->ep_sock;
+ nni_sock *sock = ep->ep_sock;
nni_protocol *proto = &sock->s_ops;
int rv;
@@ -144,7 +144,7 @@ nni_pipe_start(nni_pipe *pipe)
{
int rv;
int collide;
- nni_socket *sock = pipe->p_sock;
+ nni_sock *sock = pipe->p_sock;
nni_mtx_lock(&sock->s_mx);
if (sock->s_closing) {
diff --git a/src/core/pipe.h b/src/core/pipe.h
index 3c2c1166..193fd6c2 100644
--- a/src/core/pipe.h
+++ b/src/core/pipe.h
@@ -23,7 +23,7 @@ struct nng_pipe {
void * p_pdata; // protocol specific data
size_t p_psize; // size of protocol data
nni_list_node p_node;
- nni_socket * p_sock;
+ nni_sock * p_sock;
nni_endpt * p_ep;
int p_reap;
int p_active;
diff --git a/src/core/protocol.h b/src/core/protocol.h
index 6fd48b40..301782b4 100644
--- a/src/core/protocol.h
+++ b/src/core/protocol.h
@@ -26,7 +26,7 @@ struct nni_protocol {
size_t proto_pipe_size; // pipe private data size
//Create protocol instance, which will be stored on the socket.
- int (*proto_create)(void **, nni_socket *);
+ int (*proto_create)(void **, nni_sock *);
// Destroy the protocol instance.
void (*proto_destroy)(void *);
@@ -57,29 +57,6 @@ struct nni_protocol {
nni_msg * (*proto_send_filter)(void *, nni_msg *);
};
-// These are socket methods that protocol operations can expect to call.
-// Note that each of these should be called without any locks held, since
-// the socket can reenter the protocol.
-
-// nni_socket_sendq obtains the upper writeq. The protocol should
-// recieve messages from this, and place them on the appropriate pipe.
-extern nni_msgq *nni_socket_sendq(nni_socket *);
-
-// nni_socket_recvq obtains the upper readq. The protocol should
-// inject incoming messages from pipes to it.
-extern nni_msgq *nni_socket_recvq(nni_socket *);
-
-// nni_socket_recv_err sets an error code to be returned to clients
-// rather than waiting for a message. Set it to 0 to resume normal
-// receive operation.
-extern void nni_socket_recv_err(nni_socket *, int);
-
-// nni_socket_send_err sets an error code to be returned to clients
-// when they try to send, so that they don't have to timeout waiting
-// for their message to be accepted for send. Set it to 0 to resume
-// normal send operations.
-extern void nni_socket_send_err(nni_socket *, int);
-
// These functions are not used by protocols, but rather by the socket
// core implementation. The lookups can be used by transports as well.
extern nni_protocol *nni_protocol_find(uint16_t);
diff --git a/src/core/socket.c b/src/core/socket.c
index c64ba5ef..77e68733 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -13,17 +13,17 @@
// Socket implementation.
-// nni_socket_sendq and nni_socket_recvq are called by the protocol to obtain
+// nni_sock_sendq and nni_sock_recvq are called by the protocol to obtain
// the upper read and write queues.
nni_msgq *
-nni_socket_sendq(nni_socket *s)
+nni_sock_sendq(nni_sock *s)
{
return (s->s_uwq);
}
nni_msgq *
-nni_socket_recvq(nni_socket *s)
+nni_sock_recvq(nni_sock *s)
{
return (s->s_urq);
}
@@ -35,7 +35,7 @@ nni_socket_recvq(nni_socket *s)
static void
nni_reaper(void *arg)
{
- nni_socket *sock = arg;
+ nni_sock *sock = arg;
for (;;) {
nni_pipe *pipe;
@@ -84,11 +84,11 @@ nni_reaper(void *arg)
}
-// nn_socket_create creates the underlying socket.
+// nn_sock_open creates the underlying socket.
int
-nni_socket_create(nni_socket **sockp, uint16_t proto)
+nni_sock_open(nni_sock **sockp, uint16_t proto)
{
- nni_socket *sock;
+ nni_sock *sock;
nni_protocol *ops;
int rv;
@@ -157,9 +157,9 @@ nni_socket_create(nni_socket **sockp, uint16_t proto)
}
-// nni_socket_close closes the underlying socket.
+// nni_sock_close closes the underlying socket.
int
-nni_socket_close(nni_socket *sock)
+nni_sock_close(nni_sock *sock)
{
nni_pipe *pipe;
nni_endpt *ep;
@@ -241,7 +241,7 @@ nni_socket_close(nni_socket *sock)
int
-nni_socket_sendmsg(nni_socket *sock, nni_msg *msg, nni_time expire)
+nni_sock_sendmsg(nni_sock *sock, nni_msg *msg, nni_time expire)
{
int rv;
int besteffort;
@@ -284,7 +284,7 @@ nni_socket_sendmsg(nni_socket *sock, nni_msg *msg, nni_time expire)
int
-nni_socket_recvmsg(nni_socket *sock, nni_msg **msgp, nni_time expire)
+nni_sock_recvmsg(nni_sock *sock, nni_msg **msgp, nni_time expire)
{
int rv;
nni_msg *msg;
@@ -319,16 +319,16 @@ nni_socket_recvmsg(nni_socket *sock, nni_msg **msgp, nni_time expire)
}
-// nni_socket_protocol returns the socket's 16-bit protocol number.
+// nni_sock_protocol returns the socket's 16-bit protocol number.
uint16_t
-nni_socket_proto(nni_socket *sock)
+nni_sock_proto(nni_sock *sock)
{
return (sock->s_ops.proto_self);
}
int
-nni_socket_dial(nni_socket *sock, const char *addr, nni_endpt **epp, int flags)
+nni_sock_dial(nni_sock *sock, const char *addr, nni_endpt **epp, int flags)
{
nni_endpt *ep;
int rv;
@@ -349,7 +349,7 @@ nni_socket_dial(nni_socket *sock, const char *addr, nni_endpt **epp, int flags)
int
-nni_socket_listen(nni_socket *sock, const char *addr, nni_endpt **epp,
+nni_sock_listen(nni_sock *sock, const char *addr, nni_endpt **epp,
int flags)
{
nni_endpt *ep;
@@ -371,21 +371,21 @@ nni_socket_listen(nni_socket *sock, const char *addr, nni_endpt **epp,
void
-nni_socket_recverr(nni_socket *sock, int err)
+nni_sock_recverr(nni_sock *sock, int err)
{
sock->s_recverr = err;
}
void
-nni_socket_senderr(nni_socket *sock, int err)
+nni_sock_senderr(nni_sock *sock, int err)
{
sock->s_senderr = err;
}
int
-nni_socket_setopt(nni_socket *sock, int opt, const void *val, size_t size)
+nni_sock_setopt(nni_sock *sock, int opt, const void *val, size_t size)
{
size_t rsz;
void *ptr;
@@ -428,7 +428,7 @@ nni_socket_setopt(nni_socket *sock, int opt, const void *val, size_t size)
int
-nni_socket_getopt(nni_socket *sock, int opt, void *val, size_t *sizep)
+nni_sock_getopt(nni_sock *sock, int opt, void *val, size_t *sizep)
{
size_t rsz;
void *ptr;
diff --git a/src/core/socket.h b/src/core/socket.h
index bd0a5c8a..1808b09d 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -45,20 +45,32 @@ struct nng_socket {
uint32_t s_nextid; // Next Pipe ID.
};
-extern int nni_socket_create(nni_socket **, uint16_t);
-extern int nni_socket_close(nni_socket *);
-extern uint16_t nni_socket_proto(nni_socket *);
-extern int nni_socket_setopt(nni_socket *, int, const void *, size_t);
-extern int nni_socket_getopt(nni_socket *, int, void *, size_t *);
-extern int nni_socket_recvmsg(nni_socket *, nni_msg **, nni_time);
-extern int nni_socket_sendmsg(nni_socket *, nni_msg *, nni_time);
-extern int nni_socket_dial(nni_socket *, const char *, nni_endpt **, int);
-extern int nni_socket_listen(nni_socket *, const char *, nni_endpt **, int);
+extern int nni_sock_open(nni_sock **, uint16_t);
+extern int nni_sock_close(nni_sock *);
+extern uint16_t nni_sock_proto(nni_sock *);
+extern int nni_sock_setopt(nni_sock *, int, const void *, size_t);
+extern int nni_sock_getopt(nni_sock *, int, void *, size_t *);
+extern int nni_sock_recvmsg(nni_sock *, nni_msg **, nni_time);
+extern int nni_sock_sendmsg(nni_sock *, nni_msg *, nni_time);
+extern int nni_sock_dial(nni_sock *, const char *, nni_endpt **, int);
+extern int nni_sock_listen(nni_sock *, const char *, nni_endpt **, int);
// Set error codes for applications. These are only ever
// called from the filter functions in protocols, and thus
// already have the socket lock held.
-extern void nni_socket_recverr(nni_socket *, int);
-extern void nni_socket_senderr(nni_socket *, int);
+extern void nni_sock_recverr(nni_sock *, int);
+extern void nni_sock_senderr(nni_sock *, int);
+// These are socket methods that protocol operations can expect to call.
+// Note that each of these should be called without any locks held, since
+// the socket can reenter the protocol.
+
+// nni_socket_sendq obtains the upper writeq. The protocol should
+// recieve messages from this, and place them on the appropriate pipe.
+extern nni_msgq *nni_sock_sendq(nni_sock *);
+
+// nni_socket_recvq obtains the upper readq. The protocol should
+// inject incoming messages from pipes to it.
+extern nni_msgq *nni_sock_recvq(nni_sock *);
+
#endif // CORE_SOCKET_H