Bug fix: update packet attributes in queued packets in CSMA instead of doing a full packetbuf copy after transmissions. The lower layers often add their own headers to packetbuf.

This commit is contained in:
Niclas Finne 2011-06-15 16:10:07 +02:00
parent 6a1469aeb2
commit e8a96dc202
3 changed files with 8 additions and 3 deletions

View File

@ -244,9 +244,7 @@ packet_sent(void *ptr, int status, int num_transmissions)
/* This is needed to correctly attribute energy that we spent
transmitting this packet. */
q = list_head(queued_packet_list);
queuebuf_free(q->buf);
q->buf = queuebuf_new_from_packetbuf();
queuebuf_update_attr_from_packetbuf(q->buf);
} else {
PRINTF("csma: drop with status %d after %d transmissions, %d collisions\n",

View File

@ -163,6 +163,12 @@ queuebuf_new_from_packetbuf(void)
}
/*---------------------------------------------------------------------------*/
void
queuebuf_update_attr_from_packetbuf(struct queuebuf *buf)
{
packetbuf_attr_copyto(buf->attrs, buf->addrs);
}
/*---------------------------------------------------------------------------*/
void
queuebuf_free(struct queuebuf *buf)
{
if(memb_inmemb(&bufmem, buf)) {

View File

@ -78,6 +78,7 @@ struct queuebuf *queuebuf_new_from_packetbuf_debug(const char *file, int line);
#else /* QUEUEBUF_DEBUG */
struct queuebuf *queuebuf_new_from_packetbuf(void);
#endif /* QUEUEBUF_DEBUG */
void queuebuf_update_attr_from_packetbuf(struct queuebuf *b);
void queuebuf_to_packetbuf(struct queuebuf *b);
void queuebuf_free(struct queuebuf *b);