Changed send function to return false if it was not possible to send

This commit is contained in:
nifi 2008-06-26 11:38:59 +00:00
parent 63c620303a
commit 839b6111d6
3 changed files with 17 additions and 13 deletions

View file

@ -36,7 +36,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: collect.c,v 1.8 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: collect.c,v 1.9 2008/06/26 11:38:59 nifi Exp $
*/
/**
@ -300,7 +300,7 @@ collect_set_sink(struct collect_conn *tc, int should_be_sink)
update_rtmetric(tc);
}
/*---------------------------------------------------------------------------*/
void
int
collect_send(struct collect_conn *tc, int rexmits)
{
struct neighbor *n;
@ -320,6 +320,7 @@ collect_send(struct collect_conn *tc, int rexmits)
tc->cb->recv(&hdr->originator, hdr->originator_seqno,
hdr->hops);
}
return 1;
} else {
n = neighbor_best();
if(n != NULL) {
@ -327,7 +328,7 @@ collect_send(struct collect_conn *tc, int rexmits)
#if NETSIM
ether_set_line(n->addr.u8[0], n->addr.u8[1]);
#endif /* NETSIM */
ruc_send(&tc->ruc_conn, &n->addr, rexmits);
return ruc_send(&tc->ruc_conn, &n->addr, rexmits);
} else {
/* printf("Didn't find any neighbor\n");*/
PRINTF("%d.%d: did not find any neighbor to send to\n",
@ -335,6 +336,7 @@ collect_send(struct collect_conn *tc, int rexmits)
}
}
}
return 0;
}
/*---------------------------------------------------------------------------*/
int

View file

@ -47,7 +47,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: collect.h,v 1.4 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: collect.h,v 1.5 2008/06/26 11:38:59 nifi Exp $
*/
/**
@ -83,7 +83,7 @@ void collect_open(struct collect_conn *c, uint16_t channels,
const struct collect_callbacks *callbacks);
void collect_close(struct collect_conn *c);
void collect_send(struct collect_conn *c, int rexmits);
int collect_send(struct collect_conn *c, int rexmits);
void collect_set_sink(struct collect_conn *c, int should_be_sink);

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: ipolite.c,v 1.8 2008/06/26 11:19:22 adamdunkels Exp $
* $Id: ipolite.c,v 1.9 2008/06/26 11:38:59 nifi Exp $
*/
/**
@ -138,22 +138,24 @@ ipolite_send(struct ipolite_conn *c, clock_time_t interval, uint8_t hdrsize)
if(interval == 0) {
PRINTF("%d.%d: ipolite_send: interval 0\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
broadcast_send(&c->c);
if (broadcast_send(&c->c)) {
if(c->cb->sent) {
c->cb->sent(c);
}
return 1;
}
} else {
c->q = queuebuf_new_from_rimebuf();
if(c->q != NULL) {
ctimer_set(&c->t,
interval / 2 + (random_rand() % (interval / 2)),
send, c);
}
return 1;
}
PRINTF("%d.%d: ipolite_send: could not allocate queue buffer\n",
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1]);
}
return 0;
}
/*---------------------------------------------------------------------------*/