improve readability

This commit is contained in:
Quentin Dufour 2019-03-27 14:17:41 +01:00
parent 6a22df4ac1
commit 83b205e2c8

View file

@ -169,11 +169,11 @@ void rr_pkt_register(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo,
char buffer[16];
url_get_port (buffer, fdinfo->url);
int link_num = atoi(buffer) - 7500; // @FIXME Hardcoded
rr->remote_links |= 1 << link_num; // Make sure that the link is marked as working
if (!(rr->remote_links & 1 << link_num)) {
printf("Activate link=%d\n", link_num);
show_link_availability (rr);
}
rr->remote_links |= 1 << link_num; // Make sure that the link is marked as working
}
void rr_deliver(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct deferred_pkt* dp) {
@ -332,17 +332,14 @@ int rr_on_udp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
int max = 10;
while(1) {
if (max-- < 0) break;
rr->current_link = (rr->current_link + 1) % 10;
//if (!(rr->my_links & (1 << rr->current_link))) continue;
if (!(rr->remote_links & (1 << rr->current_link))) continue;
if (max-- < 0) break; // We have an error
rr->current_link = (rr->current_link + 1) % 8;
if (!(rr->my_links & (1 << rr->current_link))) continue;
//if (!(rr->remote_links & (1 << rr->current_link))) continue;
sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + rr->current_link); //@FIXME Hardcoded
//printf("-- Trying %s\n", url);
to_fdinfo = evt_core_get_from_url (ctx, url);
if (to_fdinfo != NULL) {
//printf("Selected url %s for pkt %d to be sent on Tor\n", url, bp->ip.ap.str.id);
break;
}
if (to_fdinfo != NULL) break; // We found a good candidate
}
rr->emit_time = curr;
rr->sent_id++;
@ -405,8 +402,8 @@ int rr_on_timer(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
// !BLACKLIST LINK
printf("Blacklist link=%d\n", pkt->link_num);
show_link_availability (rr);
rr->remote_links &= 0xff ^ 1 << pkt->link_num;
show_link_availability (rr);
while (ring_lt(rr->recv_id, pkt->id)) {
rr->recv_id++;