aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-11-16 16:07:48 +0100
committerLukas Larsson <[email protected]>2011-12-01 14:10:05 +0100
commitc68746bda431c5a068e6bb4a93bfe5ae77ce2d9a (patch)
tree19ddb406ed106a895dacacd5deedb79eccabfbf2
parent16b395a11ddc45ee8a36324ed0fb543f4065fc76 (diff)
downloadotp-c68746bda431c5a068e6bb4a93bfe5ae77ce2d9a.tar.gz
otp-c68746bda431c5a068e6bb4a93bfe5ae77ce2d9a.tar.bz2
otp-c68746bda431c5a068e6bb4a93bfe5ae77ce2d9a.zip
Remove support for file_server, sendfile has to be raw
Because the sending process has to be the controlling process of the tcp socket used to send data it is not possible to use the file_server
-rw-r--r--lib/kernel/src/file_io_server.erl9
-rw-r--r--lib/kernel/src/gen_tcp.erl18
2 files changed, 5 insertions, 22 deletions
diff --git a/lib/kernel/src/file_io_server.erl b/lib/kernel/src/file_io_server.erl
index 7280635f53..14da9c1a55 100644
--- a/lib/kernel/src/file_io_server.erl
+++ b/lib/kernel/src/file_io_server.erl
@@ -249,15 +249,6 @@ file_request(close,
file_request({position,At},
#state{handle=Handle,buf=Buf}=State) ->
std_reply(position(Handle, At, Buf), State);
-file_request({sendfile,DestSock,Offset,Bytes,Opts},
- #state{handle=Handle}=State) ->
- %% gen_tcp will call prim_file:sendfile with correct arguments
- case gen_tcp:sendfile(Handle, DestSock, Offset, Bytes, Opts) of
- {error,_}=Reply ->
- {stop,normal,Reply,State};
- Reply ->
- {reply,Reply,State}
- end;
file_request(truncate,
#state{handle=Handle}=State) ->
case ?PRIM_FILE:truncate(Handle) of
diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl
index 3f1e432f7a..9dd70ce5cc 100644
--- a/lib/kernel/src/gen_tcp.erl
+++ b/lib/kernel/src/gen_tcp.erl
@@ -317,23 +317,15 @@ unrecv(S, Data) when is_port(S) ->
-define(MAX_CHUNK_SIZE, (1 bsl 20)*20). %% 20 MB, has to fit in primary memory
-spec sendfile(File, Sock, Offset, Bytes, Opts) ->
- {'ok', non_neg_integer()} | {'error', inet:posix()} when
- File :: file:io_device(),
+ {'ok', non_neg_integer()} | {'error', inet:posix() } |
+ {'error', not_owner} when
+ File :: file:fd(),
Sock :: socket(),
Offset :: non_neg_integer(),
Bytes :: non_neg_integer(),
Opts :: [sendfile_option()].
-sendfile(File, Sock, Offset, Bytes, Opts) when is_pid(File) ->
- Ref = erlang:monitor(process, File),
- File ! {file_request,self(),File,
- {sendfile,Sock,Offset,Bytes,Opts}},
- receive
- {file_reply,File,Reply} ->
- erlang:demonitor(Ref,[flush]),
- Reply;
- {'DOWN', Ref, _, _, _} ->
- {error, terminated}
- end;
+sendfile(File, _Sock, _Offet, _Bytes, _Opts) when is_pid(File) ->
+ {error, badarg};
sendfile(File, Sock, Offset, Bytes, []) ->
sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, undefined, undefined,
false, false, false);