Skip to content
This repository has been archived by the owner on Oct 24, 2019. It is now read-only.

fatal bug: 除零错误 #41

Open
AlexStocks opened this issue Dec 9, 2017 · 0 comments
Open

fatal bug: 除零错误 #41

AlexStocks opened this issue Dec 9, 2017 · 0 comments

Comments

@AlexStocks
Copy link

AlexStocks commented Dec 9, 2017

在测试nlb/src/api/nlbapi_test.c的时候发现:
nlb/src/api/nlbapi.c: calc_success_ratio最后一步req_total结果为0!!!

修改为:

float calc_success_ratio(struct shm_servers *shm_servers, struct server_info *server)
{
    uint32_t req_total;

    req_total = server->failed + server->success;

    if (req_total < shm_servers->shaping_request_min) {
        return 100.0;
    }

    return ((float)server->success) / (req_total == 0 ? 1e-6f : (float)(req_total));
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant