couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1038660 - /couchdb/trunk/src/couchdb/couch_rep_db_listener.erl
Date Wed, 24 Nov 2010 16:05:17 GMT
Author: fdmanana
Date: Wed Nov 24 16:05:17 2010
New Revision: 1038660

URL: http://svn.apache.org/viewvc?rev=1038660&view=rev
Log:
Replicator DB: fix a rare gen_server death case. Happened when the rep_db_created message
is received before the changes loop dies.
Also simplified a bit the handling of subprocesses exits.


Modified:
    couchdb/trunk/src/couchdb/couch_rep_db_listener.erl

Modified: couchdb/trunk/src/couchdb/couch_rep_db_listener.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_db_listener.erl?rev=1038660&r1=1038659&r2=1038660&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_rep_db_listener.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_db_listener.erl Wed Nov 24 16:05:17 2010
@@ -63,12 +63,15 @@ handle_cast(rep_db_changed, State) ->
         changes_feed_loop = Loop,
         changes_queue = Queue
     } = State,
-    exit(Loop, rep_db_changed),
+    unlink(Loop),
+    catch exit(Loop, rep_db_changed),
     couch_work_queue:queue(Queue, stop_all_replications),
     {ok, NewLoop} = changes_feed_loop(Queue),
     {noreply, State#state{changes_feed_loop = NewLoop}};
 
-handle_cast(rep_db_created, #state{changes_feed_loop = nil} = State) ->
+handle_cast(rep_db_created, #state{changes_feed_loop = Loop} = State) ->
+    unlink(Loop),
+    catch exit(Loop, rep_db_changed),
     {ok, NewLoop} = changes_feed_loop(State#state.changes_queue),
     {noreply, State#state{changes_feed_loop = NewLoop}};
 
@@ -86,9 +89,6 @@ handle_info({'EXIT', From, Reason}, #sta
     ?LOG_ERROR("Database update notifier died. Reason: ~p", [Reason]),
     {stop, {db_update_notifier_died, Reason}, State};
 
-handle_info({'EXIT', _OldChangesLoop, rep_db_changed}, State) ->
-    {noreply, State};
-
 handle_info({'EXIT', From, Reason}, #state{changes_processor = From} = State) ->
     ?LOG_ERROR("Replicator DB changes processor died. Reason: ~p", [Reason]),
     {stop, {rep_db_changes_processor_died, Reason}, State}.



Mime
View raw message