diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-01-08 23:19:32 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-01-08 23:19:32 +0000 |
commit | eecb86bfb0cd0fada5bdeb3c8d069f194b08208b (patch) | |
tree | 39c3d8dffceeab1dc80744a442d112b31b370054 | |
parent | 0b1197936c488950041cc54db9db9af1d82ea0b8 (diff) |
this seems to correct the SSL reading problem introduced when switching
over to non-blocking sockets, but this loops very nastily. We should return
back to the select() and wait there until more data arrives, not just blindly
attempt again and again...
-rw-r--r-- | lib/sendf.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/sendf.c b/lib/sendf.c index ad144edd8..78581f585 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -279,13 +279,28 @@ CURLcode Curl_read(struct connectdata *conn, int sockfd, #ifdef USE_SSLEAY if (conn->ssl.use) { - int loop=100; /* just a precaution to never loop endlessly */ - while(loop--) { + bool loop=TRUE; + int err; + do { nread = SSL_read(conn->ssl.handle, buf, buffersize); - if((-1 != nread) || - (SSL_ERROR_WANT_READ != SSL_get_error(conn->ssl.handle, nread) )) + + if(nread > 0) + /* successful read */ break; - } + + err = SSL_get_error(conn->ssl.handle, nread); + + switch(err) { + case SSL_ERROR_NONE: /* this is not an error */ + case SSL_ERROR_ZERO_RETURN: /* no more data */ + loop=0; /* get out of loop */ + break; + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_WRITE: + /* if there's data pending, then we re-invoke SSL_read() */ + break; + } + } while(loop && SSL_pending(conn->ssl.handle)); } else { #endif |