return 1;
}
+ ret = SSL_get_error(vpninfo->https_ssl, len);
+ if (ret == SSL_ERROR_SYSCALL || ret == SSL_ERROR_ZERO_RETURN) {
+ vpninfo->progress(vpninfo, PRG_ERR,
+ "SSL read error %d (server probably closed connection); reconnecting.\n",
+ ret);
+ goto do_reconnect;
+ }
+
/* If SSL_write() fails we are expected to try again. With exactly
the same data, at exactly the same location. So we keep the
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
- if (select(vpninfo->select_nfds, &rfds, &wfds, &efds, &tv) >= 0
- && FD_ISSET(vpninfo->ssl_fd, &rfds)) {
- char b;
- if (recv(vpninfo->ssl_fd, &b, 1, MSG_PEEK) == 0) {
- /* Zero indicates EOF, which OpenSSL won't handle on read() */
- vpninfo->progress(vpninfo, PRG_ERR, "Server closed connection!\n");
- exit(1);
- }
- }
+
+ select(vpninfo->select_nfds, &rfds, &wfds, &efds, &tv);
}
cstp_bye(vpninfo, vpninfo->quit_reason);