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

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