aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/gen_tcp.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-11-25 11:16:54 +0100
committerLukas Larsson <[email protected]>2011-12-01 14:10:04 +0100
commit59e7e345ba51b7c2d6c9e479ce4cbb7c745c7893 (patch)
treec7a0583a81e70b6e70fca4ca2d06359719eab4e9 /lib/kernel/src/gen_tcp.erl
parenteccba49e87ad32248a678d90cfdf355ffd97015d (diff)
downloadotp-59e7e345ba51b7c2d6c9e479ce4cbb7c745c7893.tar.gz
otp-59e7e345ba51b7c2d6c9e479ce4cbb7c745c7893.tar.bz2
otp-59e7e345ba51b7c2d6c9e479ce4cbb7c745c7893.zip
Implement ignorefd for TCP
Ignore fd is a feature used by sendfile to temporarily remove all driver_select calls on that fd so that another driver can select on it. It also delays all actions which sends or receives data in that fd until in the fd is no longer ignored. Only the controlling_process should use the feature as it is otherwise possible that the ignore will never be cleaned up and hence create a memory leak in the driver. An ignored driver will not detect that an fd has been closed until it is unignored.
Diffstat (limited to 'lib/kernel/src/gen_tcp.erl')
-rw-r--r--lib/kernel/src/gen_tcp.erl7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl
index 26afed4ff9..3f1e432f7a 100644
--- a/lib/kernel/src/gen_tcp.erl
+++ b/lib/kernel/src/gen_tcp.erl
@@ -420,15 +420,16 @@ mod([], Address) ->
sendfile(#file_descriptor{ module = Mod } = Fd, Sock, Offset, Bytes,
ChunkSize, Headers, Trailers, Nodiskio, MNowait, Sync)
when is_port(Sock) ->
- {ok,SockFd} = prim_inet:stealfd(Sock),
+ ok = prim_inet:ignorefd(Sock,true),
+ {ok, SockFd} = prim_inet:getfd(Sock),
case Mod:sendfile(Fd, SockFd, Offset, Bytes, ChunkSize, Headers, Trailers,
Nodiskio, MNowait, Sync) of
{error, enotsup} ->
- prim_inet:returnfd(Sock),
+ ok = prim_inet:ignorefd(Sock,false),
sendfile_fallback(Fd, Sock, Offset, Bytes, ChunkSize,
Headers, Trailers);
Else ->
- prim_inet:returnfd(Sock),
+ ok = prim_inet:ignorefd(Sock,false),
Else
end;
sendfile(_,_,_,_,_,_,_,_,_,_) ->