This patch adds a call to the tcsd_shutdown() function after the SIGTERM signal 
is received. 
Further, the socket 'sd' is closed after this signal is received, in order to
avoid waiting the accept().


Signed-off-by: Roberto Sassu <[email protected]>
---
 src/tcsd/svrside.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/tcsd/svrside.c b/src/tcsd/svrside.c
index 27c18bf..04cb9e5 100644
--- a/src/tcsd/svrside.c
+++ b/src/tcsd/svrside.c
@@ -43,6 +43,7 @@ struct tcsd_config tcsd_options;
 struct tpm_properties tpm_metrics;
 static volatile int hup = 0, term = 0;
 extern char *optarg;
+int sd;
 
 static void
 tcsd_shutdown(void)
@@ -61,6 +62,7 @@ static void
 tcsd_signal_term(int signal)
 {
        term = 1;
+       close(sd);
 }
 
 void
@@ -213,7 +215,7 @@ main(int argc, char **argv)
 {
        struct sockaddr_in serv_addr, client_addr;
        TSS_RESULT result;
-       int sd, newsd, c, option_index = 0;
+       int newsd, c, option_index = 0;
        unsigned client_len;
        char *hostname = NULL;
        struct passwd *pwd;
@@ -339,5 +341,6 @@ main(int argc, char **argv)
        } while (term ==0);
 
        /* To close correctly, we must receive a SIGTERM */
+       tcsd_shutdown();
        return 0;
 }
-- 
1.7.2.2


------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to