aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-11-29 11:05:37 +0100
committerLukas Larsson <[email protected]>2011-12-02 10:39:38 +0100
commit1bbf8cee44b8836d66d289cc0b5b314ed83de821 (patch)
tree6d7ab44fd0d11c33f885816ddb12dfbc785f4540 /lib/kernel
parent27faa34693f35b6aa41fa67cbfe365bd082a5757 (diff)
downloadotp-1bbf8cee44b8836d66d289cc0b5b314ed83de821.tar.gz
otp-1bbf8cee44b8836d66d289cc0b5b314ed83de821.tar.bz2
otp-1bbf8cee44b8836d66d289cc0b5b314ed83de821.zip
Remove header/trailer support
Since the API for headers/trailers seem to be very awkward to work with when using non-blocking io the feature is dropped for now. See unix_efile.c for more details.
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/doc/src/file.xml25
-rw-r--r--lib/kernel/src/file.erl15
-rw-r--r--lib/kernel/test/sendfile_SUITE.erl42
3 files changed, 6 insertions, 76 deletions
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index 7fcc354176..c6a1f25dd9 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -1602,35 +1602,10 @@
using file:read and gen_tcp:send is used.</p>
<p>The option list can contain the following options:
<taglist>
- <tag><c>headers</c></tag>
- <item>A list containing data which is to be sent before
- the file is sent. If <c>headers</c> is used, <c>Bytes</c> specifies
- the total bytes in the header and/or file to be sent. If
- <c>Bytes</c> is set to 0, the all headers, the file and
- possible trailers will be sent. </item>
- <tag><c>trailers</c></tag>
- <item>A list containing data which is to be after before
- the file is sent. All the <c>trailers</c> will be sent after the
- file is sent, no matter what <c>Bytes</c> is set to. </item>
<tag><c>chunk_size</c></tag>
<item>The chunk size used by the erlang fallback to send
data. If using the fallback, this should be set to a value
which comfortably fits in the systems memory. Default is 20 MB.</item>
- <tag><c>sf_nodiskio</c></tag>
- <item>This flag causes any sendfile() call which would
- block on disk I/O to instead return EBUSY. Busy servers may bene-
- fit by transferring requests that would block to a separate I/O
- worker thread.</item>
- <tag><c>sf_mnowait</c></tag>
- <item>Do not wait for some kernel resource to become avail-
- able, in particular, mbuf and sf_buf. The flag does not make the
- sendfile() syscall truly non-blocking, since other resources are
- still allocated in a blocking fashion.</item>
- <tag><c>sf_sync</c></tag>
- <item>sendfile sleeps until the network stack no longer refer-
- ences the VM pages of the file, making subsequent modifications to
- it safe. Please note that this is not a guarantee that the data
- has actually been sent.</item>
</taglist>
</p>
<p>On operating systems with thread support, it is recommended to use
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index 19eaa7bfcc..0b0f91d86a 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -106,10 +106,7 @@
-type date_time() :: calendar:datetime().
-type posix_file_advise() :: 'normal' | 'sequential' | 'random'
| 'no_reuse' | 'will_need' | 'dont_need'.
--type sendfile_option() :: {chunk_size, pos_integer()} |
- {headers, Hdrs :: list(iodata())} |
- {trailers, Tlrs :: list(iodata())} |
- sf_nodiskio | sf_mnowait | sf_sync.
+-type sendfile_option() :: {chunk_size, non_neg_integer()}.
%%%-----------------------------------------------------------------
%%% General functions
@@ -1144,11 +1141,11 @@ sendfile(File, Sock, Offset, Bytes, Opts) ->
?MAX_CHUNK_SIZE;
true -> ChunkSize0
end,
- Headers = proplists:get_value(headers, Opts, []),
- Trailers = proplists:get_value(trailers, Opts, []),
- sendfile(File, Sock, Offset, Bytes, ChunkSize, Headers, Trailers,
- lists:member(sf_nodiskio,Opts),lists:member(sf_mnowait,Opts),
- lists:member(sf_sync,Opts)).
+ %% Support for headers, trailers and options has been removed because the
+ %% Darwin and BSD API for using it does not play nice with
+ %% non-blocking sockets. See unix_efile.c for more info.
+ sendfile(File, Sock, Offset, Bytes, ChunkSize, [], [],
+ false,false,false).
%% sendfile/2
-spec sendfile(Filename, Socket) ->
diff --git a/lib/kernel/test/sendfile_SUITE.erl b/lib/kernel/test/sendfile_SUITE.erl
index cddb783fe7..5312508918 100644
--- a/lib/kernel/test/sendfile_SUITE.erl
+++ b/lib/kernel/test/sendfile_SUITE.erl
@@ -27,7 +27,6 @@
all() ->
[t_sendfile_small
,t_sendfile_big
-% ,t_sendfile_hdtl
,t_sendfile_partial
,t_sendfile_offset
,t_sendfile_sendafter
@@ -130,47 +129,6 @@ t_sendfile_offset(Config) ->
ok = sendfile_send(Send).
-t_sendfile_hdtl(Config) ->
- Filename = proplists:get_value(small_file, Config),
- FileOpts = proplists:get_value(file_opts, Config, []),
-
- Send = fun(Sock, Headers, Trailers, HdtlSize) ->
- {Size, Data} = sendfile_file_info(Filename),
- {ok,D} = file:open(Filename,[read|FileOpts]),
- AllSize = Size+HdtlSize,
- {ok, AllSize} = file:sendfile(
- D, Sock,0,0,
- [{headers,Headers},
- {trailers,Trailers}]),
- file:close(D),
- Data
- end,
-
- SendHdTl = fun(Sock) ->
- Headers = [<<"header1">>,<<0:(1024*8)>>,"header2"],
- Trailers = [<<"trailer1">>,"trailer2"],
- D = Send(Sock,Headers,Trailers,
- iolist_size([Headers,Trailers])),
- iolist_to_binary([Headers,D,Trailers])
- end,
- ok = sendfile_send(SendHdTl),
-
- SendHd = fun(Sock) ->
- Headers = [<<"header1">>,"header2"],
- D = Send(Sock,Headers,undefined,
- iolist_size([Headers])),
- iolist_to_binary([Headers,D])
- end,
- ok = sendfile_send(SendHd),
-
- SendTl = fun(Sock) ->
- Trailers = [<<"trailer1">>,"trailer2"],
- D = Send(Sock,undefined,Trailers,
- iolist_size([Trailers])),
- iolist_to_binary([D,Trailers])
- end,
- ok = sendfile_send(SendTl).
-
t_sendfile_sendafter(Config) ->
Filename = proplists:get_value(small_file, Config),