Esempio n. 1
0
/* Stops a backend instance */
int 
ldbm_instance_stop(backend *be)
{
    int rc;
    ldbm_instance *inst = (ldbm_instance *)be->be_instance_info;

    PR_Lock (be->be_state_lock);

    if (be->be_state != BE_STATE_STARTED) {
        slapi_log_err(SLAPI_LOG_WARNING, 
                   "ldbm_instance_stop", "Backend %s is in the wrong state - %d\n", 
                   inst ? inst->inst_name : "", be->be_state);
        PR_Unlock (be->be_state_lock);
        return 0;
    }

    rc = dblayer_instance_close(be);

    be->be_state = BE_STATE_STOPPED;
    PR_Unlock (be->be_state_lock);

    cache_destroy_please(&inst->inst_cache, CACHE_TYPE_ENTRY);
    if (entryrdn_get_switch()) { /* subtree-rename: on */
        cache_destroy_please(&inst->inst_dncache, CACHE_TYPE_DN);
    }

    return rc;
}
Esempio n. 2
0
int
ldbm_instance_delete_instance_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
{
    char *instance_name;
    struct ldbminfo *li = (struct ldbminfo *)arg;
    struct ldbm_instance *inst = NULL;

    parse_ldbm_instance_entry(entryBefore, &instance_name);
    inst = ldbm_instance_find_by_name(li, instance_name);
    if (inst == NULL) {
        LDAPDebug(LDAP_DEBUG_ANY, "ldbm: instance '%s' does not exist!\n",
                  instance_name, 0, 0);
        if (returntext) {
            PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "No ldbm instance exists with the name '%s'\n",
                    instance_name);
        }
        if (returncode) {
            *returncode = LDAP_UNWILLING_TO_PERFORM;
        }
        slapi_ch_free((void **)&instance_name);
        return SLAPI_DSE_CALLBACK_ERROR;
    }

    /* check if some online task is happening */
    if ((instance_set_busy(inst) != 0) ||
        (slapi_counter_get_value(inst->inst_ref_count) > 0)) {
        LDAPDebug(LDAP_DEBUG_ANY, "ldbm: '%s' is in the middle of a task. "
                  "Cancel the task or wait for it to finish, "
                  "then try again.\n", instance_name, 0, 0);
        if (returntext) {
            PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "ldbm instance '%s' is in the middle of a "
                    "task. Cancel the task or wait for it to finish, "
                    "then try again.\n", instance_name);
        }
        if (returncode) {
            *returncode = LDAP_UNWILLING_TO_PERFORM;
        }
        slapi_ch_free((void **)&instance_name);
        return SLAPI_DSE_CALLBACK_ERROR;
    }

    /* okay, we're gonna delete this database instance.  take it offline. */
    LDAPDebug(LDAP_DEBUG_ANY, "ldbm: Bringing %s offline...\n",
              instance_name, 0, 0);
    slapi_mtn_be_stopping(inst->inst_be);
    dblayer_instance_close(inst->inst_be);
    slapi_ch_free((void **)&instance_name);

    return SLAPI_DSE_CALLBACK_OK;
}