summaryrefslogtreecommitdiff
path: root/src/core/device.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-04 12:37:34 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-04 13:13:24 -0700
commit45f455064b5704f3d5ed8ecf9f197a18fe72ee59 (patch)
tree76a626029f3a5a818b113b7e4342efaf6220a03f /src/core/device.c
parent505a9bce029e51540739c853a6c9eef0ecfb2e90 (diff)
downloadnng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.tar.gz
nng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.tar.bz2
nng-45f455064b5704f3d5ed8ecf9f197a18fe72ee59.zip
fixes #331 replace NNG_OPT_RAW option with constructor
This makes the raw mode something that is immutable, determined at socket construction. This is an enabling change for the separate context support coming soon. As a result, this is an API breaking change for users of the raw mode option (NNG_OPT_RAW). There aren't many of them out there. Cooked mode is entirely unaffected. There are changes to tests and documentation included.
Diffstat (limited to 'src/core/device.c')
-rw-r--r--src/core/device.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/core/device.c b/src/core/device.c
index 0eaec30e..6def9f64 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -105,6 +105,8 @@ nni_device_init(nni_device_data **dp, nni_sock *s1, nni_sock *s2)
nni_device_data *dd;
int npath = 2;
int i;
+ bool raw;
+ size_t rsz;
// Specifying either of these as null turns the device into
// a loopback reflector.
@@ -123,6 +125,21 @@ nni_device_init(nni_device_data **dp, nni_sock *s1, nni_sock *s2)
return (NNG_EINVAL);
}
+ raw = false;
+ rsz = sizeof(raw);
+ if (((nni_sock_getopt(s1, NNG_OPT_RAW, &raw, &rsz, NNI_TYPE_BOOL) !=
+ 0)) ||
+ (!raw)) {
+ return (NNG_EINVAL);
+ }
+
+ rsz = sizeof(raw);
+ if (((nni_sock_getopt(s2, NNG_OPT_RAW, &raw, &rsz, NNI_TYPE_BOOL) !=
+ 0)) ||
+ (!raw)) {
+ return (NNG_EINVAL);
+ }
+
// Note we assume that since they peers, we only need to look
// at the receive flags -- the other side is assumed to be able
// to send.
@@ -201,7 +218,7 @@ nni_device(nni_sock *s1, nni_sock *s2)
if ((rv = nni_aio_init(&aio, NULL, NULL)) != 0) {
return (rv);
}
- if (nni_device_init(&dd, s1, s2) != 0) {
+ if ((rv = nni_device_init(&dd, s1, s2)) != 0) {
nni_aio_fini(aio);
return (rv);
}