Hacker News new | ask | show | jobs
by viraptor 6038 days ago
Anyone diving inside the chan_sip is a brave, brave man. My general feeling from working with asterisk code is that if you ever, in any situation see code like this:

    while(pkt->owner->owner && ast_channel_trylock(pkt->owner->owner)) {
      sip_pvt_unlock(pkt->owner);
      usleep(1);
      sip_pvt_lock(pkt->owner);
    }
run! Run away and don't look back!

The code basically translates to - "as long as noone freed our important structure's owner-owner (but someone works on it) unlock our owner for a split-second so we don't deadlock and pray we don't crash" (if you want to know why we don't crash, ask oej, because he's the only person who can actually explain who holds which lock at this point and why the owner won't be freed - which of course leads to other people making modifications that break this rule).