1
This commit is contained in:
1 parent
23622fc421
commit
92673d744a
1 file changed
+9
-8
@@ -80,7 +80,7 @@ struct ETCP_LINK* etcp_loadbalancer_select_link(struct ETCP_CONN* etcp) {
|
|||||||
// New: Send dgram (select link, encrypt/send, update shaper)
|
// New: Send dgram (select link, encrypt/send, update shaper)
|
||||||
void etcp_loadbalancer_send(struct ETCP_DGRAM* dgram) {
|
void etcp_loadbalancer_send(struct ETCP_DGRAM* dgram) {
|
||||||
if (!dgram) {
|
if (!dgram) {
|
||||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "etcp_loadbalancer_send: called with NULL dgram");
|
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "called with NULL dgram");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,8 @@ void etcp_loadbalancer_send(struct ETCP_DGRAM* dgram) {
|
|||||||
if (link->shaper_load_time_tb >= now_tb + SHAPER_BURST_DELAY_TB) {
|
if (link->shaper_load_time_tb >= now_tb + SHAPER_BURST_DELAY_TB) {
|
||||||
uint64_t wait_tb = link->shaper_load_time_tb - now_tb;
|
uint64_t wait_tb = link->shaper_load_time_tb - now_tb;
|
||||||
link->shaper_timer = uasync_set_timeout(link->etcp->instance->ua, wait_tb, link, shaper_timer_cb);
|
link->shaper_timer = uasync_set_timeout(link->etcp->instance->ua, wait_tb, link, shaper_timer_cb);
|
||||||
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] scheduled shaper timer (wait_tb=%llu)", etcp->log_name, (unsigned long long)wait_tb);
|
if (link->shaper_timer == NULL) DEBUG_ERROR(DEBUG_CATEGORY_TIMERS, "Filed to allocate timer");
|
||||||
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "[%s] scheduled shaper timer (wait_tb=%llu) BW=%d pkt_size=%d", etcp->log_name, (unsigned long long)wait_tb, link->bandwidth, pkt_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inactivity correction
|
// Inactivity correction
|
||||||
@@ -168,25 +169,25 @@ int loadbalancer_link_can_send(struct ETCP_LINK* link) {
|
|||||||
|
|
||||||
void loadbalancer_link_ready(struct ETCP_LINK* link) {
|
void loadbalancer_link_ready(struct ETCP_LINK* link) {
|
||||||
if (!link || !link->etcp) {
|
if (!link || !link->etcp) {
|
||||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "loadbalancer_link_ready: invalid link (%p)", link);
|
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "invalid link (%p)", link);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (loadbalancer_link_can_send(link) == 0) {
|
if (loadbalancer_link_can_send(link) == 0) {
|
||||||
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "loadbalancer_link_ready: link still blocked");
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "link still blocked");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "loadbalancer_link_ready: link=%p now ready, notifying ETCP_CONN", link);
|
DEBUG_TRACE(DEBUG_CATEGORY_ETCP, "link=%p now ready, notifying ETCP_CONN", link);
|
||||||
if (link->etcp->link_ready_for_send_fn) {
|
if (link->etcp->link_ready_for_send_fn) {
|
||||||
link->etcp->link_ready_for_send_fn(link->etcp);
|
link->etcp->link_ready_for_send_fn(link->etcp);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "loadbalancer_link_ready: no link_ready_for_send_fn set");
|
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "no link_ready_for_send_fn set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get ETCP link status: 1 = at least one link is up, 0 = all links down or no links
|
// Get ETCP link status: 1 = at least one link is up, 0 = all links down or no links
|
||||||
int etcp_loadbalancer_get_link_status(struct ETCP_CONN* etcp) {
|
int etcp_loadbalancer_get_link_status(struct ETCP_CONN* etcp) {
|
||||||
if (!etcp) {
|
if (!etcp) {
|
||||||
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "etcp_loadbalancer_get_link_status: NULL etcp");
|
DEBUG_WARN(DEBUG_CATEGORY_ETCP, "NULL etcp");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +213,7 @@ static void shaper_timer_cb(void* arg) {
|
|||||||
if (!link) return;
|
if (!link) return;
|
||||||
|
|
||||||
link->shaper_timer = NULL;
|
link->shaper_timer = NULL;
|
||||||
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "shaper_timer_cb: link=%p now ready", link);
|
DEBUG_DEBUG(DEBUG_CATEGORY_ETCP, "link=%p now ready", link);
|
||||||
|
|
||||||
// Notify loadbalancer that link is ready
|
// Notify loadbalancer that link is ready
|
||||||
loadbalancer_link_ready(link);
|
loadbalancer_link_ready(link);
|
||||||
|
|||||||
Reference in new issue
Block a user