aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/core/socket.c38
-rw-r--r--src/core/socket.h5
3 files changed, 38 insertions, 7 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d8b045c9..7ac2a46f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -61,6 +61,8 @@ set (NNG_SOURCES
protocol/pair/pair.c
+ protocol/reqrep/req.c
+
transport/inproc/inproc.c
)
diff --git a/src/core/socket.c b/src/core/socket.c
index aabcab7c..8c734591 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -197,8 +197,7 @@ nni_socket_close(nni_socket *sock)
// Generally, unless the protocol is blocked trying to perform
// writes (e.g. a slow reader on the other side), it should be
- // trying to shut things down -- the normal flow is for it to
- // close pipes and call nni_sock_rem_pipe(). We wait to give it
+ // trying to shut things down. We wait to give it
// a chance to do so gracefully.
nni_mutex_enter(&sock->s_mx);
while (nni_list_first(&sock->s_pipes) != NULL) {
@@ -419,7 +418,7 @@ nni_socket_listen(nni_socket *sock, const char *addr, nni_endpt **epp,
}
-static int
+int
nni_setopt_duration(nni_duration *ptr, const void *val, size_t size)
{
nni_duration dur;
@@ -429,27 +428,52 @@ nni_setopt_duration(nni_duration *ptr, const void *val, size_t size)
}
memcpy(&dur, val, sizeof (dur));
if (dur < -1) {
- return (-EINVAL);
+ return (NNG_EINVAL);
}
*ptr = dur;
return (0);
}
-static int
+int
+nni_setopt_int(int *ptr, const void *val, size_t size)
+{
+ if (size != sizeof (*ptr)) {
+ return (NNG_EINVAL);
+ }
+ memcpy(ptr, val, sizeof (*ptr));
+ return (0);
+}
+
+
+int
nni_getopt_duration(nni_duration *ptr, void *val, size_t *sizep)
{
- size_t sz = sizeof (nni_duration);
+ size_t sz = sizeof (*ptr);
+
+ if (sz > *sizep) {
+ sz = *sizep;
+ }
+ *sizep = sizeof (*ptr);
+ memcpy(val, ptr, sz);
+ return (0);
+}
+
+int
+nni_getopt_int(int *ptr, void *val, size_t *sizep)
+{
+ size_t sz = sizeof (*ptr);
if (sz > *sizep) {
sz = *sizep;
}
- *sizep = sizeof (nni_duration);
+ *sizep = sizeof (*ptr);
memcpy(val, ptr, sz);
return (0);
}
+
static int
nni_setopt_buf(nni_msgqueue *mq, const void *val, size_t sz)
{
diff --git a/src/core/socket.h b/src/core/socket.h
index 37a0e5eb..35ddc36c 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -56,4 +56,9 @@ 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_setopt_duration(nni_duration *, const void *, size_t);
+extern int nni_getopt_duration(nni_duration *, void *, size_t *);
+extern int nni_setopt_int(int *, const void *, size_t);
+extern int nni_getopt_int(int *, void *, size_t *);
+
#endif // CORE_SOCKET_H