Branch: Tag:

2015-05-18

2015-05-18 15:57:18 by Henrik Grubbström (Grubba) <grubba@grubba.org>

SSL: Improved robustness of the async_tls_close test.

The test is run four times in succession, and attempted to use
the same (fixed) port number every time. This would cause the
test to fail if something else already had claimed the port
(unlikely), or if the OS had a too long grace period (common).

The test now lets the OS allocate a port.

Also adds a timeout if the TLS connection doesn't wake up when
the port is closed.

This should fix intermittent testsuite failures on several platforms,
where the testsuite watchdog killed the SSL testsuite.

16:    Pike.Backend blocked_backend = Pike.Backend();    Stdio.Port blocked_server = Stdio.Port();    blocked_server->set_backend (blocked_backend); -  blocked_server->bind (36565, lambda () { +  if (!blocked_server->bind (0, +  lambda () {    fail = "Should never accept a connection.\n"; -  }); +  })) { +  Tools.Testsuite.log_msg("Failed to bind port: %s.\n", strerror(errno())); +  Tools.Testsuite.report_result(0, 1); +  exit(4); +  }    -  +  string addr = blocked_server->query_address(); +  int port = (int)(addr/" ")[-1]; +  addr = (addr/" ")[0]; +     Stdio.File con = Stdio.File();    SSL.File tlscon;    con->async_connect ( -  "127.0.0.1", 36565, +  addr, port,    lambda (int success) {    if (success) {    tlscon = SSL.File (con, SSL.Context());
77:    "clean_close=%d block=%d res=%{%O %}\n",    clean_close, block, res);    Tools.Testsuite.report_result (successful, !successful); -  exit (!successful); +  _exit (!successful);    })    fail = "Error in call out: " + describe_backtrace (err);    }    if (fail) werror (fail); -  exit (2); +  _exit (2);    }, 0.5);       thread_create (lambda () {    sleep (1);   #if 0    werror ("\n"); -  +  werror ("blocked_server: %O (fd: %d)\n", +  blocked_server, blocked_server->query_fd());    foreach (all_threads(), Thread.Thread t)    werror ("\n" + describe_backtrace (t->backtrace()));   #endif    destruct (blocked_server); -  +  +  sleep (2); +  Tools.Testsuite.log_msg("Poll didn't wake up.\n" +  "Async tls close on stalled connection failed: " +  "tlscon: %O " +  "clean_close=%d block=%d\n", +  tlscon, clean_close, block); +  Tools.Testsuite.report_result(0, 1); +  _exit(3);    });       return -1;   }