From 29c069db3dcb78e77c03bb18153eec21456585c4 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 4 May 2017 14:48:18 -0500 Subject: [PATCH 1/2] Testing msi: Add retries if necessary Hoping this will fix the annoying problems on Windows Jenkins. --- src/ioc/dbtemplate/test/msi.plt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ioc/dbtemplate/test/msi.plt b/src/ioc/dbtemplate/test/msi.plt index f584dcf3d..230a2c18b 100644 --- a/src/ioc/dbtemplate/test/msi.plt +++ b/src/ioc/dbtemplate/test/msi.plt @@ -58,5 +58,19 @@ sub msi { my ($args) = @_; my $exe = ($^O eq 'MSWin32') || ($^O eq 'cygwin') ? '.exe' : ''; my $msi = "./msi-copy$exe"; - return `$msi $args`; + my $result; + if ($args =~ m/-o / && $args !~ m/-D/) { + # An empty result is expected + $result = `$msi $args`; + } + else { + # Try up to 5 times, sometimes msi fails on Windows + my $count = 5; + do { + $result = `$msi $args`; + print "# result of '$msi $args' empty, retrying\n" + if $result eq ''; + } while ($result eq '') && (--$count > 0); + } + return $result; } From 9c859ffdca5d9203a8f2025eec84a3276bf2e042 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 1 Jun 2017 15:37:34 -0500 Subject: [PATCH 2/2] Protect casStatsFetch() if called before rsrv_init() Also ensures clientQ is initialized before creating clientQlock. Fixes LP: #1694966 --- src/rsrv/caservertask.c | 15 ++++++++++----- src/rsrv/server.h | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/rsrv/caservertask.c b/src/rsrv/caservertask.c index 7867babe6..71c35ec1b 100644 --- a/src/rsrv/caservertask.c +++ b/src/rsrv/caservertask.c @@ -241,7 +241,6 @@ int rsrv_init (void) clientQlock = epicsMutexMustCreate(); - ellInit ( &clientQ ); freeListInitPvt ( &rsrvClientFreeList, sizeof(struct client), 8 ); freeListInitPvt ( &rsrvChanFreeList, sizeof(struct channel_in_use), 512 ); freeListInitPvt ( &rsrvEventFreeList, sizeof(struct event_ext), 512 ); @@ -951,16 +950,22 @@ struct client *create_tcp_client ( SOCKET sock ) void casStatsFetch ( unsigned *pChanCount, unsigned *pCircuitCount ) { - LOCK_CLIENTQ; + if ( ! clientQlock ) { + *pCircuitCount = 0; + *pChanCount = 0; + return; + } + + LOCK_CLIENTQ; { int circuitCount = ellCount ( &clientQ ); if ( circuitCount < 0 ) { - *pCircuitCount = 0; + *pCircuitCount = 0; } else { - *pCircuitCount = (unsigned) circuitCount; + *pCircuitCount = (unsigned) circuitCount; } *pChanCount = rsrvChannelCount; } - UNLOCK_CLIENTQ; + UNLOCK_CLIENTQ; } diff --git a/src/rsrv/server.h b/src/rsrv/server.h index fc7627f80..e4b947ea9 100644 --- a/src/rsrv/server.h +++ b/src/rsrv/server.h @@ -156,7 +156,7 @@ enum ctl {ctlInit, ctlRun, ctlPause, ctlExit}; /* NOTE: external used so they remember the state across loads */ #ifdef GLBLSOURCE # define GLBLTYPE -# define GLBLTYPE_INIT(A) +# define GLBLTYPE_INIT(A) = A #else # define GLBLTYPE extern # define GLBLTYPE_INIT(A) @@ -176,7 +176,7 @@ GLBLTYPE int CASDEBUG; GLBLTYPE SOCKET IOC_sock; GLBLTYPE SOCKET IOC_cast_sock; GLBLTYPE unsigned short ca_server_port; -GLBLTYPE ELLLIST clientQ; /* locked by clientQlock */ +GLBLTYPE ELLLIST clientQ GLBLTYPE_INIT(ELLLIST_INIT); GLBLTYPE ELLLIST beaconAddrList; GLBLTYPE epicsMutexId clientQlock; GLBLTYPE struct client *prsrv_cast_client;