예제 #1
0
/**
 * @brief	Destroy a web session and its associated data.
 * @param	sess	a pointer to the web session to be destroyed.
 * @return	This function returns no value.
 */
void sess_destroy(session_t *sess) {

	if (sess) {

		if (sess->user) {
			meta_remove(sess->user->username, META_PROT_WEB);
		}

		st_cleanup(sess->warden.token);
		st_cleanup(sess->warden.agent);

		// Release the credential.
		if (sess->warden.cred) {
			credential_free(sess->warden.cred);
			sess->warden.cred = NULL;
		}

		st_cleanup(sess->request.host);
		st_cleanup(sess->request.path);
		st_cleanup(sess->request.application);
		inx_cleanup(sess->compositions);

		mutex_destroy(&(sess->lock));
		mm_free(sess);
	}

	return;
}
예제 #2
0
/**
 * @brief	Free a composition object.
 * @note	This is an inx helper function.
 * @param	comp	a pointer to the composition object to be destroyed.
 * @return	This function returns no value.
 */
void sess_release_composition(composition_t *comp) {

	if (comp) {
		inx_cleanup(comp->attachments);
		mm_free(comp);
	}

	return;
}
예제 #3
0
/**
 * @brief	Free a magma folder object and its underlying records.
 * @return	This function returns no value.
 */
void magma_folder_free(magma_folder_t *folder) {

	if (folder) {
		inx_cleanup(folder->records);
		rwlock_destroy(&(folder->lock));
		mm_free(folder);
	}

	return;
}
예제 #4
0
파일: inx_check.c 프로젝트: lavabit/magma
bool_t check_inx_append_mthread(MAGMA_INDEX inx_type, stringer_t *errmsg) {

	void *result;
	inx_t *inx = NULL;
	bool_t outcome = true;
	pthread_t *threads = NULL;

	if (status() && (!(inx = inx_alloc(inx_type | M_INX_LOCK_MANUAL, &ns_free)))) {
		st_sprint(errmsg, "An error occured during initial allocation in the inx check append multi-threaded test.");
		outcome = false;
	}
	else {

		if (!INX_CHECK_MTHREADS || !(threads = mm_alloc(sizeof(pthread_t) * INX_CHECK_MTHREADS))) {
			outcome = false;
		}
		else {

			for (uint64_t counter = 0; counter < INX_CHECK_MTHREADS; counter++) {
				if (thread_launch(threads + counter, &check_inx_append_mthread_test, inx)) {
					st_sprint(errmsg, "An error occured when launching a thread.");
					outcome = false;
				}
			}

			for (uint64_t counter = 0; counter < INX_CHECK_MTHREADS; counter++) {
				if (thread_result(*(threads + counter), &result) || !result || !*(bool_t *)result) {
					if (st_empty(errmsg)) st_sprint(errmsg, "One of the append check threads returned false.");
					outcome = false;
				}

				mm_cleanup(result);
			}

			mm_free(threads);
		}

		if (inx_count(inx) != 0 && st_empty(errmsg)) {
			st_sprint(errmsg, "The index was not properly cleared.");
			outcome = false;
		}

	}

	if (inx) {
		inx_cleanup(inx);
	}

	return outcome;
}
예제 #5
0
파일: meta.c 프로젝트: lavabit/magma
/**
 * @brief	Free a meta user object.
 *
 * @param	user	a pointer to the meta user object to be destroyed.
 *
 * @return	This function returns no value.
 */
void meta_free(meta_user_t *user) {

	if (user) {

		prime_cleanup(user->prime.key);
		prime_cleanup(user->prime.signet);

		inx_cleanup(user->aliases);
		inx_cleanup(user->folders);
		inx_cleanup(user->message_folders);
		inx_cleanup(user->messages);
		inx_cleanup(user->contacts);

		st_cleanup(user->username, user->verification, user->realm.mail);

		// When read/write locking issues have been fixed, this line can be used once again.
		rwlock_destroy(&(user->lock));
		mutex_destroy(&(user->refs.lock));

		mm_free(user);
	}

	return;
}
예제 #6
0
/**
 * @brief	Free a list of SMTP inbound mail preferences and its underlying data.
 * @param	inbound		a pointer to the head of the SMTP inbound mail preferences list to be destroyed.
 * @return	This function returns no value.
 */
void smtp_free_inbound(smtp_inbound_prefs_t *inbound) {

	smtp_inbound_prefs_t *holder;

	while (inbound) {
		st_cleanup(inbound->rcptto);
		st_cleanup(inbound->address);
		st_cleanup(inbound->domain);
		st_cleanup(inbound->forwarded);
		st_cleanup(inbound->spamsig);
		inx_cleanup(inbound->filters);
		holder = inbound;
		inbound = (smtp_inbound_prefs_t *)holder->next;
		mm_free(holder);
	}

	return;
}
예제 #7
0
파일: inx_check.c 프로젝트: lavabit/magma
bool_t check_inx_append_sthread(MAGMA_INDEX inx_type, stringer_t *errmsg) {

	inx_t *inx = NULL;
	bool_t outcome = true;

	if (status() && (!(inx = inx_alloc(inx_type | M_INX_LOCK_MANUAL, &ns_free)))) {
		st_sprint(errmsg, "An error occured during initial allocation in the inx check append single-threaded test.");
		outcome = false;
	}
	else if(!check_inx_append_helper(inx)) {
		st_sprint(errmsg, "An error occured inside append test helper.");
		outcome = false;
	}

	if (outcome && inx_count(inx) != 0) {
		st_sprint(errmsg, "The index was not properly cleared.");
		outcome = false;
	}

	inx_cleanup(inx);
	return outcome;
}