ia64/xen-unstable

changeset 8875:2d00d405ef9f

VTPM Tools: Fix threading bug in vtpm_manager while using NPTL. Now
supports Linux Threads and NPTL threads. Also clean up vtpm Makefile.

Signed-off-by: Vinnie Scarlata <vincent.r.scarlata@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Feb 16 22:39:55 2006 +0100 (2006-02-16)
parents 761275bcf825
children b85d62caa347
files tools/vtpm/Makefile tools/vtpm_manager/Makefile tools/vtpm_manager/manager/Makefile tools/vtpm_manager/manager/vtpmd.c tools/vtpm_manager/util/log.c
line diff
     1.1 --- a/tools/vtpm/Makefile	Thu Feb 16 22:33:46 2006 +0100
     1.2 +++ b/tools/vtpm/Makefile	Thu Feb 16 22:39:55 2006 +0100
     1.3 @@ -22,10 +22,10 @@ install: build
     1.4  	$(MAKE) -C $(VTPM_DIR) $@
     1.5  
     1.6  clean:
     1.7 -	if [ -d $(TPM_EMULATOR_DIR) ]; \
     1.8 +	@if [ -d $(TPM_EMULATOR_DIR) ]; \
     1.9  		then $(MAKE) -C $(TPM_EMULATOR_DIR) clean; \
    1.10  	fi
    1.11 -	if [ -d $(VTPM_DIR) ]; \
    1.12 +	@if [ -d $(VTPM_DIR) ]; \
    1.13  		then $(MAKE) -C $(VTPM_DIR) clean; \
    1.14  	fi
    1.15  
    1.16 @@ -57,7 +57,7 @@ mrproper:
    1.17  	patch -p1 <../vtpm.patch
    1.18  
    1.19  build_sub:
    1.20 -	if [ -e $(GMP_HEADER) ]; then \
    1.21 +	@if [ -e $(GMP_HEADER) ]; then \
    1.22  		$(MAKE) -C $(VTPM_DIR); \
    1.23  		if [ "$(BUILD_EMULATOR)" = "y" ]; then \
    1.24  			$(MAKE) -C $(TPM_EMULATOR_DIR); \
     2.1 --- a/tools/vtpm_manager/Makefile	Thu Feb 16 22:33:46 2006 +0100
     2.2 +++ b/tools/vtpm_manager/Makefile	Thu Feb 16 22:39:55 2006 +0100
     2.3 @@ -9,7 +9,7 @@ OPENSSL_HEADER	= /usr/include/openssl/cr
     2.4  all: build
     2.5  
     2.6  build:
     2.7 -	if [ -e $(OPENSSL_HEADER) ]; then \
     2.8 +	@if [ -e $(OPENSSL_HEADER) ]; then \
     2.9  		@set -e; for subdir in $(SUBDIRS); do \
    2.10  			$(MAKE) -C $$subdir $@; \
    2.11  		done; \
     3.1 --- a/tools/vtpm_manager/manager/Makefile	Thu Feb 16 22:33:46 2006 +0100
     3.2 +++ b/tools/vtpm_manager/manager/Makefile	Thu Feb 16 22:39:55 2006 +0100
     3.3 @@ -24,4 +24,4 @@ mrproper: clean
     3.4  
     3.5  # libraries
     3.6  LIBS += ../tcs/libTCS.a ../util/libTCGUtils.a ../crypto/libtcpaCrypto.a
     3.7 -LIBS += -lcrypto -lpthread -lrt -lm
     3.8 +LIBS += -lcrypto -lpthread -lm
     4.1 --- a/tools/vtpm_manager/manager/vtpmd.c	Thu Feb 16 22:33:46 2006 +0100
     4.2 +++ b/tools/vtpm_manager/manager/vtpmd.c	Thu Feb 16 22:39:55 2006 +0100
     4.3 @@ -54,21 +54,15 @@ void signal_handler(int reason) {
     4.4  #ifndef VTPM_MULTI_VM
     4.5  
     4.6    if (pthread_equal(pthread_self(), vtpm_globals->master_pid)) {
     4.7 -    if (reason >= 0) { // Reason is a signal
     4.8 -      vtpmloginfo(VTPM_LOG_VTPM, "VTPM Manager shutting down for signal %d.\n", reason);
     4.9 -    } else  {// Reason is a TPM_RESULT * -1
    4.10 -      vtpmloginfo(VTPM_LOG_VTPM,"VTPM Manager shuting down for: %s\n", tpm_get_error_name(-1 * reason) );
    4.11 -    }
    4.12 -    
    4.13 -    return;
    4.14 +    vtpmloginfo(VTPM_LOG_VTPM, "VTPM Manager shutting down for signal %d.\n", reason);
    4.15    } else {
    4.16 +    // For old Linux Thread machines, signals are delivered to each thread. Deal with them.
    4.17      vtpmloginfo(VTPM_LOG_VTPM, "Child shutting down\n");
    4.18      pthread_exit(NULL);
    4.19    }
    4.20 -#else
    4.21 +#endif
    4.22    VTPM_Stop_Service();
    4.23    exit(-1);
    4.24 -#endif
    4.25  }
    4.26  
    4.27  struct sigaction ctl_c_handler;
    4.28 @@ -127,8 +121,10 @@ int main(int argc, char **argv) {
    4.29    //Join the other threads until exit time.
    4.30    pthread_join(be_thread, NULL);
    4.31    pthread_join(dmi_thread, NULL);
    4.32 -  
    4.33 +#endif
    4.34 + 
    4.35 +  vtpmlogerror(VTPM_LOG_VTPM, "VTPM Manager shut down unexpectedly.\n");
    4.36 + 
    4.37    VTPM_Stop_Service();
    4.38    return 0;
    4.39 -#endif
    4.40  }
     5.1 --- a/tools/vtpm_manager/util/log.c	Thu Feb 16 22:33:46 2006 +0100
     5.2 +++ b/tools/vtpm_manager/util/log.c	Thu Feb 16 22:39:55 2006 +0100
     5.3 @@ -138,5 +138,5 @@ const char* tpm_get_error_name (TPM_RESU
     5.4      if (code == error_msgs[i].code) 
     5.5        return error_msgs[i].code_name;
     5.6    
     5.7 -    return "Failed to find code name for given code";
     5.8 +    return("Unknown Error Code");
     5.9  }