Exemple #1
0
/** Release a transaction. */
int SYMEXPORT alpm_trans_release(alpm_handle_t *handle)
{
    alpm_trans_t *trans;

    /* Sanity checks */
    CHECK_HANDLE(handle, return -1);

    trans = handle->trans;
    ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
    ASSERT(trans->state != STATE_IDLE, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));

    int nolock_flag = trans->flags & ALPM_TRANS_FLAG_NOLOCK;

    _alpm_trans_free(trans);
    handle->trans = NULL;

    /* unlock db */
    if(!nolock_flag) {
        if(_alpm_handle_unlock(handle)) {
            _alpm_log(handle, ALPM_LOG_WARNING, _("could not remove lock file %s\n"),
                      alpm_option_get_lockfile(handle));
            alpm_logaction(handle, "warning: could not remove lock file %s\n",
                           alpm_option_get_lockfile(handle));
        }
    }

    return 0;
}
Exemple #2
0
/** Release a transaction.
 * @return 0 on success, -1 on error (pm_errno is set accordingly)
 */
int SYMEXPORT alpm_trans_release()
{
	pmtrans_t *trans;

	ALPM_LOG_FUNC;

	/* Sanity checks */
	ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));

	trans = handle->trans;
	ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
	ASSERT(trans->state != STATE_IDLE, RET_ERR(PM_ERR_TRANS_NULL, -1));

	_alpm_trans_free(trans);
	handle->trans = NULL;

	/* unlock db */
	if(handle->lckfd != -1) {
		while(close(handle->lckfd) == -1 && errno == EINTR);
		handle->lckfd = -1;
	}
	if(_alpm_lckrm()) {
		_alpm_log(PM_LOG_WARNING, _("could not remove lock file %s\n"),
				alpm_option_get_lockfile());
		alpm_logaction("warning: could not remove lock file %s\n",
				alpm_option_get_lockfile());
	}

	return(0);
}
Exemple #3
0
void _alpm_handle_free(pmhandle_t *handle)
{
	ALPM_LOG_FUNC;

	if(handle == NULL) {
		return;
	}

	/* close logfile */
	if(handle->logstream) {
		fclose(handle->logstream);
		handle->logstream= NULL;
	}
	if(handle->usesyslog) {
		handle->usesyslog = 0;
		closelog();
	}

	/* free memory */
	_alpm_trans_free(handle->trans);
	FREE(handle->root);
	FREE(handle->dbpath);
	FREELIST(handle->cachedirs);
	FREE(handle->logfile);
	FREE(handle->lockfile);
	FREE(handle->xfercommand);
	FREELIST(handle->dbs_sync);
	FREELIST(handle->noupgrade);
	FREELIST(handle->noextract);
	FREELIST(handle->ignorepkg);
	FREELIST(handle->holdpkg);
	FREELIST(handle->ignoregrp);
	FREE(handle);
}
Exemple #4
0
void _alpm_handle_free(alpm_handle_t *handle)
{
	if(handle == NULL) {
		return;
	}

	/* close logfile */
	if(handle->logstream) {
		fclose(handle->logstream);
		handle->logstream = NULL;
	}
	if(handle->usesyslog) {
		handle->usesyslog = 0;
		closelog();
	}

#ifdef HAVE_LIBCURL
	/* release curl handle */
	curl_easy_cleanup(handle->curl);
#endif

#ifdef HAVE_LIBGPGME
	FREELIST(handle->known_keys);
#endif

	regfree(&handle->delta_regex);

	/* free memory */
	_alpm_trans_free(handle->trans);
	FREE(handle->root);
	FREE(handle->dbpath);
	FREELIST(handle->cachedirs);
	FREE(handle->logfile);
	FREE(handle->lockfile);
	FREE(handle->arch);
	FREE(handle->gpgdir);
	FREELIST(handle->noupgrade);
	FREELIST(handle->noextract);
	FREELIST(handle->ignorepkg);
	FREELIST(handle->ignoregroup);

	alpm_list_free_inner(handle->assumeinstalled, (alpm_list_fn_free)alpm_dep_free);
	alpm_list_free(handle->assumeinstalled);

	FREE(handle);
}
Exemple #5
0
/** Release a transaction. */
int SYMEXPORT alpm_trans_release(alpm_handle_t *handle)
{
	alpm_trans_t *trans;

	/* Sanity checks */
	CHECK_HANDLE(handle, return -1);

	trans = handle->trans;
	ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
	ASSERT(trans->state != STATE_IDLE, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));

	int nolock_flag = trans->flags & ALPM_TRANS_FLAG_NOLOCK;

	_alpm_trans_free(trans);
	handle->trans = NULL;

	/* unlock db */
	if(!nolock_flag) {
		_alpm_handle_unlock(handle);
	}

	return 0;
}