@@ -302,7 +302,7 @@ maybe_close_lru_db(#server{lru=Lru}=Server) ->
302
302
303
303
open_async (Server , From , DbName , Filepath , Options ) ->
304
304
Parent = self (),
305
- put ({ async_open , DbName }, os :timestamp () ),
305
+ T0 = os :timestamp (),
306
306
Opener = spawn_link (fun () ->
307
307
Res = couch_db :start_link (DbName , Filepath , Options ),
308
308
case {Res , lists :member (create , Options )} of
@@ -311,7 +311,7 @@ open_async(Server, From, DbName, Filepath, Options) ->
311
311
_ ->
312
312
ok
313
313
end ,
314
- gen_server :call (Parent , {open_result , DbName , Res }, infinity ),
314
+ gen_server :call (Parent , {open_result , T0 , DbName , Res }, infinity ),
315
315
unlink (Parent )
316
316
end ),
317
317
ReqType = case lists :member (create , Options ) of
@@ -345,13 +345,11 @@ handle_call({set_max_dbs_open, Max}, _From, Server) ->
345
345
{reply , ok , Server # server {max_dbs_open = Max }};
346
346
handle_call (get_server , _From , Server ) ->
347
347
{reply , {ok , Server }, Server };
348
- handle_call ({open_result , DbName , {ok , Db }}, {FromPid , _Tag }, Server ) ->
348
+ handle_call ({open_result , T0 , DbName , {ok , Db }}, {FromPid , _Tag }, Server ) ->
349
349
link (Db # db .main_pid ),
350
350
true = ets :delete (couch_dbs_pid_to_name , FromPid ),
351
- case erase ({async_open , DbName }) of undefined -> ok ; T0 ->
352
- OpenTime = timer :now_diff (os :timestamp (), T0 ) / 1000 ,
353
- couch_stats :update_histogram ([couchdb , db_open_time ], OpenTime )
354
- end ,
351
+ OpenTime = timer :now_diff (os :timestamp (), T0 ) / 1000 ,
352
+ couch_stats :update_histogram ([couchdb , db_open_time ], OpenTime ),
355
353
% icky hack of field values - compactor_pid used to store clients
356
354
% and fd used to possibly store a creation request
357
355
[# db {fd = ReqType , compactor_pid = Froms }] = ets :lookup (couch_dbs , DbName ),
@@ -372,9 +370,9 @@ handle_call({open_result, DbName, {ok, Db}}, {FromPid, _Tag}, Server) ->
372
370
Server # server .lru
373
371
end ,
374
372
{reply , ok , Server # server {lru = Lru }};
375
- handle_call ({open_result , DbName , {error , eexist }}, From , Server ) ->
376
- handle_call ({open_result , DbName , file_exists }, From , Server );
377
- handle_call ({open_result , DbName , Error }, {FromPid , _Tag }, Server ) ->
373
+ handle_call ({open_result , T0 , DbName , {error , eexist }}, From , Server ) ->
374
+ handle_call ({open_result , T0 , DbName , file_exists }, From , Server );
375
+ handle_call ({open_result , _T0 , DbName , Error }, {FromPid , _Tag }, Server ) ->
378
376
% icky hack of field values - compactor_pid used to store clients
379
377
[# db {fd = ReqType , compactor_pid = Froms }= Db ] = ets :lookup (couch_dbs , DbName ),
380
378
[gen_server :reply (From , Error ) || From <- Froms ],
0 commit comments