diff options
author | Micael Karlberg <[email protected]> | 2018-05-08 15:26:41 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-09-18 13:01:37 +0200 |
commit | 56641fca11c50306c6c62266844f7828e325ae7d (patch) | |
tree | c0e68da6142b80b977093c91db1a15acfa3ad8f2 | |
parent | 7bc2d3e8618f561185694ae11afe4fc83b1f72f3 (diff) | |
download | otp-56641fca11c50306c6c62266844f7828e325ae7d.tar.gz otp-56641fca11c50306c6c62266844f7828e325ae7d.tar.bz2 otp-56641fca11c50306c6c62266844f7828e325ae7d.zip |
[socket-nif] setopt of socket option priority
-rw-r--r-- | erts/emulator/nifs/common/socket_nif.c | 15 | ||||
-rw-r--r-- | erts/preloaded/src/socket.erl | 7 |
2 files changed, 20 insertions, 2 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c index 843543b42b..905e04848c 100644 --- a/erts/emulator/nifs/common/socket_nif.c +++ b/erts/emulator/nifs/common/socket_nif.c @@ -361,6 +361,7 @@ typedef union { #define SOCKET_OPT_SOCK_KEEPALIVE 9 #define SOCKET_OPT_SOCK_LINGER 10 +#define SOCKET_OPT_SOCK_PRIORITY 16 #define SOCKET_OPT_SOCK_REUSEADDR 21 #define SOCKET_OPT_IP_RECVTOS 0 @@ -3431,6 +3432,20 @@ BOOLEAN_T eoptval2optval_socket(ErlNifEnv* env, break; #endif +#if defined(SO_PRIORITY) + case SOCKET_OPT_SOCK_PRIORITY: + if (GET_INT(env, eVal, &valP->u.intVal)) { + valP->tag = SOCKET_OPT_VALUE_INT; + *opt = SO_PRIORITY; + return TRUE; + } else { + *opt = -1; + valP->tag = SOCKET_OPT_VALUE_UNDEF; + return FALSE; + } + break; +#endif + #if defined(SO_REUSEADDR) case SOCKET_OPT_SOCK_REUSEADDR: { diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index 6b245c41f0..4c903bb759 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -434,6 +434,7 @@ -define(SOCKET_OPT_SOCK_KEEPALIVE, 9). -define(SOCKET_OPT_SOCK_LINGER, 10). +-define(SOCKET_OPT_SOCK_PRIORITY, 16). -define(SOCKET_OPT_SOCK_REUSEADDR, 21). -define(SOCKET_OPT_IP_RECVTOS, 0). @@ -1615,6 +1616,8 @@ enc_setopt_value(socket, linger, abort, D, T, P) -> enc_setopt_value(socket, linger, {OnOff, Secs} = V, _D, _T, _P) when is_boolean(OnOff) andalso is_integer(Secs) andalso (Secs >= 0) -> V; +enc_setopt_value(socket, priority, V, _D, _T, _P) when is_integer(V) -> + V; enc_setopt_value(socket, reuseaddr, V, _D, _T, _P) when is_boolean(V) -> V; enc_setopt_value(socket = L, Opt, V, _D, _T, _P) -> @@ -1821,8 +1824,8 @@ enc_sockopt_key(socket, peek_off = Opt, _Dir, local = _D, _T, _P) -> not_supported(Opt); enc_sockopt_key(socket, peek_cred = Opt, get = _Dir, _D, _T, _P) -> not_supported(Opt); -enc_sockopt_key(socket, priority = Opt, _Dir, _D, _T, _P) -> - not_supported(Opt); +enc_sockopt_key(socket, priority = _Opt, _Dir, _D, _T, _P) -> + ?SOCKET_OPT_SOCK_PRIORITY; enc_sockopt_key(socket, rcvbuf = Opt, _Dir, _D, _T, _P) -> not_supported(Opt); enc_sockopt_key(socket, rcvbufforce = Opt, _Dir, _D, _T, _P) -> |