Skip to content

Commit

Permalink
Fix sol_socket to sol_tcp issue due to API change (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
yy-chen authored and priestjim committed Dec 20, 2018
1 parent 6e17cac commit d0b62e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/tcp.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
-define(DARWIN_TCP_KEEPCNT, 16#102). % number of keepalives before close

-define(LINUX_SOL_SOCKET, 16#0001).
-define(LINUX_SOL_TCP, 16#0006).
-define(LINUX_SO_KEEPALIVE, 16#0009).
-define(LINUX_TCP_KEEPIDLE, 16#4). % idle time used when SO_KEEPALIVE is enabled
-define(LINUX_TCP_KEEPINTVL, 16#5). % interval between keepalives
Expand Down
6 changes: 3 additions & 3 deletions src/driver/gen_rpc_driver_tcp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ set_socket_keepalive({unix, linux}, Socket) ->
{ok, KeepInterval} = application:get_env(?APP, socket_keepalive_interval),
{ok, KeepCount} = application:get_env(?APP, socket_keepalive_count),
ok = inet:setopts(Socket, [{raw, ?LINUX_SOL_SOCKET, ?LINUX_SO_KEEPALIVE, <<1:32/native>>}]),
ok = inet:setopts(Socket, [{raw, ?LINUX_SOL_SOCKET, ?LINUX_TCP_KEEPIDLE, <<KeepIdle:32/native>>}]),
ok = inet:setopts(Socket, [{raw, ?LINUX_SOL_SOCKET, ?LINUX_TCP_KEEPINTVL, <<KeepInterval:32/native>>}]),
ok = inet:setopts(Socket, [{raw, ?LINUX_SOL_SOCKET, ?LINUX_TCP_KEEPCNT, <<KeepCount:32/native>>}]),
ok = inet:setopts(Socket, [{raw, ?LINUX_SOL_TCP, ?LINUX_TCP_KEEPIDLE, <<KeepIdle:32/native>>}]),
ok = inet:setopts(Socket, [{raw, ?LINUX_SOL_TCP, ?LINUX_TCP_KEEPINTVL, <<KeepInterval:32/native>>}]),
ok = inet:setopts(Socket, [{raw, ?LINUX_SOL_TCP, ?LINUX_TCP_KEEPCNT, <<KeepCount:32/native>>}]),
ok;

set_socket_keepalive(_Unsupported, _Socket) ->
Expand Down

0 comments on commit d0b62e8

Please sign in to comment.