Ejemplo n.º 1
0
Archivo: oci8.c Proyecto: Vachman/STMT
/*
 * call-seq:
 *   logoff
 *
 * Disconnects from the Oracle server. The uncommitted transaction is
 * rollbacked.
 */
static VALUE oci8_svcctx_logoff(VALUE self)
{
    oci8_svcctx_t *svcctx = (oci8_svcctx_t *)DATA_PTR(self);
    sword rv;

    while (svcctx->base.children != NULL) {
        oci8_base_free(svcctx->base.children);
    }
    switch (svcctx->logon_type) {
    case T_IMPLICIT:
        oci_lc(OCITransRollback_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, OCI_DEFAULT));
        rv = OCILogoff_nb(svcctx, svcctx->base.hp.svc, oci8_errhp);
        svcctx->base.type = 0;
        svcctx->logon_type = T_NOT_LOGIN;
        if (rv != OCI_SUCCESS)
            oci8_raise(oci8_errhp, rv, NULL);
        svcctx->authhp = NULL;
        svcctx->srvhp = NULL;
        break;
    case T_EXPLICIT:
        oci_lc(OCITransRollback_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, OCI_DEFAULT));
        rv = OCISessionEnd_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, svcctx->authhp, OCI_DEFAULT);
        if (rv == OCI_SUCCESS) {
            rv = OCIServerDetach_nb(svcctx, svcctx->srvhp, oci8_errhp, OCI_DEFAULT);
        }
        svcctx->logon_type = T_NOT_LOGIN;
        if (rv != OCI_SUCCESS)
            oci8_raise(oci8_errhp, rv, NULL);
        break;
    case T_NOT_LOGIN:
        break;
    }
    return Qtrue;
}
Ejemplo n.º 2
0
static void call_session_end(oci8_svcctx_t *svcctx)
{
    sword rv = OCI_SUCCESS;

    if (svcctx->state & OCI8_STATE_SESSION_BEGIN_WAS_CALLED) {
        rv = OCISessionEnd_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, svcctx->session->hp.authhp, OCI_DEFAULT);
        svcctx->state &= ~OCI8_STATE_SESSION_BEGIN_WAS_CALLED;
    }
    if (svcctx->state & OCI8_STATE_SERVER_ATTACH_WAS_CALLED) {
        rv = OCIServerDetach_nb(svcctx, svcctx->server->hp.srvhp, oci8_errhp, OCI_DEFAULT);
        svcctx->state &= ~OCI8_STATE_SERVER_ATTACH_WAS_CALLED;
    }
    svcctx->logoff_method = NULL;
    if (rv != OCI_SUCCESS) {
        oci8_raise(oci8_errhp, rv, NULL);
    }
}