@@ -148,12 +148,22 @@ master_send_receive(SyncMsg, NewAcc, Syncer, Ref, Parent) ->
148
148
{'EXIT' , Syncer , Reason } -> {stop , {sync_died , Reason }}
149
149
end .
150
150
151
- master_done ({Syncer , Ref , _Log , _HandleInfo , _EmitStats , Parent }, BQS ) ->
151
+ master_done ({Syncer , Ref , _Log , _HandleInfo , _EmitStats , Parent } = I , BQS ) ->
152
152
receive
153
- {next , Ref } -> stop_syncer (Syncer , {done , Ref }),
154
- {ok , BQS };
155
- {'EXIT' , Parent , Reason } -> {shutdown , Reason , BQS };
156
- {'EXIT' , Syncer , Reason } -> {sync_died , Reason , BQS }
153
+ {'$gen_call' , From ,
154
+ cancel_sync_mirrors } ->
155
+ stop_syncer (Syncer , {cancel , Ref }),
156
+ gen_server2 :reply (From , ok ),
157
+ {cancelled , BQS };
158
+ {cancelled , Ref } ->
159
+ {cancelled , BQS };
160
+ {next , Ref } ->
161
+ stop_syncer (Syncer , {done , Ref }),
162
+ {ok , BQS };
163
+ {'EXIT' , Parent , Reason } ->
164
+ {shutdown , Reason , BQS };
165
+ {'EXIT' , Syncer , Reason } ->
166
+ {sync_died , Reason , BQS }
157
167
end .
158
168
159
169
stop_syncer (Syncer , Msg ) ->
@@ -230,7 +240,7 @@ syncer_check_resources(Ref, MPid, SPids) ->
230
240
syncer_loop (Ref , MPid , SPids );
231
241
true ->
232
242
case wait_for_resources (Ref , SPids ) of
233
- cancel -> ok ;
243
+ cancel -> MPid ! { cancelled , Ref } ;
234
244
SPids1 -> MPid ! {next , Ref },
235
245
syncer_loop (Ref , MPid , SPids1 )
236
246
end
@@ -240,7 +250,7 @@ syncer_loop(Ref, MPid, SPids) ->
240
250
receive
241
251
{conserve_resources , memory , true } ->
242
252
case wait_for_resources (Ref , SPids ) of
243
- cancel -> ok ;
253
+ cancel -> MPid ! { cancelled , Ref } ;
244
254
SPids1 -> syncer_loop (Ref , MPid , SPids1 )
245
255
end ;
246
256
{conserve_resources , _ , _ } ->
0 commit comments