Blame SOURCES/xinetd-2.3.14-leaking-fds.patch

4a9f2a
diff -up xinetd-2.3.14-dist/xinetd/service.c xinetd-2.3.14/xinetd/service.c
4a9f2a
--- xinetd-2.3.14-dist/xinetd/service.c	2012-01-11 11:50:43.438650900 +0100
4a9f2a
+++ xinetd-2.3.14/xinetd/service.c	2012-01-16 08:18:09.462620084 +0100
4a9f2a
@@ -88,6 +88,7 @@ struct service *svc_new( struct service_
4a9f2a
    CLEAR( *sp ) ;
4a9f2a
 
4a9f2a
    SVC_CONF(sp) = scp ;
4a9f2a
+   sp->svc_pfd_index = -1;
4a9f2a
    return( sp ) ;
4a9f2a
 }
4a9f2a
 
4a9f2a
@@ -346,7 +347,16 @@ status_e svc_activate( struct service *s
4a9f2a
        ps.rws.pfds_last)*sizeof(struct pollfd));
4a9f2a
      ps.rws.pfd_array = tmp;
4a9f2a
    }
4a9f2a
-   SVC_POLLFD( sp ) = &ps.rws.pfd_array[ps.rws.pfds_last++] ;
4a9f2a
+   if ( sp->svc_pfd_index >= 0 )
4a9f2a
+   {
4a9f2a
+     SVC_POLLFD( sp ) = &ps.rws.pfd_array[sp->svc_pfd_index] ;
4a9f2a
+   }
4a9f2a
+   else
4a9f2a
+   {
4a9f2a
+     sp->svc_pfd_index = ps.rws.pfds_last ;
4a9f2a
+     SVC_POLLFD( sp ) = &ps.rws.pfd_array[ps.rws.pfds_last++] ;
4a9f2a
+   }
4a9f2a
+
4a9f2a
 #endif /* HAVE_POLL */
4a9f2a
 
4a9f2a
    if( SC_IPV4( scp ) ) {
4a9f2a
@@ -433,6 +443,11 @@ status_e svc_activate( struct service *s
4a9f2a
 static void deactivate( const struct service *sp )
4a9f2a
 {
4a9f2a
    (void) Sclose( SVC_FD( sp ) ) ;
4a9f2a
+#ifdef HAVE_POLL
4a9f2a
+   SVC_FD( sp ) = 0;
4a9f2a
+#else      
4a9f2a
+   FD_CLR( SVC_FD( sp ), &ps.rws.socket_mask ) ;
4a9f2a
+#endif
4a9f2a
 
4a9f2a
 #ifdef HAVE_MDNS
4a9f2a
    xinetd_mdns_deregister(SVC_CONF(sp));
4a9f2a
diff -up xinetd-2.3.14-dist/xinetd/service.h xinetd-2.3.14/xinetd/service.h
4a9f2a
--- xinetd-2.3.14-dist/xinetd/service.h	2012-01-11 11:50:43.418650925 +0100
4a9f2a
+++ xinetd-2.3.14/xinetd/service.h	2012-01-16 08:02:59.667553008 +0100
4a9f2a
@@ -47,6 +47,7 @@ struct service
4a9f2a
 {
4a9f2a
    state_e                svc_state ;
4a9f2a
    int                    svc_ref_count ;   /* # of pters to this struct */
4a9f2a
+   int                    svc_pfd_index;    /* index of pfd in pfd_array */
4a9f2a
    struct service_config *svc_conf ;    /* service configuration */
4a9f2a
 
4a9f2a
 #ifdef HAVE_POLL