EV-Redis

 view release on metacpan or  search on metacpan

src/EV__Redis.xs  view on Meta::CPAN

        }

        q = ngx_queue_head(&local_queue);
        cbt = ngx_queue_data(q, ev_redis_cb_t, queue);
        ngx_queue_remove(q);

        /* Mark as skipped FIRST to prevent double callback invocation if
         * invoke_callback_error re-enters the event loop. */
        cbt->skipped = 1;

        /* Re-initialize queue node so any subsequent remove (from reply_cb's
         * skipped path on re-entry) is safe. */
        ngx_queue_init(q);
        if (!cbt->persist) self->pending_count--;

        /* Save and clear callback BEFORE invoking — if the user callback
         * re-enters and a Redis reply arrives, reply_cb sees skipped=1
         * and frees cbt. Clearing cb first avoids use-after-free. */
        if (NULL != cbt->cb) {
            SV* cb_to_invoke = cbt->cb;
            cbt->cb = NULL;

            invoke_callback_error(cb_to_invoke, err_skipped);
            SvREFCNT_dec(cb_to_invoke);
        }
    }

    self->in_cb_cleanup = 0;

    self->callback_depth--;
    check_destroyed(self);
}

int
has_ssl(char* class);
CODE:
{
    PERL_UNUSED_VAR(class);
#ifdef EV_REDIS_SSL
    RETVAL = 1;
#else
    RETVAL = 0;
#endif
}
OUTPUT:
    RETVAL

#ifdef EV_REDIS_SSL

void
_setup_ssl_context(EV::Redis self, SV* cacert, SV* capath, SV* cert, SV* key, SV* server_name, int verify = 1);
CODE:
{
    redisSSLContextError ssl_error = REDIS_SSL_CTX_NONE;
    redisSSLOptions ssl_opts;

    memset(&ssl_opts, 0, sizeof(ssl_opts));
    ssl_opts.cacert_filename = (SvOK(cacert)) ? SvPV_nolen(cacert) : NULL;
    ssl_opts.capath = (SvOK(capath)) ? SvPV_nolen(capath) : NULL;
    ssl_opts.cert_filename = (SvOK(cert)) ? SvPV_nolen(cert) : NULL;
    ssl_opts.private_key_filename = (SvOK(key)) ? SvPV_nolen(key) : NULL;
    ssl_opts.server_name = (SvOK(server_name)) ? SvPV_nolen(server_name) : NULL;
    ssl_opts.verify_mode = verify ? REDIS_SSL_VERIFY_PEER : REDIS_SSL_VERIFY_NONE;

    /* Free existing SSL context if any */
    if (NULL != self->ssl_ctx) {
        redisFreeSSLContext(self->ssl_ctx);
        self->ssl_ctx = NULL;
    }

    self->ssl_ctx = redisCreateSSLContextWithOptions(&ssl_opts, &ssl_error);

    if (NULL == self->ssl_ctx) {
        croak("SSL context creation failed: %s", redisSSLContextGetError(ssl_error));
    }
}

#endif



( run in 1.788 second using v1.01-cache-2.11-cpan-39bf76dae61 )