[dovecot-cvs] dovecot/src/lib fd-close-on-exec.c,1.7,1.8

cras at procontrol.fi cras at procontrol.fi
Sun Jun 20 00:24:58 EEST 2004


Update of /home/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv12742

Modified Files:
	fd-close-on-exec.c 
Log Message:
if socket is leaked, show also the remote side of it



Index: fd-close-on-exec.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/fd-close-on-exec.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- fd-close-on-exec.c	26 Aug 2003 21:18:16 -0000	1.7
+++ fd-close-on-exec.c	19 Jun 2004 21:24:55 -0000	1.8
@@ -24,8 +24,8 @@
 
 void fd_debug_verify_leaks(int first_fd, int last_fd)
 {
-	struct ip_addr addr;
-	unsigned int port;
+	struct ip_addr addr, raddr;
+	unsigned int port, rport;
 	struct stat st;
 
 	while (first_fd < last_fd) {
@@ -46,8 +46,14 @@
 						first_fd, sa.sun_path);
 				}
 
-				i_panic("Leaked socket fd %d: %s:%u",
-					first_fd, net_ip2addr(&addr), port);
+				if (net_getpeername(first_fd,
+						    &raddr, &rport) < 0) {
+					memset(&raddr, 0, sizeof(raddr));
+					rport = 0;
+				}
+				i_panic("Leaked socket fd %d: %s:%u -> %s:%u",
+					first_fd, net_ip2addr(&addr), port,
+					net_ip2addr(&raddr), rport);
 			}
 
 			if (fstat(first_fd, &st) == 0) {



More information about the dovecot-cvs mailing list