title: Is it safe to do SSL_shutdown again if socket returns SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE
body: <p>I am trying perform SSL_shutdown on a non-blocking socket. In the code below, i am trying poll after trying SSL_shutdown.</p>
  <pre><code>do {
      err = SSL_shutdown();
      if (err == 0) {
         // unidirectional shutdown success, will try SSL_shutdown once more and exit
      } else if (err == 1) {
         //shutdown complete. Exit
      } else {
         ec = SSL_get_error(ctx, err);
         if (ec == SSL_ERROR_WANT_READ) {
             rc = poll(fd, POLLIN|POLLPRI, timeout);
             if (rc &gt; 0) {
                 continue;
             } else {
                 break;
             }
         } else if (ec == SSL_ERROR_WANT_WRITE) {
             rc = poll(fd, POLLOUT, timeout);
             if (rc &gt; 0) {
                 continue;
             } else {
                 break;
             }
         } else {
             break;
         }
      }
  } while(1);
  </code></pre>
  <p>After a successful <code>poll</code> is it possible that the socket is writeable or readable and triggering the shutdown will WANT_WRITE or WANT_READ again. Can the above code get stuck in an infinite loop?</p>