static void vmem_destroy1(vmem_t *vm) { #if defined(QCACHE) qc_destroy(vm); #endif /* defined(QCACHE) */ if (vm->vm_hashlist != NULL) { int i; for (i = 0; i < vm->vm_hashsize; i++) { bt_t *bt; while ((bt = LIST_FIRST(&vm->vm_hashlist[i])) != NULL) { KASSERT(bt->bt_type == BT_TYPE_SPAN_STATIC); bt_free(vm, bt); } } if (vm->vm_hashlist != &vm->vm_hash0) { xfree(vm->vm_hashlist, sizeof(struct vmem_hashlist *) * vm->vm_hashsize); } } bt_freetrim(vm, 0); VMEM_CONDVAR_DESTROY(vm); VMEM_LOCK_DESTROY(vm); xfree(vm, sizeof(*vm)); }
void mvc_trans(mvc *m) { int schema_changed = 0, err = m->session->status; assert(!m->session->active); /* can only start a new transaction */ store_lock(); schema_changed = sql_trans_begin(m->session); if (m->qc && (schema_changed || m->qc->nr > m->cache || err)){ if (schema_changed || err) { int seqnr = m->qc->id; if (m->qc) qc_destroy(m->qc); m->qc = qc_create(m->clientid, seqnr); } else { /* clean all but the prepared statements */ qc_clean(m->qc); } } store_unlock(); }
void mvc_destroy(mvc *m) { sql_trans *tr; if (mvc_debug) fprintf(stderr, "#mvc_destroy\n"); tr = m->session->tr; if (tr) { store_lock(); if (m->session->active) sql_trans_end(m->session); while (tr->parent) tr = sql_trans_destroy(tr); m->session->tr = NULL; store_unlock(); } sql_session_destroy(m->session); stack_pop_until(m, 0); _DELETE(m->vars); if (m->scanner.log) /* close and destroy stream */ close_stream(m->scanner.log); if (m->sa) sa_destroy(m->sa); m->sa = NULL; if (m->qc) qc_destroy(m->qc); m->qc = NULL; _DELETE(m->args); m->args = NULL; _DELETE(m); }