Improve reliability of tests with dummy interface

This commit is contained in:
Jeremy Lakeman 2012-09-19 16:32:25 +09:30
parent 0538e95be8
commit ac00c06a18
3 changed files with 18 additions and 5 deletions

View File

@ -395,6 +395,12 @@ static int add_explain_response(struct subscriber *subscriber, void *context){
response->please_explain->payload=ob_new();
ob_limitsize(response->please_explain->payload, 1024);
}
// if one of our identities is unknown,
// the header of our next payload must include our full sid.
if (subscriber->reachable==REACHABLE_SELF)
subscriber->send_full = 1;
// add the whole subscriber id to the payload, stop if we run out of space
DEBUGF("Adding full sid by way of explanation %s", alloca_tohex_sid(subscriber->sid));
if (ob_append_bytes(response->please_explain->payload, subscriber->sid, SID_SIZE))

View File

@ -619,7 +619,7 @@ void overlay_dummy_poll(struct sched_ent *alarm)
/* if there's no input, while we want to check for more soon,
we need to allow all other low priority alarms to fire first,
otherwise we'll dominate the scheduler without accomplishing anything */
alarm->alarm = gettime_ms() + 20;
alarm->alarm = gettime_ms() + 5;
if (interface->last_tick_ms != -1 && alarm->alarm > interface->last_tick_ms + interface->tick_ms)
alarm->alarm = interface->last_tick_ms + interface->tick_ms;
alarm->deadline = alarm->alarm + 10000;
@ -633,8 +633,8 @@ void overlay_dummy_poll(struct sched_ent *alarm)
if (nread == -1)
WHY_perror("read");
else {
interface->recv_offset += nread;
if (nread == sizeof packet) {
interface->recv_offset += nread;
plen = packet[110] + (packet[111] << 8);
if (plen > nread - 128)
plen = -1;
@ -658,9 +658,12 @@ void overlay_dummy_poll(struct sched_ent *alarm)
}
}
/* keep reading new packets as fast as possible,
but don't prevent other high priority alarms */
alarm->alarm = gettime_ms();
alarm->deadline = alarm->alarm + 200;
but don't completely prevent other high priority alarms */
if (interface->recv_offset >= length)
alarm->alarm = gettime_ms() + 5;
else
alarm->alarm = gettime_ms();
alarm->deadline = alarm->alarm + 100;
}
schedule(alarm);

View File

@ -258,6 +258,10 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
if (f.type==OF_TYPE_SELFANNOUNCE){
sender = f.source;
// skip the entire packet if it came from me
if (sender->reachable==REACHABLE_SELF)
break;
overlay_address_set_sender(f.source);
// if this is a dummy announcement for a node that isn't in our routing table