diff options
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -287,6 +287,13 @@ CURLcode curl_global_init(long flags) } #endif +#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_INIT) + if(libssh2_init(0)) { + DEBUGF(fprintf(stderr, "Error: libssh2_init failed\n")); + return CURLE_FAILED_INIT; + } +#endif + init_flags = flags; /* Preset pseudo-random number sequence. */ @@ -355,6 +362,10 @@ void curl_global_cleanup(void) amiga_cleanup(); #endif +#if defined(USE_LIBSSH2) && defined(HAVE_LIBSSH2_EXIT) + (void)libssh2_exit(); +#endif + init_flags = 0; } @@ -689,8 +700,9 @@ CURL *curl_easy_duphandle(CURL *incurl) } #ifdef USE_ARES - /* If we use ares, we setup a new ares channel for the new handle */ - if(ARES_SUCCESS != ares_init(&outcurl->state.areschannel)) + /* If we use ares, we clone the ares channel for the new handle */ + if(ARES_SUCCESS != ares_dup(&outcurl->state.areschannel, + data->state.areschannel)) break; #endif @@ -1061,9 +1073,6 @@ static CURLcode easy_connection(struct SessionHandle *data, curl_socket_t *sfd, struct connectdata **connp) { - CURLcode ret; - long sockfd; - if(data == NULL) return CURLE_BAD_FUNCTION_ARGUMENT; @@ -1073,18 +1082,13 @@ static CURLcode easy_connection(struct SessionHandle *data, return CURLE_UNSUPPORTED_PROTOCOL; } - ret = Curl_getconnectinfo(data, &sockfd, connp); - if(ret != CURLE_OK) - return ret; + *sfd = Curl_getconnectinfo(data, connp); - if(sockfd == -1) { + if(*sfd == CURL_SOCKET_BAD) { failf(data, "Failed to get recent socket"); return CURLE_UNSUPPORTED_PROTOCOL; } - *sfd = (curl_socket_t)sockfd; /* we know that this is actually a socket - descriptor so the typecast is fine here */ - return CURLE_OK; } @@ -1097,7 +1101,6 @@ CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n) { curl_socket_t sfd; CURLcode ret; - int ret1; ssize_t n1; struct connectdata *c; struct SessionHandle *data = (struct SessionHandle *)curl; @@ -1107,13 +1110,10 @@ CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n) return ret; *n = 0; - ret1 = Curl_read(c, sfd, buffer, buflen, &n1); + ret = Curl_read(c, sfd, buffer, buflen, &n1); - if(ret1 == -1) - return CURLE_AGAIN; - - if(ret1 != CURLE_OK) - return (CURLcode)ret1; + if(ret != CURLE_OK) + return ret; *n = (size_t)n1; |