[svn-commits] simon.perreault: branch group/v6 r84778 - /team/group/v6/trunk/main/asterisk.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Oct 5 10:05:04 CDT 2007
Author: simon.perreault
Date: Fri Oct 5 10:05:03 2007
New Revision: 84778
URL: http://svn.digium.com/view/asterisk?view=rev&rev=84778
Log:
Beginning of a file descriptor leak tracing facility. This simply prints the FDs that are
still open just before terminating.
Modified:
team/group/v6/trunk/main/asterisk.c
Modified: team/group/v6/trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/group/v6/trunk/main/asterisk.c?view=diff&rev=84778&r1=84777&r2=84778
==============================================================================
--- team/group/v6/trunk/main/asterisk.c (original)
+++ team/group/v6/trunk/main/asterisk.c Fri Oct 5 10:05:03 2007
@@ -80,6 +80,7 @@
#include <grp.h>
#include <pwd.h>
#include <sys/stat.h>
+#include <dirent.h>
#if defined(HAVE_SYSINFO)
#include <sys/sysinfo.h>
#endif
@@ -1206,6 +1207,27 @@
AST_RWLIST_UNLOCK(&atexits);
}
+static void show_fd_leaks(void)
+{
+ DIR *d;
+ struct dirent *fd;
+ char buf[PATH_MAX];
+ ssize_t len;
+
+ if (!(d = opendir("/proc/self/fd")))
+ return;
+
+ while ((fd = readdir(d))) {
+ snprintf(buf, sizeof(buf), "/proc/self/fd/%s", fd->d_name);
+ if ((len = readlink(buf, buf, sizeof(buf))) == -1)
+ continue;
+ buf[len] = '\0';
+ ast_debug(1, "Possible FD leak: %s -> %s\n", fd->d_name, buf);
+ }
+
+ closedir(d);
+}
+
static void quit_handler(int num, int nice, int safeshutdown, int restart)
{
char filename[80] = "";
@@ -1284,6 +1306,7 @@
close(ast_consock);
if (!ast_opt_remote)
unlink(ast_config_AST_PID);
+ show_fd_leaks();
printf(term_quit());
if (restart) {
if (option_verbose || ast_opt_console)
More information about the svn-commits
mailing list