{
int success = 0;
+ if (BIO_printf(out, "ACCEPT") <= 0)
+ return 0;
if (with_address) {
union BIO_sock_info_u info;
char *hostname = NULL;
&& (service = BIO_ADDR_service_string(info.addr, 1)) != NULL
&& BIO_printf(out,
strchr(hostname, ':') == NULL
- ? /* IPv4 */ "ACCEPT %s:%s\n"
- : /* IPv6 */ "ACCEPT [%s]:%s\n",
+ ? /* IPv4 */ " %s:%s\n"
+ : /* IPv6 */ " [%s]:%s\n",
hostname, service) > 0)
success = 1;
+ else
+ (void)BIO_printf(out, "unknown:error\n");
OPENSSL_free(hostname);
OPENSSL_free(service);
BIO_ADDR_free(info.addr);
- } else {
- (void)BIO_printf(out, "ACCEPT\n");
+ } else if (BIO_printf(out, "\n") > 0) {
success = 1;
}
(void)BIO_flush(out);
if ($server_name eq "Mock") {
indir "Mock" => sub {
$pid = start_mock_server("");
- skip "Cannot start or find the started CMP mock server",
- scalar @all_aspects unless $pid;
+ die "Cannot start or find the started CMP mock server" unless $pid;
}
}
foreach my $aspect (@all_aspects) {
my $cmd = bldtop_dir($app) . " -config server.cnf $args";
print "Current directory is ".getcwd()."\n";
print "Launching mock server: $cmd\n";
+ die "Invalid port: $server_port" unless $server_port =~ m/^\d+$/;
my $pid = open($server_fh, "$cmd|") or die "Trying to $cmd";
print "Pid is: $pid\n";
- # Find out the actual server port
- while (<$server_fh>) {
- print;
- s/\R$//; # Better chomp
- next unless (/^ACCEPT\s.*:(\d+)$/);
- $server_port = $1;
- $server_tls = $1;
- $kur_port = $1;
- $pbm_port = $1;
- last;
+ if ($server_port eq "0") {
+ # Find out the actual server port
+ while (<$server_fh>) {
+ print;
+ s/\R$//; # Better chomp
+ next unless (/^ACCEPT/);
+ $server_port = $server_tls = $kur_port = $pbm_port = $1
+ if m/^ACCEPT\s.*?:(\d+)$/;
+ last;
+ }
}
- return $pid;
+ return $pid if $server_port =~ m/^(\d+)$/;
+ stop_mock_server($pid);
+ return 0;
}
sub stop_mock_server {