]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/system/AMQueueImplP.nc
Patch from John Regehr. Make queue catch it when the underlying radio
[tinyos-2.x.git] / tos / system / AMQueueImplP.nc
index 8ea5c7aa1c5444dbfe7b142204d95bb3e7dfa8ce..51cd2aece1c3f83eee2531e2b3a4a925db67e151 100644 (file)
@@ -179,13 +179,21 @@ implementation {
     }
   
     event void AMSend.sendDone[am_id_t id](message_t* msg, error_t err) {
-        if(queue[current].msg == msg) {
-            sendDone(current, msg, err);
-        }
-        else {
-            dbg("PointerBug", "%s received send done for %p, signaling for %p.\n",
-                __FUNCTION__, msg, queue[current].msg);
-        }
+      // Bug fix from John Regehr: if the underlying radio mixes things
+      // up, we don't want to read memory incorrectly. This can occur
+      // on the mica2.
+      // Note that since all AM packets go through this queue, this
+      // means that the radio has a problem. -pal
+      if (current >= numClients) {
+       return;
+      }
+      if(queue[current].msg == msg) {
+       sendDone(current, msg, err);
+      }
+      else {
+       dbg("PointerBug", "%s received send done for %p, signaling for %p.\n",
+           __FUNCTION__, msg, queue[current].msg);
+      }
     }
     
     command uint8_t Send.maxPayloadLength[uint8_t id]() {