tinyos/tinyos-main — pull request #288 by bradjc (2014-06-11 11:50:37+00:00)
Title: BLIP: fix for memory not freed on send queue fail

If an outgoing packet fragment is unable to be added to the send queue, the fragment message_t and send_info were never put back in their pools. This patch cleans up that memory.

Addresses:

```
From: Jonas
Date: Tue, Jun 10, 2014 at 11:17 AM
Subject: [Tinyos-help] Blip - SendQueue - Potential memory leak?
To: tinyos-help@millennium.berkeley.edu

Hi everyone,

I am still working with BLIP and found a piece of code that made me
wonder if it could cause memory problems.
In the file is the interface command
that splits ip packets to fragments and enqueues these.
It starts by allocating a send_info and after this it allocates for
every fragment split both a send_entry and a message_t (from FragPool).
In all failure cases send_entry and message_t are put back to their
pools but when failing to enqueue them in SendQueue they aren't put back.
Since sendTask() only drops and 'put back's the fragments already
enqueued in SendQueue, we would loose a SendEntryPool-entry and a
FragPool-entry forever...

Some code to show what I meant:

struct send_info *s_info = getSendInfo();

while(BYTESLEFTTOSEND < BYTESPUTINFRAGMENTS) {
struct send_entry *s_entry = call SendEntryPool.get();
message_t *outgoing = call FragPool.get();

if (call SendQueue.enqueue(s_entry) != SUCCESS) {
s_info->failed = TRUE;
// Shouldn't they be put back?
// FragPool.put(outgoing);
// SendEntryPool.put()
}
}

Is this correct or did I do a mistake by ignoring something?

Best regards,
Jonas
```