diff options
author | Matt Caswell <matt@openssl.org> | 2016-03-15 16:44:26 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-03-15 23:46:50 +0000 |
commit | 5427976d9eddacc87c7e079976bc7738e133dbdc (patch) | |
tree | 25bc6f00fef02ab1486cc1f99560f2abb3908a9a /util/TLSProxy | |
parent | 2460c7f13389d766dd65fa4e14b69b6fbe3e4e3b (diff) | |
download | openssl-5427976d9eddacc87c7e079976bc7738e133dbdc.tar.gz |
Fix a TLSProxy race condition
TLSProxy starts s_server and specifies the number of client connects
it should expect. After that s_server is supposed to close down
automatically. However, if another test is then run then TLSProxy
will start a new instance of s_server. If the previous instance
hasn't closed down yet then the new instance can fail to bind to
the socket.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'util/TLSProxy')
-rw-r--r-- | util/TLSProxy/Proxy.pm | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/util/TLSProxy/Proxy.pm b/util/TLSProxy/Proxy.pm index 96e368189e..fcbe2483c4 100644 --- a/util/TLSProxy/Proxy.pm +++ b/util/TLSProxy/Proxy.pm @@ -52,6 +52,7 @@ # Hudson (tjh@cryptsoft.com). use strict; +use POSIX ":sys_wait_h"; package TLSProxy::Proxy; @@ -86,6 +87,7 @@ sub new serverflags => "", clientflags => "", serverconnects => 1, + serverpid => 0, #Public read execute => $execute, @@ -138,23 +140,31 @@ sub new return bless $self, $class; } -sub clear +sub clearClient { my $self = shift; $self->{cipherc} = ""; - $self->{ciphers} = "AES128-SHA"; $self->{flight} = 0; $self->{record_list} = []; $self->{message_list} = []; - $self->{serverflags} = ""; $self->{clientflags} = ""; - $self->{serverconnects} = 1; TLSProxy::Message->clear(); TLSProxy::Record->clear(); } +sub clear +{ + my $self = shift; + + $self->clearClient; + $self->{ciphers} = "AES128-SHA"; + $self->{serverflags} = ""; + $self->{serverconnects} = 1; + $self->{serverpid} = 0; +} + sub restart { my $self = shift; @@ -195,6 +205,7 @@ sub start } exec($execcmd); } + $self->serverpid($pid); $self->clientstart; } @@ -319,6 +330,13 @@ sub clientstart if(!$self->debug) { select($oldstdout); } + $self->serverconnects($self->serverconnects - 1); + if ($self->serverconnects == 0) { + die "serverpid is zero\n" if $self->serverpid == 0; + print "Waiting for server process to close: " + .$self->serverpid."\n"; + waitpid( $self->serverpid, 0); + } } sub process_packet @@ -503,4 +521,12 @@ sub message_list } return $self->{message_list}; } +sub serverpid +{ + my $self = shift; + if (@_) { + $self->{serverpid} = shift; + } + return $self->{serverpid}; +} 1; |