* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <urcu/ref.h>
#include <urcu.h>
#include <urcu/list.h>
#include <urcu/rculfhash.h>
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;
}
{
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);
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.