Abort idle-loop in ssl_server2 if sockets gets invalid

Previously, the idling loop in ssl_server2 didn't check whether
the underlying call to mbedtls_net_poll signalled that the socket
became invalid. This had the consequence that during idling, the
server couldn't be terminated through a SIGTERM, as the corresponding
handler would only close the sockets and expect the remainder of
the program to shutdown gracefully as a consequence of this.
This was subsequently attempted to be fixed through a change
in ssl-opt.sh by terminating the server through a KILL signal,
which however lead to other problems when the latter was run
under valgrind.

This commit changes the idling loop in ssl_server2 and ssl_client2
to obey the return code of mbedtls_net_poll and gracefully shutdown
if an error occurs, e.g. because the socket was closed.

As a consequence, the server termination via a KILL signal in
ssl-opt.sh is no longer necessary, with the previous `kill; wait`
pattern being sufficient. The commit reverts the corresponding
change.
diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh
index a1155e8..1682a84 100755
--- a/tests/ssl-opt.sh
+++ b/tests/ssl-opt.sh
@@ -447,19 +447,11 @@
 
         # terminate the server (and the proxy)
         kill $SRV_PID
-        sleep 0.01
-        if kill -0 $SRV_PID >/dev/null 2>&1; then
-            kill -3 $SRV_PID
-            wait $SRV_PID
-        fi
+        wait $SRV_PID
 
         if [ -n "$PXY_CMD" ]; then
             kill $PXY_PID >/dev/null 2>&1
-            sleep 0.01
-            if kill -0 $PXY_PID >/dev/null 2>&1; then
-                kill -3 $PXY_PID
-                wait $PXY_PID
-            fi
+            wait $PXY_PID
         fi
 
         # retry only on timeouts