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

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