Changeset 3801

Show
Ignore:
Timestamp:
08/31/06 11:43:54 (8 years ago)
Author:
piers
Message:

Fixed MBUS seqnum size - introduced wrapping at 999999 - since a number of pieces of code
assume that the seqnum is never longer than 6 digits. This was a problem when the mbus was
used for long periods of time - leading to memroy errors.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • common/trunk/src/mbus.c

    r3751 r3801  
    429429        gettimeofday(&curr_time, NULL); 
    430430        if (curr_time.tv_sec - m->last_heartbeat.tv_sec >= interval) { 
    431             mb_header(++m->seqnum, curr_time, 'U', m->addr, "()", -1); 
     431            m->seqnum=(++m->seqnum)%999999; 
     432            mb_header(m->seqnum, curr_time, 'U', m->addr, "()", -1); 
    432433                mb_add_command("mbus.hello", ""); 
    433434                mb_send(m); 
     
    697698        curr->retransmit_count = 0; 
    698699        curr->message_size     = alen + 60 + strlen(dest) + strlen(m->addr); 
    699         curr->seqnum           = ++m->seqnum; 
     700        m->seqnum              = (++m->seqnum)%999999; 
     701        curr->seqnum           = m->seqnum; 
    700702        curr->reliable         = reliable; 
    701703        curr->complete         = FALSE; 
     
    907909 
    908910                                gettimeofday(&t, NULL); 
    909                                 mb_header(++m->seqnum, t, 'U', m->addr, newsrc, seq); 
     911                                m->seqnum=(++m->seqnum)%999999; 
     912                                mb_header(m->seqnum, t, 'U', m->addr, newsrc, seq); 
    910913                                mb_send(m); 
    911914