aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/gen_tcp.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-11-25 10:48:46 +0100
committerLukas Larsson <[email protected]>2011-12-01 14:10:02 +0100
commit0348a9c9c0114ddf83d776adc3d01ac60dfcccfc (patch)
tree109a4d4c9b55d5ef5a4a2cc2f49e9e64a1e748f5 /lib/kernel/src/gen_tcp.erl
parent5ba916ef7ac71bd1e7e23b4c87ae6a472f14fd6c (diff)
downloadotp-0348a9c9c0114ddf83d776adc3d01ac60dfcccfc.tar.gz
otp-0348a9c9c0114ddf83d776adc3d01ac60dfcccfc.tar.bz2
otp-0348a9c9c0114ddf83d776adc3d01ac60dfcccfc.zip
Implement sendfile using blocking io in asynch threads
Move the command handling to outputv in preparation for header and trailer inclusion in the sendfile api. Use the standard efile communication functions for sendfile.
Diffstat (limited to 'lib/kernel/src/gen_tcp.erl')
-rw-r--r--lib/kernel/src/gen_tcp.erl5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl
index 56eca4cda4..ea25dc3dc3 100644
--- a/lib/kernel/src/gen_tcp.erl
+++ b/lib/kernel/src/gen_tcp.erl
@@ -421,12 +421,15 @@ mod([], Address) ->
sendfile(#file_descriptor{ module = Mod } = Fd, Sock, Offset, Bytes,
ChunkSize, Headers, Trailers, Nodiskio, MNowait, Sync)
when is_port(Sock) ->
- case Mod:sendfile(Fd, Sock, Offset, Bytes, ChunkSize, Headers, Trailers,
+ {ok,SockFd} = prim_inet:stealfd(Sock),
+ case Mod:sendfile(Fd, SockFd, Offset, Bytes, ChunkSize, Headers, Trailers,
Nodiskio, MNowait, Sync) of
{error, enotsup} ->
+ prim_inet:returnfd(Sock),
sendfile_fallback(Fd, Sock, Offset, Bytes, ChunkSize,
Headers, Trailers);
Else ->
+ prim_inet:returnfd(Sock),
Else
end;
sendfile(_,_,_,_,_,_,_,_,_,_) ->