#include "common/ust-fd.h"
#include "common/macros.h"
#include <lttng/ust-error.h>
#include "common/ust-fd.h"
#include "common/macros.h"
#include <lttng/ust-error.h>
/* Operations on the fd set. */
#define IS_FD_VALID(fd) ((fd) >= 0 && (fd) < lttng_ust_max_fd)
#define GET_FD_SET_FOR_FD(fd, fd_sets) (&((fd_sets)[(fd) / FD_SETSIZE]))
/* Operations on the fd set. */
#define IS_FD_VALID(fd) ((fd) >= 0 && (fd) < lttng_ust_max_fd)
#define GET_FD_SET_FOR_FD(fd, fd_sets) (&((fd_sets)[(fd) / FD_SETSIZE]))
/*
* Track whether we are within lttng-ust or application, for close
* system call override by LD_PRELOAD library. This also tracks whether
/*
* Track whether we are within lttng-ust or application, for close
* system call override by LD_PRELOAD library. This also tracks whether
* process. This will be called during the constructor execution
* and will also be called in the child after fork via lttng_ust_init.
*/
* process. This will be called during the constructor execution
* and will also be called in the child after fork via lttng_ust_init.
*/
void lttng_ust_lock_fd_tracker(void)
{
sigset_t sig_all_blocked, orig_mask;
void lttng_ust_lock_fd_tracker(void)
{
sigset_t sig_all_blocked, orig_mask;
- ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
- if (ret) {
- ERR("pthread_setcancelstate: %s", strerror(ret));
+ if (lttng_ust_cancelstate_disable_push()) {
+ ERR("lttng_ust_cancelstate_disable_push");
}
sigfillset(&sig_all_blocked);
ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask);
}
sigfillset(&sig_all_blocked);
ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask);
void lttng_ust_unlock_fd_tracker(void)
{
sigset_t sig_all_blocked, orig_mask;
void lttng_ust_unlock_fd_tracker(void)
{
sigset_t sig_all_blocked, orig_mask;
sigfillset(&sig_all_blocked);
ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask);
sigfillset(&sig_all_blocked);
ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_mask);
pthread_mutex_unlock(&ust_safe_guard_fd_mutex);
}
ret = pthread_sigmask(SIG_SETMASK, &orig_mask, NULL);
if (ret) {
ERR("pthread_sigmask: %s", strerror(ret));
}
pthread_mutex_unlock(&ust_safe_guard_fd_mutex);
}
ret = pthread_sigmask(SIG_SETMASK, &orig_mask, NULL);
if (ret) {
ERR("pthread_sigmask: %s", strerror(ret));
}
- if (restore_cancel) {
- ret = pthread_setcancelstate(newstate, &oldstate);
- if (ret) {
- ERR("pthread_setcancelstate: %s", strerror(ret));
- }
+ if (lttng_ust_cancelstate_disable_pop()) {
+ ERR("lttng_ust_cancelstate_disable_pop");