mirror of
https://github.com/moparisthebest/pacman
synced 2025-03-11 07:31:04 -04:00
make alpm_unlock and trans_interrupt async safe
RET_ERR calls _alpm_log which includes calls that are not safe for use in asynchronous signal handlers (see signal(7)). Replace it in functions called from our signal handlers with a new macro RET_ERR_ASYNC_SAFE which is identical except that it lacks the call to _alpm_log. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
This commit is contained in:
parent
1d6583a58d
commit
a724235b61
@ -141,7 +141,7 @@ int SYMEXPORT alpm_unlock(alpm_handle_t *handle)
|
|||||||
handle->lockfd = -1;
|
handle->lockfd = -1;
|
||||||
|
|
||||||
if(unlink(handle->lockfile) != 0) {
|
if(unlink(handle->lockfile) != 0) {
|
||||||
RET_ERR(handle, ALPM_ERR_SYSTEM, -1);
|
RET_ERR_ASYNC_SAFE(handle, ALPM_ERR_SYSTEM, -1);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,9 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Interrupt a transaction. */
|
/** Interrupt a transaction.
|
||||||
|
* @note Safe to call from inside signal handlers.
|
||||||
|
*/
|
||||||
int SYMEXPORT alpm_trans_interrupt(alpm_handle_t *handle)
|
int SYMEXPORT alpm_trans_interrupt(alpm_handle_t *handle)
|
||||||
{
|
{
|
||||||
alpm_trans_t *trans;
|
alpm_trans_t *trans;
|
||||||
@ -242,9 +244,9 @@ int SYMEXPORT alpm_trans_interrupt(alpm_handle_t *handle)
|
|||||||
CHECK_HANDLE(handle, return -1);
|
CHECK_HANDLE(handle, return -1);
|
||||||
|
|
||||||
trans = handle->trans;
|
trans = handle->trans;
|
||||||
ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
|
ASSERT(trans != NULL, RET_ERR_ASYNC_SAFE(handle, ALPM_ERR_TRANS_NULL, -1));
|
||||||
ASSERT(trans->state == STATE_COMMITING || trans->state == STATE_INTERRUPTED,
|
ASSERT(trans->state == STATE_COMMITING || trans->state == STATE_INTERRUPTED,
|
||||||
RET_ERR(handle, ALPM_ERR_TRANS_TYPE, -1));
|
RET_ERR_ASYNC_SAFE(handle, ALPM_ERR_TRANS_TYPE, -1));
|
||||||
|
|
||||||
trans->state = STATE_INTERRUPTED;
|
trans->state = STATE_INTERRUPTED;
|
||||||
|
|
||||||
|
@ -71,6 +71,10 @@ void _alpm_alloc_fail(size_t size);
|
|||||||
(handle)->pm_errno = (err); \
|
(handle)->pm_errno = (err); \
|
||||||
return (ret); } while(0)
|
return (ret); } while(0)
|
||||||
|
|
||||||
|
#define RET_ERR_ASYNC_SAFE(handle, err, ret) do { \
|
||||||
|
(handle)->pm_errno = (err); \
|
||||||
|
return (ret); } while(0)
|
||||||
|
|
||||||
#define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
|
#define DOUBLE_EQ(x, y) (fabs((x) - (y)) < DBL_EPSILON)
|
||||||
|
|
||||||
#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0)
|
#define CHECK_HANDLE(handle, action) do { if(!(handle)) { action; } (handle)->pm_errno = 0; } while(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user