Esempio n. 1
0
static void innostore_drv_finish()
{
    erl_drv_mutex_destroy(G_ENGINE_STATE_LOCK);

    // Shutdown the engine, if it's running -- note that this blocks the
    // the calling VM thread and may be a long running operation.
    if (G_ENGINE_STATE == ENGINE_STARTED)
    {
        ib_err_t result = ib_shutdown(IB_SHUTDOWN_NORMAL);
        if (result != DB_SUCCESS)
        {
            log("ib_shutdown failed: %s\n", ib_strerror(result));
        }
    }

    // Clean up logging after inno has shutdown completely
    erl_drv_mutex_destroy(G_LOGGER_LOCK); 
    if (G_LOGGER_BUF != NULL)
    {
        driver_free(G_LOGGER_BUF);
        G_LOGGER_BUF = NULL;
        G_LOGGER_SIZE = 0;
    }
    if (G_LOGGER_FH != NULL)
    {
        fclose(G_LOGGER_FH);
        G_LOGGER_FH = NULL;
        G_LOGGER_FN = raw_logger;
    }

    G_ENGINE_STATE = ENGINE_STOPPED;
}
Esempio n. 2
0
void stop_native_gui(wxe_data *sd)
{
  erl_drv_thread_join(wxe_thread, NULL);
  erl_drv_mutex_destroy(wxe_status_m);
  erl_drv_cond_destroy(wxe_status_c);
  erl_drv_mutex_destroy(wxe_batch_locker_m);
  erl_drv_cond_destroy(wxe_batch_locker_c);
}
Esempio n. 3
0
void stop_native_gui(wxe_data *sd)
{
    if(wxe_status == WXE_INITIATED) {
        meta_command(WXE_SHUTDOWN, sd);
    }
#ifdef __DARWIN__
    erl_drv_stolen_main_thread_join(wxe_thread, NULL);
#else
    erl_drv_thread_join(wxe_thread, NULL);
#endif
    erl_drv_mutex_destroy(wxe_status_m);
    erl_drv_cond_destroy(wxe_status_c);
    erl_drv_mutex_destroy(wxe_batch_locker_m);
    erl_drv_cond_destroy(wxe_batch_locker_c);
}
Esempio n. 4
0
static void stop(ErlDrvData drv_data)
{
    Otp9302Data *data = (Otp9302Data *) drv_data;
    if (!data->smp)
	erl_drv_mutex_destroy(data->msgq.mtx);
    driver_free(data);
}
Esempio n. 5
0
void bdberl_tpool_stop(TPool* tpool)
{
    LOCK(tpool);

    // Set the shutdown flag and broadcast a notification
    tpool->shutdown = 1;
    erl_drv_cond_broadcast(tpool->work_cv);

    // Clean out the queue of pending jobs -- invoke their cleanup function

    // Wait for until active_threads hits zero
    while (tpool->active_threads > 0)
    {
        erl_drv_cond_wait(tpool->work_cv, tpool->lock);
    }
    
    // Join up with all the workers
    int i = 0;
    for (i = 0; i < tpool->thread_count; i++)
    {
        erl_drv_thread_join(tpool->threads[i], 0);
    }

    // Cleanup 
    erl_drv_cond_destroy(tpool->work_cv);
    erl_drv_cond_destroy(tpool->cancel_cv);
    driver_free(tpool->threads);
    UNLOCK(tpool);
    erl_drv_mutex_destroy(tpool->lock);
    driver_free(tpool);
}
Esempio n. 6
0
static void innostore_drv_stop(ErlDrvData handle)
{
    PortState* state = (PortState*)handle;

    // Grab the worker lock, in case we have an job running
    erl_drv_mutex_lock(state->worker_lock);

    // Signal the shutdown and wait until the current operation has completed
    state->shutdown_flag = 1;
    erl_drv_cond_signal(state->worker_cv);

    while (state->op)
    {
        erl_drv_cond_wait(state->worker_cv, state->worker_lock);
    }

    // If the port state is not marked as READY, close the cursor and abort the txn
    if (state->port_state != STATE_READY)
    {
        ib_cursor_close(state->cursor);
        ib_trx_rollback(state->txn);
    }

    // No pending jobs and we have the lock again -- join our worker thread
    erl_drv_cond_signal(state->worker_cv);
    erl_drv_mutex_unlock(state->worker_lock);
    erl_drv_thread_join(state->worker, 0);

    // Cleanup
    erl_drv_cond_destroy(state->worker_cv);
    erl_drv_mutex_destroy(state->worker_lock);
    driver_free(handle);
}
Esempio n. 7
0
File: lock.c Progetto: mihawk/yatce
void mutex_fini(mutex_t* mutex){
#ifdef USE_PTHREAD
  pthread_mutex_destroy(mutex);
  //  free(mutex);
#elif defined  USE_ETHREAD
  erl_drv_mutex_destroy(*mutex);
#endif
}
Esempio n. 8
0
static ErlDrvData innostore_drv_start(ErlDrvPort port, char* buffer)
{
    PortState* state = (PortState*)driver_alloc(sizeof(PortState));
    int worker_rc;

    memset(state, '\0', sizeof(PortState));

    // Save handle to the port
    state->port = port;

    // Save the owner PID
    state->port_owner = driver_connected(port);

    // Initialize in the READY state
    state->port_state = STATE_READY;

    // Make sure port is running in binary mode
    set_port_control_flags(port, PORT_CONTROL_FLAG_BINARY);

    // Allocate a mutex and condition variable for the worker
    state->worker_lock = erl_drv_mutex_create("innostore_worker_lock");
    state->worker_cv   = erl_drv_cond_create("innostore_worker_cv");

    // Spin up the worker
    worker_rc = erl_drv_thread_create("innostore_worker", &(state->worker),
                                      &innostore_worker, state, 0);
    if (state->worker_lock != NULL &&
        state->worker_cv != NULL &&
         worker_rc == 0)
    {
        return (ErlDrvData)state;
    }
    else
    {
        log("Innostore: Could not create port [lock=%p, cv=%p]\n",
            state->worker_lock, state->worker_cv);

        if (state->worker_cv != NULL)
            erl_drv_cond_destroy(state->worker_cv);

        if (state->worker_lock != NULL)
            erl_drv_mutex_destroy(state->worker_lock);

        driver_free(state);

        errno = worker_rc;
        return (ErlDrvData) ERL_DRV_ERROR_ERRNO;
    }
}
Esempio n. 9
0
// Cleanup the mess
void dthread_finish(dthread_t* thr)
{
    dmessage_t* mp;

    if (thr->iq_mtx) {
	erl_drv_mutex_destroy(thr->iq_mtx);
	thr->iq_mtx = NULL;
    }
    mp = thr->iq_front;
    while(mp) {
	dmessage_t* tmp = mp->next;
	dmessage_free(mp);
	mp = tmp;
    }
    thr->iq_front = thr->iq_rear = NULL;
    dthread_signal_finish(thr, 0);
}
Esempio n. 10
0
File: erl_nif.c Progetto: a5an0/otp
void enif_mutex_destroy(ErlNifMutex *mtx) {  erl_drv_mutex_destroy(mtx); }
Esempio n. 11
0
int
erts_mutex_destroy(erl_mutex_t mtx)
{
    erl_drv_mutex_destroy((ErlDrvMutex *) mtx);
    return 0;
}