mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Only send broadcast ticks every 5 seconds when we have no neighbours
This commit is contained in:
parent
628a52ca87
commit
dabd482ad8
@ -739,8 +739,13 @@ static void overlay_interface_poll(struct sched_ent *alarm)
|
||||
|
||||
if (now >= interface->destination->last_tx+interface->destination->tick_ms)
|
||||
overlay_send_tick_packet(interface->destination);
|
||||
|
||||
alarm->alarm=interface->destination->last_tx+interface->destination->tick_ms;
|
||||
|
||||
time_ms_t interval = interface->destination->tick_ms;
|
||||
// only tick every 5s if we have no neighbours here
|
||||
if (interval < 5000 && !link_interface_has_neighbours(interface))
|
||||
interval = 5000;
|
||||
|
||||
alarm->alarm=interface->destination->last_tx+interval;
|
||||
alarm->deadline=alarm->alarm+interface->destination->tick_ms/2;
|
||||
}
|
||||
|
||||
|
16
route_link.c
16
route_link.c
@ -167,6 +167,7 @@ struct link_state{
|
||||
|
||||
DEFINE_ALARM(link_send);
|
||||
static int append_link(struct subscriber *subscriber, void *context);
|
||||
static int neighbour_find_best_link(struct neighbour *n);
|
||||
|
||||
struct neighbour *neighbours=NULL;
|
||||
int route_version=0;
|
||||
@ -725,10 +726,23 @@ void link_neighbour_status_html(struct strbuf *b, struct subscriber *neighbour)
|
||||
strbuf_puts(b, "Not found<br>");
|
||||
}
|
||||
|
||||
int link_has_neighbours(){
|
||||
int link_has_neighbours()
|
||||
{
|
||||
return neighbours?1:0;
|
||||
}
|
||||
|
||||
int link_interface_has_neighbours(struct overlay_interface *interface)
|
||||
{
|
||||
struct neighbour *n = neighbours;
|
||||
while(n){
|
||||
neighbour_find_best_link(n);
|
||||
if (n->best_link && n->best_link->interface == interface)
|
||||
return 1;
|
||||
n=n->_next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int send_legacy_self_announce_ack(struct neighbour *neighbour, struct link_in *link, time_ms_t now){
|
||||
struct overlay_frame *frame=emalloc_zero(sizeof(struct overlay_frame));
|
||||
frame->type = OF_TYPE_SELFANNOUNCE_ACK;
|
||||
|
1
serval.h
1
serval.h
@ -333,6 +333,7 @@ void link_neighbour_short_status_html(struct strbuf *b, const char *link_prefix)
|
||||
void link_neighbour_status_html(struct strbuf *b, struct subscriber *neighbour);
|
||||
int link_stop_routing(struct subscriber *subscriber);
|
||||
int link_has_neighbours();
|
||||
int link_interface_has_neighbours(struct overlay_interface *interface);
|
||||
|
||||
int generate_nonce(unsigned char *nonce,int bytes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user