Mercurial > cgi-bin > hgwebdir.cgi > VMS > C_Libraries > BestEffortMessaging
changeset 3:5c0fb7c519d7
Check for trigger counter overflow
author | Merten Sach <msach@mailbox.tu-berlin.de> |
---|---|
date | Tue, 13 Mar 2012 15:21:36 +0100 |
parents | b6dd31dbab8c |
children | 7ba5a3a6102d |
files | LossyCom.c LossyCom.h |
diffstat | 2 files changed, 23 insertions(+), 15 deletions(-) [+] |
line diff
1.1 --- a/LossyCom.c Mon Mar 12 18:35:10 2012 +0100 1.2 +++ b/LossyCom.c Tue Mar 13 15:21:36 2012 +0100 1.3 @@ -108,23 +108,30 @@ 1.4 { 1.5 msgCopy = localEndpoint->centralExchange->outboxArray[senderEndpointID]; 1.6 msgTrigger = 0xFFFF & (msgCopy >> TRIGGER_SHIFT); 1.7 - // check if the message is new (msg trigger > archived trigger) 1.8 - // and already valid (msgTrigger <= currentTriggerCopy) 1.9 - if(msgTrigger > localEndpoint->localTriggerCopy && 1.10 - msgTrigger <= currentTriggerCopy) 1.11 + 1.12 + 1.13 + if(msgTrigger > localEndpoint->localTriggerCopy || 1.14 + msgTrigger <= currentTriggerCopy) 1.15 { 1.16 - //printf("receive search until %d \n", currentTriggerCopy); 1.17 - //let the message handler parse the message 1.18 - msgBody = 0xFFFFFFFF & msgCopy; 1.19 - receiverID = 0xFFFF & (msgCopy >> ENDPOINT_ID_SHIFT); 1.20 - //only receive broadcast and p2p for own receiverID 1.21 - if(receiverID == BROADCAST_ID || 1.22 - receiverID == localEndpoint->endpointID) 1.23 + // check if the message is new (msg trigger > archived trigger) 1.24 + // and already valid (msgTrigger <= currentTriggerCopy) 1.25 + if((msgTrigger > localEndpoint->localTriggerCopy && 1.26 + msgTrigger <= currentTriggerCopy) || 1.27 + ((int64_t)currentTriggerCopy- // check for triggerCounterOverflow 1.28 + (int64_t)localEndpoint->localTriggerCopy < -MAX_TRIGGER/2)) 1.29 { 1.30 - (*(localEndpoint->msgHandler))(senderEndpointID, 1.31 - msgBody, 1.32 - localEndpoint->msgHandlerData); 1.33 - } 1.34 + //let the message handler parse the message 1.35 + msgBody = 0xFFFFFFFF & msgCopy; 1.36 + receiverID = 0xFFFF & (msgCopy >> ENDPOINT_ID_SHIFT); 1.37 + //only receive broadcast and p2p for own receiverID 1.38 + if(receiverID == BROADCAST_ID || 1.39 + receiverID == localEndpoint->endpointID) 1.40 + { 1.41 + (*(localEndpoint->msgHandler))(senderEndpointID, 1.42 + msgBody, 1.43 + localEndpoint->msgHandlerData); 1.44 + } 1.45 + } 1.46 } 1.47 } 1.48 senderEndpointID++;
2.1 --- a/LossyCom.h Mon Mar 12 18:35:10 2012 +0100 2.2 +++ b/LossyCom.h Tue Mar 13 15:21:36 2012 +0100 2.3 @@ -26,6 +26,7 @@ 2.4 ***********************************/ 2.5 //never use this number as a endpoint! 2.6 #define BROADCAST_ID 65535 2.7 +#define MAX_TRIGGER 65535 2.8 2.9 /*********************************** 2.10 * Type Definitions