Review Board 1.7.16

build_peer peer mailbox management bug

Review Request #4515 - Created March 19, 2015 and updated

trunk, 13, 11
During a reload, build_peer iterates over the peer's mailboxes and tags them for removal via the delme variable. It adds any new, unique mailboxes to the peer via add_peer_mailboxes and then removes any mailboxes with delme still set.

However, there isn't any code to unset delme, so this would remove any previously configured mailboxes.

That is not what happens though because build_peer also calls set_peer_defaults which clears out all of the configured mailboxes using clear_peer_mailboxes making the setting of delme redundant.

So in the end there is no impact to the user because all the configured mailboxes get added regardless.

Patch unsets delme for existing, still-configured mailboxes in add_peer_mailboxes and removes call to clear_peer_mailboxes.
Added new mailboxes to peer, reloaded chan_sip and verified that existing mailboxes were still there and new mailboxes had been added.

Removed mailboxes from peer, reloaded chan_sip and verified that those mailboxes were no longer assigned to peer.
Posted (March 19, 2015, 10:40 p.m.)


/trunk/channels/chan_sip.c (Diff revision 1)
This could result in a change of behaviour.  In build_peer 'first_pass' will no longer decide if the existing mailboxes get cleared, it would only be done when '!dev_state'.

I feel that a safer change would be to just remove the delme variable, let the current logic live on.  I could be convinced otherwise if you can show that the current logic produces the wrong results, but even then we'd have to very careful.
  1. My understanding of the code is that build_peer is only called with devstate_only=true for realtime peers not already cached in the peers table (rtcachefriends=yes) and the state of the peer is being checked via sip_devicestate [1].
    So firstpass=false should only happen for realtime peers that had been semi-built (peer exists and peer->the_mark=false) as the result of a sip_devicestate call.
    [1] sip_unregister also calls with devstate_only=true, but it also sets realtime=false so realtime_peer will not be called. runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to