Revert the asynchronous SSL_connect.

This commit is contained in:
Jim Morrison 2012-02-20 13:15:02 -08:00
parent 6e7025b9f5
commit f404142b17
2 changed files with 2 additions and 17 deletions

View File

@ -138,8 +138,6 @@ int communicate(const std::string& host, uint16_t port,
std::cerr << "Could not connect to the host" << std::endl; std::cerr << "Could not connect to the host" << std::endl;
return -1; return -1;
} }
make_non_block(fd);
set_tcp_nodelay(fd);
SSL_CTX *ssl_ctx; SSL_CTX *ssl_ctx;
ssl_ctx = SSL_CTX_new(SSLv23_client_method()); ssl_ctx = SSL_CTX_new(SSLv23_client_method());
if(!ssl_ctx) { if(!ssl_ctx) {
@ -155,6 +153,8 @@ int communicate(const std::string& host, uint16_t port,
if(ssl_handshake(ssl, fd) == -1) { if(ssl_handshake(ssl, fd) == -1) {
return -1; return -1;
} }
make_non_block(fd);
set_tcp_nodelay(fd);
Spdylay sc(fd, ssl, callbacks); Spdylay sc(fd, ssl, callbacks);
nfds_t npollfds = 1; nfds_t npollfds = 1;

View File

@ -476,22 +476,7 @@ int ssl_handshake(SSL *ssl, int fd)
std::cerr << ERR_error_string(ERR_get_error(), 0) << std::endl; std::cerr << ERR_error_string(ERR_get_error(), 0) << std::endl;
return -1; return -1;
} }
int loop_count = 0;
int r = SSL_connect(ssl); int r = SSL_connect(ssl);
nfds_t npollfds = 1;
pollfd pollfds[1];
pollfds[0].fd = fd;
while(r == -1) {
++loop_count;
int nfds = poll(pollfds, npollfds, -1);
if(nfds == -1)
continue;
r = SSL_connect(ssl);
}
std::cerr << "Loop iterated #" << loop_count << " times." << std::endl;
//std::cerr << "Event is " << pollfds[0].events << ":" << pollfds[0].revents << std::endl;
if(r <= 0) { if(r <= 0) {
std::cerr << ERR_error_string(ERR_get_error(), 0) << std::endl; std::cerr << ERR_error_string(ERR_get_error(), 0) << std::endl;
return -1; return -1;