X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcommon%2Ffd-tracker%2Ffd-tracker.c;h=cdc1691f61da4c124032d0fe56384a7efdfeff7d;hb=934d8097107022c5c9697333d3352044b962324f;hp=fbf46ec18193ecbbc1a39af6ae400e9a21c538cd;hpb=bdafebb5195cfda710b32b019f9cac6c4d86f42a;p=lttng-tools.git diff --git a/src/common/fd-tracker/fd-tracker.c b/src/common/fd-tracker/fd-tracker.c index fbf46ec18..cdc1691f6 100644 --- a/src/common/fd-tracker/fd-tracker.c +++ b/src/common/fd-tracker/fd-tracker.c @@ -15,7 +15,6 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include #include #include #include @@ -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);