Пример #1
0
struct connection *conn_get_server_from_pool(struct context *ctx, struct address *addr)
{
    struct connection *server = NULL;
    char key[DSN_LEN + 1];

    socket_get_key(addr, key);
    server = dict_get(&ctx->server_table, key);
    if (server != NULL) {
        if (verify_server(server) == CORVUS_ERR) return NULL;
        return server;
    }

    server = conn_create_server(ctx, addr, key);
    return server;
}
Пример #2
0
struct connection *conn_get_server_from_pool(struct context *ctx,
        struct address *addr, bool readonly)
{
    struct connection *server = NULL;
    char key[ADDRESS_LEN];
    snprintf(key, ADDRESS_LEN, "%s:%d", addr->ip, addr->port);

    server = dict_get(&ctx->server_table, key);
    if (server != NULL) {
        if (verify_server(server, readonly) == CORVUS_ERR) return NULL;
        return server;
    }

    server = conn_create_server(ctx, addr, key, readonly);
    return server;
}