• antirez's avatar
    Sentinel: fix cross-master Sentinel address update. · 026f9fc7
    antirez authored
    This commit both fixes the crash reported with issue #3364 and
    also properly closes the old links after the Sentinel address for the
    other masters gets updated.
    
    The two problems where:
    
    1. The Sentinel that switched address may not monitor all the masters,
       it is possible that there is no match, and the 'match' variable is
       NULL. Now we check for no match and 'continue' to the next master.
    
    2. By ispecting the code because of issue "1" I noticed that there was a
       problem in the code that disconnects the link of the Sentinel that
       needs the address update. Basically link->disconnected is non-zero
       even if just *a single link* (cc -- command link or pc -- pubsub
       link) are disconnected, so to check with if (link->disconnected)
       in order to close the links risks to leave one link connected.
    
    I was able to manually reproduce the crash at "1" and verify that the
    commit resolves the issue.
    
    Close #3364.
    026f9fc7
sentinel.c 166 KB