mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-06 08:20:13 +01:00
Merge branch 'diagnose-leaked-fd' into 'master'
_dbus_check_fdleaks_leave: Try to describe what the leaked fd is See merge request dbus/dbus!503
This commit is contained in:
commit
12265328a6
1 changed files with 14 additions and 1 deletions
|
|
@ -606,6 +606,9 @@ _dbus_check_fdleaks_leave (DBusInitialFDs *fds,
|
|||
|
||||
while ((de = readdir(d)))
|
||||
{
|
||||
char description[256] = { 0 };
|
||||
char proc_self_fd[256] = { 0 };
|
||||
size_t description_length = sizeof (description) - 1;
|
||||
long l;
|
||||
char *e = NULL;
|
||||
int fd;
|
||||
|
|
@ -635,7 +638,17 @@ _dbus_check_fdleaks_leave (DBusInitialFDs *fds,
|
|||
if (FD_ISSET (fd, &fds->set))
|
||||
continue;
|
||||
|
||||
_dbus_test_fatal ("file descriptor %i leaked in %s.", fd, context);
|
||||
snprintf (proc_self_fd, sizeof (proc_self_fd) - 1,
|
||||
"/proc/self/fd/%ld", l);
|
||||
proc_self_fd[sizeof (proc_self_fd) - 1] = '\0';
|
||||
|
||||
if (readlink (proc_self_fd, description, description_length) <= 0)
|
||||
snprintf (description, sizeof (description) - 1, "(unknown)");
|
||||
|
||||
description[sizeof (description) - 1] = '\0';
|
||||
|
||||
_dbus_test_fatal ("file descriptor %i \"%s\" leaked in %s.",
|
||||
fd, description, context);
|
||||
}
|
||||
|
||||
closedir (d);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue