couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r954044 - in /couchdb/trunk/src/couchdb: couch_db_updater.erl couch_file.erl
Date Sat, 12 Jun 2010 19:14:17 GMT
Author: kocolosk
Date: Sat Jun 12 19:14:16 2010
New Revision: 954044

URL: http://svn.apache.org/viewvc?rev=954044&view=rev
Log:
more efficient header commits. COUCHDB-767

Modified:
    couchdb/trunk/src/couchdb/couch_db_updater.erl
    couchdb/trunk/src/couchdb/couch_file.erl

Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=954044&r1=954043&r2=954044&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Sat Jun 12 19:14:16 2010
@@ -681,6 +681,7 @@ commit_data(Db, true) ->
 commit_data(Db, _) ->
     #db{
         fd = Fd,
+        filepath = Filepath,
         header = OldHeader,
         fsync_options = FsyncOptions,
         waiting_delayed_commit = Timer
@@ -691,14 +692,14 @@ commit_data(Db, _) ->
         Db;
     Header ->
         case lists:member(before_header, FsyncOptions) of
-        true -> ok = couch_file:sync(Fd);
+        true -> ok = couch_file:sync(Filepath);
         _    -> ok
         end,
 
         ok = couch_file:write_header(Fd, Header),
 
         case lists:member(after_header, FsyncOptions) of
-        true -> ok = couch_file:sync(Fd);
+        true -> ok = couch_file:sync(Filepath);
         _    -> ok
         end,
 

Modified: couchdb/trunk/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_file.erl?rev=954044&r1=954043&r2=954044&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_file.erl (original)
+++ couchdb/trunk/src/couchdb/couch_file.erl Sat Jun 12 19:14:16 2010
@@ -146,6 +146,9 @@ truncate(Fd, Pos) ->
 %%  or {error, Reason}.
 %%----------------------------------------------------------------------
 
+sync(Filepath) when is_list(Filepath) ->
+    {ok, Fd} = file:open(Filepath, [read, raw]),
+    try file:sync(Fd) after file:close(Fd) end;
 sync(Fd) ->
     gen_server:call(Fd, sync, infinity).
 



Mime
View raw message