Better loop to choose links
This commit is contained in:
parent
d48c5753fb
commit
ef49d07dd9
1 changed files with 9 additions and 5 deletions
|
@ -293,17 +293,21 @@ int rr_on_udp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
|||
bp->ip.ap.str.bitfield = rr->remote_links;
|
||||
bp->ip.ap.str.prevlink = rr->current_link;
|
||||
|
||||
do {
|
||||
int max = 10;
|
||||
while(1) {
|
||||
if (max-- < 0) break;
|
||||
rr->current_link = (rr->current_link) + 1 % 10;
|
||||
} while (!(rr->my_links & (1 << rr->current_link)));
|
||||
if (!(rr->my_links & (1 << rr->current_link))) continue;
|
||||
sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + rr->current_link); //@FIXME Hardcoded
|
||||
to_fdinfo = evt_core_get_from_url (ctx, url);
|
||||
if (to_fdinfo != NULL) break;
|
||||
}
|
||||
rr->emit_time = curr;
|
||||
rr->sent_id++;
|
||||
|
||||
// 4. A whole packet has been read, we will find someone to write it
|
||||
sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + rr->current_link); //@FIXME Hardcoded
|
||||
to_fdinfo = evt_core_get_from_url (ctx, url);
|
||||
if (to_fdinfo == NULL) {
|
||||
fprintf(stderr, "No fd for URL %s in udp-read. Dropping packet :( \n", url);
|
||||
fprintf(stderr, "No fd for URL %s in udp-read. Dropping packet :( \n", fdinfo->url);
|
||||
mv_buffer_wtor (app_ctx, fdinfo, bp);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue