00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "setup.h"
00025
00026 #include <string.h>
00027
00028 #ifdef NEED_MALLOC_H
00029 #include <malloc.h>
00030 #endif
00031 #ifdef HAVE_SYS_SOCKET_H
00032 #include <sys/socket.h>
00033 #endif
00034 #ifdef HAVE_NETINET_IN_H
00035 #include <netinet/in.h>
00036 #endif
00037 #ifdef HAVE_NETDB_H
00038 #include <netdb.h>
00039 #endif
00040 #ifdef HAVE_ARPA_INET_H
00041 #include <arpa/inet.h>
00042 #endif
00043 #ifdef HAVE_STDLIB_H
00044 #include <stdlib.h>
00045 #endif
00046 #ifdef HAVE_UNISTD_H
00047 #include <unistd.h>
00048 #endif
00049 #ifdef VMS
00050 #include <in.h>
00051 #include <inet.h>
00052 #include <stdlib.h>
00053 #endif
00054
00055 #ifdef HAVE_SETJMP_H
00056 #include <setjmp.h>
00057 #endif
00058
00059 #ifdef HAVE_PROCESS_H
00060 #include <process.h>
00061 #endif
00062
00063 #include "urldata.h"
00064 #include "sendf.h"
00065 #include "hostip.h"
00066 #include "hash.h"
00067 #include "share.h"
00068 #include "strerror.h"
00069 #include "url.h"
00070
00071 #define _MPRINTF_REPLACE
00072 #include <curl/mprintf.h>
00073
00074 #if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
00075 #include "inet_ntoa_r.h"
00076 #endif
00077
00078 #include "memory.h"
00079
00080 #include "memdebug.h"
00081
00082
00083
00084
00085 #ifdef CURLRES_ASYNCH
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 static CURLcode addrinfo_callback(void *arg,
00100 int status,
00101 void *addr)
00102 {
00103 struct connectdata *conn = (struct connectdata *)arg;
00104 struct Curl_dns_entry *dns = NULL;
00105 CURLcode rc = CURLE_OK;
00106
00107 conn->async.status = status;
00108
00109 if(CURL_ASYNC_SUCCESS == status) {
00110
00111
00112
00113
00114
00115
00116
00117 Curl_addrinfo *ai = Curl_addrinfo_copy(addr, conn->async.port);
00118 if(ai) {
00119 struct SessionHandle *data = conn->data;
00120
00121 if(data->share)
00122 Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
00123
00124 dns = Curl_cache_addr(data, ai,
00125 conn->async.hostname,
00126 conn->async.port);
00127 if(!dns) {
00128
00129 Curl_freeaddrinfo(ai);
00130 rc = CURLE_OUT_OF_MEMORY;
00131 }
00132
00133 if(data->share)
00134 Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
00135 }
00136 else
00137 rc = CURLE_OUT_OF_MEMORY;
00138 }
00139
00140 conn->async.dns = dns;
00141
00142
00143
00144
00145 conn->async.done = TRUE;
00146
00147
00148
00149 return rc;
00150 }
00151
00152 CURLcode Curl_addrinfo4_callback(void *arg,
00153 int status,
00154 struct hostent *hostent)
00155 {
00156 return addrinfo_callback(arg, status, hostent);
00157 }
00158
00159 #ifdef CURLRES_IPV6
00160 CURLcode Curl_addrinfo6_callback(void *arg,
00161 int status,
00162 struct addrinfo *ai)
00163 {
00164
00165
00166
00167 return addrinfo_callback(arg, status, ai);
00168 }
00169 #endif
00170
00171 #endif