couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Kocoloski <kocol...@apache.org>
Subject Re: svn commit: r1001196 - /couchdb/trunk/src/couchdb/couch_file.erl
Date Mon, 27 Sep 2010 14:34:12 GMT
Hi Filipe, I'm quite certain that the file_descriptor is closed when couch_file dies.  I believe
what the man page means by that statement is that if you don't supply the 'raw' option, Erlang
will spawn a process to handle IO for the file.  That is, couch_file will send a message to
another process which owns the port, rather than couch_file owning the port itself.  Regards,

Adam

On Sep 25, 2010, at 7:26 AM, fdmanana@apache.org wrote:

> Author: fdmanana
> Date: Sat Sep 25 11:26:39 2010
> New Revision: 1001196
> 
> URL: http://svn.apache.org/viewvc?rev=1001196&view=rev
> Log:
> Explicitely close the file descriptor. It doesn't hurt.
> Also, since we open the file in 'raw' mode, I suspect the file descriptor is not closed
when the couch_file server dies.
> 
> From erl -man file:
> 
> "The raw option allows faster access to a file, because no Erlang process is needed to
handle the file."
> 
> For me, no Erlang process handling the file means that it's likely the file is not closed
by any other process.
> 
> 
> 
> Modified:
>    couchdb/trunk/src/couchdb/couch_file.erl
> 
> Modified: couchdb/trunk/src/couchdb/couch_file.erl
> URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_file.erl?rev=1001196&r1=1001195&r2=1001196&view=diff
> ==============================================================================
> --- couchdb/trunk/src/couchdb/couch_file.erl (original)
> +++ couchdb/trunk/src/couchdb/couch_file.erl Sat Sep 25 11:26:39 2010
> @@ -278,8 +278,8 @@ maybe_track_open_os_files(FileOptions) -
>         couch_stats_collector:track_process_count({couchdb, open_os_files})
>     end.
> 
> -terminate(_Reason, _Fd) ->
> -    ok.
> +terminate(_Reason, #file{fd = Fd}) ->
> +    ok = file:close(Fd).
> 
> 
> handle_call({pread_iolist, Pos}, _From, File) ->
> 
> 


Mime
View raw message