Exemplo n.º 1
0
redisAsyncContext *redisAsyncConnectBind(const char *ip, int port,
                                         const char *source_addr) {
    redisContext *c = redisConnectBindNonBlock(ip,port,source_addr);
    redisAsyncContext *ac = redisAsyncInitialize(c);
    __redisAsyncCopyError(ac);
    return ac;
}
Exemplo n.º 2
0
redisAsyncContext *redisAsyncConnect(const char *ip, int port) {
    redisContext *c = redisConnectNonBlock(ip,port);
    redisAsyncContext *ac = redisAsyncInitialize(c);
    memset(ac->ip, 0, sizeof(ac->ip));
    memcpy(ac->ip, ip, strlen(ip));
    ac->port = port;
    __redisAsyncCopyError(ac);
    return ac;
}
Exemplo n.º 3
0
Arquivo: async.c Projeto: freb/rules
redisAsyncContext *redisAsyncConnectBind(const char *ip, int port, const char *source_addr) {
    SOCKADDR_STORAGE ss;
    redisContext *c = redisPreConnectNonBlock(ip, port, &ss);
    redisAsyncContext *ac = redisAsyncInitialize(c);
    if (aeWinSocketConnectBind(ac->c.fd, &ss, source_addr) != 0) {
        ac->c.err = errno;
        strerror_r(errno, ac->c.errstr, sizeof(ac->c.errstr));
    }
    __redisAsyncCopyError(ac);
    return ac;
}
Exemplo n.º 4
0
redisAsyncContext *redisAsyncConnect(const char *ip, int port) {
    struct sockaddr_in sa;
    redisContext *c = redisPreConnectNonBlock(ip, port, &sa);
    redisAsyncContext *ac = redisAsyncInitialize(c);
    if (aeWinSocketConnect(c->fd, (struct sockaddr *)&sa, sizeof(sa)) != 0) {
        c->err = errno;
        strerror_r(errno,c->errstr,sizeof(c->errstr));
    }
    __redisAsyncCopyError(ac);
    return ac;
}
Exemplo n.º 5
0
redisAsyncContext *redisAsyncConnectUnix(const char *path) {
    redisContext *c;
    redisAsyncContext *ac;

    c = redisConnectUnixNonBlock(path);
    if (c == NULL)
        return NULL;

    ac = redisAsyncInitialize(c);
    __redisAsyncCopyError(ac);
    return ac;
}
Exemplo n.º 6
0
redisAsyncContext *redisAsyncConnect(const char *ip, int port) {
    redisContext *c;
    redisAsyncContext *ac;

    c = redisConnectNonBlock(ip,port);
    if (c == NULL)
        return NULL;

    ac = redisAsyncInitialize(c);
    if (ac == NULL) {
        redisFree(c);
        return NULL;
    }

    __redisAsyncCopyError(ac);
    return ac;
}
Exemplo n.º 7
0
/* Helper function to make the disconnect happen and clean up. */
static void __redisAsyncDisconnect(redisAsyncContext *ac) {
    redisContext *c = &(ac->c);

    /* Make sure error is accessible if there is any */
    __redisAsyncCopyError(ac);

    if (ac->err == 0) {
        /* For clean disconnects, there should be no pending callbacks. */
        assert(__redisShiftCallback(&ac->replies,NULL) == REDIS_ERR);
    } else {
        /* Disconnection is caused by an error, make sure that pending
         * callbacks cannot call new commands. */
        c->flags |= REDIS_DISCONNECTING;
    }

    /* For non-clean disconnects, __redisAsyncFree() will execute pending
     * callbacks with a NULL-reply. */
    __redisAsyncFree(ac);
}
Exemplo n.º 8
0
// 非阻塞连接
redisAsyncContext *redisAsyncConnect(const char *ip, int port) {
    redisContext *c = redisConnectNonBlock(ip,port);
    redisAsyncContext *ac = redisAsyncInitialize(c);
    __redisAsyncCopyError(ac);
    return ac;
}