fd-tracker: remove unneeded header inclusion
[lttng-tools.git] / src / common / fd-tracker / fd-tracker.c
index 0331f56d0ac2cb2935e0ed9964cd19ae1f398cec..cdc1691f61da4c124032d0fe56384a7efdfeff7d 100644 (file)
@@ -15,7 +15,6 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#include <urcu/ref.h>
 #include <urcu.h>
 #include <urcu/list.h>
 #include <urcu/rculfhash.h>
@@ -365,6 +364,8 @@ struct fd_tracker *fd_tracker_create(unsigned int capacity)
        tracker->capacity = capacity;
        tracker->unsuspendable_fds = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
                        CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       DBG("File descriptor tracker created with a limit of %u simultaneously-opened FDs",
+                       capacity);
 end:
        return tracker;
 }
@@ -752,6 +753,17 @@ int fs_handle_get_fd(struct fs_handle *handle)
 {
        int ret;
 
+       /*
+        * TODO This should be optimized as it is a fairly hot path.
+        * The fd-tracker's lock should only be taken when a fs_handle is
+        * restored (slow path). On the fast path (fs_handle is active),
+        * the only effect on the fd_tracker is marking the handle as the
+        * most recently used. Currently, it is done by a call to the
+        * track/untrack helpers, but it should be done atomically.
+        *
+        * Note that the lock's nesting order must still be respected here.
+        * The handle's lock nests inside the tracker's lock.
+        */
        pthread_mutex_lock(&handle->tracker->lock);
        pthread_mutex_lock(&handle->lock);
        assert(!handle->in_use);
@@ -797,6 +809,7 @@ int fs_handle_close(struct fs_handle *handle)
        pthread_mutex_lock(&handle->lock);
        fd_tracker_untrack(handle->tracker, handle);
        if (handle->fd >= 0) {
+               assert(!handle->in_use);
                /*
                 * The return value of close() is not propagated as there
                 * isn't much the user can do about it.
This page took 0.025039 seconds and 5 git commands to generate.