#include <common/hashtable/utils.hpp>
#include <common/macros.hpp>
#include <common/optional.hpp>
+#include <common/urcu.hpp>
#include <fcntl.h>
#include <inttypes.h>
#include <urcu/rculfhash.h>
/* Tracker lock must be taken by the user. */
-#define TRACKED_COUNT(tracker) \
- (tracker->count.suspendable.active + tracker->count.suspendable.suspended + \
- tracker->count.unsuspendable)
+#define TRACKED_COUNT(tracker) \
+ ((tracker)->count.suspendable.active + (tracker)->count.suspendable.suspended + \
+ (tracker)->count.unsuspendable)
/* Tracker lock must be taken by the user. */
-#define ACTIVE_COUNT(tracker) (tracker->count.suspendable.active + tracker->count.unsuspendable)
+#define ACTIVE_COUNT(tracker) ((tracker)->count.suspendable.active + (tracker)->count.unsuspendable)
/* Tracker lock must be taken by the user. */
-#define SUSPENDED_COUNT(tracker) (tracker->count.suspendable.suspended)
+#define SUSPENDED_COUNT(tracker) ((tracker)->count.suspendable.suspended)
/* Tracker lock must be taken by the user. */
#define SUSPENDABLE_COUNT(tracker) \
- (tracker->count.suspendable.active + tracker->count.suspendable.suspended)
+ ((tracker)->count.suspendable.active + (tracker)->count.suspendable.suspended)
/* Tracker lock must be taken by the user. */
-#define UNSUSPENDABLE_COUNT(tracker) (tracker->count.unsuspendable)
+#define UNSUSPENDABLE_COUNT(tracker) ((tracker)->count.unsuspendable)
struct fd_tracker {
pthread_mutex_t lock;
}
DBG_NO_LOC(" Tracked unsuspendable file descriptors");
- rcu_read_lock();
- cds_lfht_for_each_entry (
- tracker->unsuspendable_fds, &iter, unsuspendable_fd, tracker_node) {
- DBG_NO_LOC(" %s [active, fd %d]",
- unsuspendable_fd->name ?: "Unnamed",
- unsuspendable_fd->fd);
- }
- rcu_read_unlock();
+
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (
+ tracker->unsuspendable_fds, &iter, unsuspendable_fd, tracker_node) {
+ DBG_NO_LOC(" %s [active, fd %d]",
+ unsuspendable_fd->name ?: "Unnamed",
+ unsuspendable_fd->fd);
+ }
+ }
+
if (!UNSUSPENDABLE_COUNT(tracker)) {
DBG_NO_LOC(" None");
}
int ret, user_ret, i, fds_to_suspend;
unsigned int active_fds;
struct unsuspendable_fd **entries;
+ lttng::urcu::read_lock_guard read_lock;
entries = calloc<unsuspendable_fd *>(fd_count);
if (!entries) {
entries[i] = entry;
}
- rcu_read_lock();
for (i = 0; i < fd_count; i++) {
struct cds_lfht_node *node;
struct unsuspendable_fd *entry = entries[i];
if (node != &entry->tracker_node) {
ret = -EEXIST;
- rcu_read_unlock();
goto end_free_entries;
}
entries[i] = nullptr;
}
tracker->count.unsuspendable += fd_count;
- rcu_read_unlock();
ret = user_ret;
end_unlock:
pthread_mutex_unlock(&tracker->lock);
{
int i, ret, user_ret;
int *fds = nullptr;
+ lttng::urcu::read_lock_guard read_lock;
/*
* Maintain a local copy of fds_in as the user's callback may modify its
memcpy(fds, fds_in, sizeof(*fds) * fd_count);
pthread_mutex_lock(&tracker->lock);
- rcu_read_lock();
/* Let the user close the file descriptors. */
user_ret = close(user_data, fds_in);
tracker->count.unsuspendable -= fd_count;
ret = 0;
end_unlock:
- rcu_read_unlock();
pthread_mutex_unlock(&tracker->lock);
free(fds);
end: