[xinetd] Fix leaking file descriptors (#702670)

jsynacek jsynacek at fedoraproject.org
Mon Jan 16 10:59:41 UTC 2012


commit c92212b82669d20f0a2cac8bf1e83071241979f3
Author: Jan Synacek <jsynacek at redhat.com>
Date:   Mon Jan 16 08:36:22 2012 +0100

    Fix leaking file descriptors (#702670)

 xinetd-2.3.14-leaking-fds.patch |   52 +++++++++++++++++++++++++++++++++++++++
 xinetd.spec                     |    9 +++++-
 2 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/xinetd-2.3.14-leaking-fds.patch b/xinetd-2.3.14-leaking-fds.patch
new file mode 100644
index 0000000..bc1b919
--- /dev/null
+++ b/xinetd-2.3.14-leaking-fds.patch
@@ -0,0 +1,52 @@
+diff -up xinetd-2.3.14-dist/xinetd/service.c xinetd-2.3.14/xinetd/service.c
+--- xinetd-2.3.14-dist/xinetd/service.c	2012-01-11 11:50:43.438650900 +0100
++++ xinetd-2.3.14/xinetd/service.c	2012-01-16 08:18:09.462620084 +0100
+@@ -88,6 +88,7 @@ struct service *svc_new( struct service_
+    CLEAR( *sp ) ;
+ 
+    SVC_CONF(sp) = scp ;
++   sp->svc_pfd_index = -1;
+    return( sp ) ;
+ }
+ 
+@@ -346,7 +347,16 @@ status_e svc_activate( struct service *s
+        ps.rws.pfds_last)*sizeof(struct pollfd));
+      ps.rws.pfd_array = tmp;
+    }
+-   SVC_POLLFD( sp ) = &ps.rws.pfd_array[ps.rws.pfds_last++] ;
++   if ( sp->svc_pfd_index >= 0 )
++   {
++     SVC_POLLFD( sp ) = &ps.rws.pfd_array[sp->svc_pfd_index] ;
++   }
++   else
++   {
++     sp->svc_pfd_index = ps.rws.pfds_last ;
++     SVC_POLLFD( sp ) = &ps.rws.pfd_array[ps.rws.pfds_last++] ;
++   }
++
+ #endif /* HAVE_POLL */
+ 
+    if( SC_IPV4( scp ) ) {
+@@ -433,6 +443,11 @@ status_e svc_activate( struct service *s
+ static void deactivate( const struct service *sp )
+ {
+    (void) Sclose( SVC_FD( sp ) ) ;
++#ifdef HAVE_POLL
++   SVC_FD( sp ) = 0;
++#else      
++   FD_CLR( SVC_FD( sp ), &ps.rws.socket_mask ) ;
++#endif
+ 
+ #ifdef HAVE_MDNS
+    xinetd_mdns_deregister(SVC_CONF(sp));
+diff -up xinetd-2.3.14-dist/xinetd/service.h xinetd-2.3.14/xinetd/service.h
+--- xinetd-2.3.14-dist/xinetd/service.h	2012-01-11 11:50:43.418650925 +0100
++++ xinetd-2.3.14/xinetd/service.h	2012-01-16 08:02:59.667553008 +0100
+@@ -47,6 +47,7 @@ struct service
+ {
+    state_e                svc_state ;
+    int                    svc_ref_count ;   /* # of pters to this struct */
++   int                    svc_pfd_index;    /* index of pfd in pfd_array */
+    struct service_config *svc_conf ;    /* service configuration */
+ 
+ #ifdef HAVE_POLL
diff --git a/xinetd.spec b/xinetd.spec
index ad67f6b..ca07944 100644
--- a/xinetd.spec
+++ b/xinetd.spec
@@ -43,6 +43,9 @@ Patch17: xinetd-2.3.13-log-crash.patch
 Patch18: xinetd-2.3.14-rpc-specific-port.patch
 Patch19: xinetd-2.3.14-signal-log-hang.patch
 Patch20: xinetd-2.3.14-fix-type-punned-ptr.patch
+# Fix leaking file descriptors and pfd_array wasting
+# This fixes #702670
+Patch21: xinetd-2.3.14-leaking-fds.patch
 
 BuildRequires: autoconf, automake
 BuildRequires: libselinux-devel >= 1.30
@@ -95,6 +98,7 @@ located in the /etc/xinetd.d directory.
 %patch18 -p1 -b .rpc-specific-port
 %patch19 -p1 -b .signal-log-hang
 %patch20 -p1 -b .fix-type-punned-ptr
+%patch21 -p1 -b .leaking-fds
 
 aclocal
 autoconf
@@ -164,8 +168,9 @@ fi
 %{_mandir}/*/*
 
 %changelog
-* Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2:2.3.14-38
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
+* Mon Jan 16 2012 Jan Synáček <jsynacek at redhat.com> - 2:2.3.14-38
+- Fix leaking file descriptors
+- Resolves: #702670
 
 * Mon Sep 12 2011 Tom Callaway <spot at fedoraproject.org> - 2:2.3.14-37
 - covert to systemd


More information about the scm-commits mailing list