couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r748299 - in /couchdb/trunk: share/www/script/test/stats.js src/couchdb/Makefile.am src/couchdb/couch_file.erl src/couchdb/couch_file_stats.erl src/couchdb/couch_stats_aggregator.erl
Date Thu, 26 Feb 2009 21:01:25 GMT
Author: damien
Date: Thu Feb 26 21:01:24 2009
New Revision: 748299

URL: http://svn.apache.org/viewvc?rev=748299&view=rev
Log:
Fix and test for file descriptor leaks

Removed:
    couchdb/trunk/src/couchdb/couch_file_stats.erl
Modified:
    couchdb/trunk/share/www/script/test/stats.js
    couchdb/trunk/src/couchdb/Makefile.am
    couchdb/trunk/src/couchdb/couch_file.erl
    couchdb/trunk/src/couchdb/couch_stats_aggregator.erl

Modified: couchdb/trunk/share/www/script/test/stats.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/stats.js?rev=748299&r1=748298&r2=748299&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/stats.js (original)
+++ couchdb/trunk/share/www/script/test/stats.js Thu Feb 26 21:01:24 2009
@@ -56,6 +56,7 @@
           value: max.toString()}],
 
         function () {
+          var files_open = requestStatsTest("couchdb", "os_files_open").current;
           for(var i=0; i<max+1; i++) {
             var db = new CouchDB("test_suite_db" + i);
             db.deleteDb();
@@ -65,11 +66,11 @@
           var open_databases = requestStatsTest("couchdb", "open_databases").max;
           T(max >= open_databases, name);
 
-          // not needed for the test but cleanup is nice
           for(var i=0; i<max+1; i++) {
             var db = new CouchDB("test_suite_db" + i);
             db.deleteDb();
           }
+          T(files_open == requestStatsTest("couchdb", "os_files_open").current);
         })
     },
  };

Modified: couchdb/trunk/src/couchdb/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/Makefile.am?rev=748299&r1=748298&r2=748299&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/Makefile.am (original)
+++ couchdb/trunk/src/couchdb/Makefile.am Thu Feb 26 21:01:24 2009
@@ -51,7 +51,6 @@
     couch_external_manager.erl \
     couch_external_server.erl \
     couch_file.erl \
-    couch_file_stats.erl \
     couch_httpd.erl \
     couch_httpd_db.erl \
     couch_httpd_external.erl \
@@ -92,7 +91,6 @@
     couch_external_manager.beam \
     couch_external_server.beam \
     couch_file.beam \
-    couch_file_stats.beam \
     couch_httpd.beam \
     couch_httpd_db.beam \
     couch_httpd_external.beam \

Modified: couchdb/trunk/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_file.erl?rev=748299&r1=748298&r2=748299&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_file.erl (original)
+++ couchdb/trunk/src/couchdb/couch_file.erl Thu Feb 26 21:01:24 2009
@@ -35,7 +35,6 @@
     case gen_server:start_link(couch_file,
             {Filepath, Options, self(), Ref = make_ref()}, []) of
     {ok, Fd} ->
-        couch_file_stats:track_file(Fd),
         {ok, Fd};
     ignore ->
         % get the error
@@ -270,6 +269,7 @@
 % server functions
 
 init({Filepath, Options, ReturnPid, Ref}) ->
+    process_flag(trap_exit, true),
     case lists:member(create, Options) of
     true ->
         filelib:ensure_dir(Filepath),
@@ -285,12 +285,14 @@
                 true ->
                     {ok, 0} = file:position(Fd, 0),
                     ok = file:truncate(Fd),
+                    couch_stats_collector:increment({couchdb, os_files_open}),
                     {ok, Fd};
                 false ->
                     ok = file:close(Fd),
                     init_status_error(ReturnPid, Ref, file_exists)
                 end;
             false ->
+                couch_stats_collector:increment({couchdb, os_files_open}),
                 {ok, Fd}
             end;
         Error ->
@@ -302,6 +304,7 @@
         {ok, Fd_Read} ->
             {ok, Fd} = file:open(Filepath, [read, write, raw, binary]),
             ok = file:close(Fd_Read),
+            couch_stats_collector:increment({couchdb, os_files_open}),
             {ok, Fd};
         Error ->
             init_status_error(ReturnPid, Ref, Error)
@@ -310,6 +313,7 @@
 
 
 terminate(_Reason, _Fd) ->
+    couch_stats_collector:decrement({couchdb, os_files_open}),
     ok.
 
 
@@ -345,5 +349,5 @@
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
 
-handle_info(foo, Fd) ->
-    {stop, foo, Fd}.
+handle_info({'EXIT', _, Reason}, Fd) ->
+    {stop, Reason, Fd}.

Modified: couchdb/trunk/src/couchdb/couch_stats_aggregator.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_stats_aggregator.erl?rev=748299&r1=748298&r2=748299&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_stats_aggregator.erl (original)
+++ couchdb/trunk/src/couchdb/couch_stats_aggregator.erl Thu Feb 26 21:01:24 2009
@@ -299,6 +299,7 @@
     ets:insert(?MODULE, {{couchdb, database_changes}, <<"Number of times a database
was changed">>}),
     ets:insert(?MODULE, {{couchdb, database_reads}, <<"Number of times a document was
read from a database">>}),
     ets:insert(?MODULE, {{couchdb, open_databases}, <<"Number of open databases">>}),
+    ets:insert(?MODULE, {{couchdb, os_files_open}, <<"Number of file descriptors CouchDB
has open.">>}),
     ets:insert(?MODULE, {{couchdb, request_time}, <<"Length of a request inside CouchDB
without Mochiweb">>}),
 
     ets:insert(?MODULE, {{http_status_codes, '200'}, <<"Number of HTTP 200 OK responses">>}),



Mime
View raw message