aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/nifs/common/socket_util.c
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-09-28 18:40:08 +0200
committerMicael Karlberg <[email protected]>2018-09-28 18:40:08 +0200
commit1c412c62ba3be17b7a818f264049a7ee7942351e (patch)
tree675494d373a04c6b15ff0fc19b24725d5f95c986 /erts/emulator/nifs/common/socket_util.c
parent0b56a98366fc152c0fa5d5398220ac31866114d5 (diff)
downloadotp-1c412c62ba3be17b7a818f264049a7ee7942351e.tar.gz
otp-1c412c62ba3be17b7a818f264049a7ee7942351e.tar.bz2
otp-1c412c62ba3be17b7a818f264049a7ee7942351e.zip
[socket-nif] Add support for socket (level otp) buffer options
Add support for otp level socket options rcvbuf, rcvctrlbuf and sndctrlbuf. These options define default sizes for these buffers. The 'rcvbuf' is used when receiving messages when calling the recv, recvfrom and recvmsg functions. The 'rcvctrlbuf' is used for the control message header info when calling the recvmsg function. The 'sndctrlbuf' is used for the control message header info when calling the sendmsg function. OTP-14831
Diffstat (limited to 'erts/emulator/nifs/common/socket_util.c')
-rw-r--r--erts/emulator/nifs/common/socket_util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/erts/emulator/nifs/common/socket_util.c b/erts/emulator/nifs/common/socket_util.c
index 8bb725fb5b..ff50fd2384 100644
--- a/erts/emulator/nifs/common/socket_util.c
+++ b/erts/emulator/nifs/common/socket_util.c
@@ -1261,6 +1261,35 @@ char* esock_decode_protocol(ErlNifEnv* env,
+/* +++ esock_decode_bufsz +++
+ *
+ * Decode an buffer size. The size of a buffer is:
+ *
+ * Sz > 0 => Use provided value
+ * Sz => Use provided default
+ *
+ */
+extern
+char* esock_decode_bufsz(ErlNifEnv* env,
+ ERL_NIF_TERM eVal,
+ size_t defSz,
+ size_t* sz)
+{
+ int val;
+
+ if (!GET_INT(env, eVal, &val))
+ return ESOCK_STR_EINVAL;
+
+ if (val > 0)
+ *sz = (size_t) val;
+ else
+ *sz = defSz;
+
+ return NULL;
+}
+
+
+
/* *** esock_decode_string ***
*
* Decode a string value. A successful decode results in an