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

fatal bug: 除零错误 #41

@AlexStocks

Description

@AlexStocks

在测试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));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions