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/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index 74a1142..e296339 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -846,16 +846,17 @@
  * (Used in event-driven IO mode).
  */
 #if !defined(MBEDTLS_TIMING_C)
-void idle( mbedtls_net_context *fd,
+int idle( mbedtls_net_context *fd,
            int idle_reason )
 {
 #else
-void idle( mbedtls_net_context *fd,
+int idle( mbedtls_net_context *fd,
            mbedtls_timing_delay_context *timer,
            int idle_reason )
 {
 #endif
 
+    int ret;
     int poll_type = 0;
 
     if( idle_reason == MBEDTLS_ERR_SSL_WANT_WRITE )
@@ -879,12 +880,17 @@
 #endif /* MBEDTLS_TIMING_C */
 
         /* Check if underlying transport became available */
-        if( poll_type != 0 &&
-            mbedtls_net_poll( fd, poll_type, 0 ) == poll_type )
+        if( poll_type != 0 )
         {
-            break;
+            ret = mbedtls_net_poll( fd, poll_type, 0 );
+            if( ret < 0 )
+                return( ret );
+            if( ret == poll_type )
+                break;
         }
     }
+
+    return( 0 );
 }
 
 int main( int argc, char *argv[] )
@@ -2205,10 +2211,12 @@
         if( opt.event == 1 /* level triggered IO */ )
         {
 #if defined(MBEDTLS_TIMING_C)
-            idle( &client_fd, &timer, ret );
+            ret = idle( &client_fd, &timer, ret );
 #else
-            idle( &client_fd, ret );
+            ret = idle( &client_fd, ret );
 #endif
+            if( ret != 0 )
+                goto reset;
         }
     }