Enforce mailboxes checked in increasing order
authorMark Spencer <markster@digium.com>
Sat, 24 May 2003 20:47:25 +0000 (20:47 +0000)
committerMark Spencer <markster@digium.com>
Sat, 24 May 2003 20:47:25 +0000 (20:47 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1054 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index a46c8e5..ac323bf 100755 (executable)
@@ -4617,6 +4617,8 @@ static void *do_monitor(void *data)
        struct sip_peer *peer;
        time_t t;
        int fastrestart =0;
+       int lastpeernum = -1;
+       int curpeernum;
        /* Add an I/O event to our UDP socket */
        if (sipsock > -1) 
                ast_io_add(io, sipsock, sipsock_read, AST_IO_IN, NULL);
@@ -4665,17 +4667,23 @@ restartsearch:
                peer = peerl.peers;
                time(&t);
                fastrestart = 0;
+               curpeernum = 0;
                while(peer) {
-                       if (strlen(peer->mailbox) && ((t - peer->lastmsgcheck) > 10)) {
+                       if ((curpeernum > lastpeernum) && strlen(peer->mailbox) && ((t - peer->lastmsgcheck) > 10)) {
                                sip_send_mwi_to_peer(peer);
                                fastrestart = 1;
+                               lastpeernum = curpeernum;
                                break;
                        }
+                       curpeernum++;
                        peer = peer->next;
                }
                /* Remember, sip_send_mwi_to_peer releases the lock if we've called it */
-               if (!peer)
+               if (!peer) {
+                       /* Reset where we come from */
+                       lastpeernum = -1;
                        ast_pthread_mutex_unlock(&peerl.lock);
+               }
                ast_pthread_mutex_unlock(&monlock);
        }
        /* Never reached */