Beispiel #1
0
static VALUE blocking_function_execute(blocking_region_arg_t *arg)
{
    oci8_svcctx_t *svcctx = arg->svcctx;
    void *(*func)(void *) = arg->func;
    void *data = arg->data;
    struct timeval tv;
    sword rv;

    tv.tv_sec = 0;
    tv.tv_usec = 10000;
    svcctx->executing_thread = rb_thread_current();
    while ((rv = (sword)(VALUE)func(data)) == OCI_STILL_EXECUTING) {
        rb_thread_wait_for(tv);
        if (tv.tv_usec < 500000)
            tv.tv_usec <<= 1;
    }
    if (rv == OCI_ERROR) {
        if (oci8_get_error_code(oci8_errhp) == 1013) {
            OCIReset(svcctx->base.hp.ptr, oci8_errhp);
            svcctx->executing_thread = Qnil;
            rb_raise(eOCIBreak, "Canceled by user request.");
        }
    }
    svcctx->executing_thread = Qnil;
    return rv;
}
Beispiel #2
0
static VALUE blocking_function_ensure(oci8_svcctx_t *svcctx)
{
    if (!NIL_P(svcctx->executing_thread)) {
        /* The thread is killed. */
        OCIBreak(svcctx->base.hp.ptr, oci8_errhp);
        OCIReset(svcctx->base.hp.ptr, oci8_errhp);
        svcctx->executing_thread = Qnil;
    }
    return Qnil;
}
Beispiel #3
0
VALUE oci8_reset(VALUE self)
{
    oci8_handle_t *h;
    sword rv;

    Get_Handle(self, h); /* 0 */
    rv = OCIReset(h->hp, h->errhp);
    if (rv != OCI_SUCCESS)
        oci8_raise(h->errhp, rv, NULL);
    return self;
}
Beispiel #4
0
GSQLCursorState 
oracle_cursor_stop (GSQLCursor *cursor)
{
	GSQL_TRACE_FUNC;
	
	GSQLSession *session;
	GSQLEOracleSession *spec_session;
	GSQLEOracleCursor *spec_cursor;
	
	g_return_val_if_fail (GSQL_IS_CURSOR (cursor), GSQL_CURSOR_STATE_ERROR);
	
	session = cursor->session;
	spec_session = session->spec;
	spec_cursor = cursor->spec;
	
	OCIBreak (spec_session->svchp, spec_cursor->errhp);
	OCIReset (spec_session->svchp, spec_cursor->errhp);
	
	return GSQL_CURSOR_STATE_STOP;
	
}
Beispiel #5
0
/*
 * close current timelimited operation and disconnect if timeout occured
 * return true only if work in asynch mode and timeout detect
 */
int done_timelimit(ora_con_t* con, sword status)
{
    int ret = 0;

    if (!cur_asynch_mode)
        return 0;

    if (remap_status(con, status) == OCI_STILL_EXECUTING) {
        sword code;

        status = OCIBreak(con->svchp, con->errhp);
        if (status != OCI_SUCCESS)
            LM_ERR("driver: %s\n",
                   db_oracle_error(con, status));

        status = OCIReset(con->svchp, con->errhp);
        if (   status == OCI_ERROR
                && OCIErrorGet(con->errhp, 1, NULL, &code,
                               NULL, 0, OCI_HTYPE_ERROR) == OCI_SUCCESS
                && code == 1013)
        {
            status = OCI_SUCCESS;
        }
        if (status != OCI_SUCCESS)
            LM_ERR("driver: %s\n",
                   db_oracle_error(con, status));
        db_oracle_disconnect(con);
        ++ret;
    } else {
        status = change_mode(con);
        if (status != OCI_SUCCESS) {
            LM_ERR("driver: %s\n", db_oracle_error(con, status));
            ++ret;
        } else {
            cur_asynch_mode = 0;
        }
    }
    return ret;
}