diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmessage/llares.cpp (renamed from linden/indra/llcommon/llares.cpp) | 99 |
1 files changed, 49 insertions, 50 deletions
diff --git a/linden/indra/llcommon/llares.cpp b/linden/indra/llmessage/llares.cpp index 4d054e4..5a310b3 100644 --- a/linden/indra/llcommon/llares.cpp +++ b/linden/indra/llmessage/llares.cpp | |||
@@ -31,17 +31,15 @@ | |||
31 | * $/LicenseInfo$ | 31 | * $/LicenseInfo$ |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifdef LL_STANDALONE | 34 | #include "linden_common.h" |
35 | # include <ares_dns.h> | ||
36 | #else | ||
37 | # include <ares/ares_dns.h> | ||
38 | #endif | ||
39 | 35 | ||
40 | #include "apr-1/apr_portable.h" | 36 | #include <ares_dns.h> |
41 | #include "apr-1/apr_network_io.h" | 37 | #include <ares_version.h> |
42 | #include "apr-1/apr_poll.h" | 38 | |
39 | #include "apr_portable.h" | ||
40 | #include "apr_network_io.h" | ||
41 | #include "apr_poll.h" | ||
43 | 42 | ||
44 | #include "linden_common.h" | ||
45 | #include "llapr.h" | 43 | #include "llapr.h" |
46 | #include "llares.h" | 44 | #include "llares.h" |
47 | 45 | ||
@@ -103,24 +101,22 @@ void LLAres::QueryResponder::queryError(int code) | |||
103 | } | 101 | } |
104 | 102 | ||
105 | LLAres::LLAres() | 103 | LLAres::LLAres() |
106 | : chan_(NULL) | ||
107 | { | 104 | { |
108 | ares_init(&chan_); | 105 | ares_init(&chan_); |
109 | } | 106 | } |
110 | 107 | ||
111 | LLAres::~LLAres() | 108 | LLAres::~LLAres() |
112 | { | 109 | { |
113 | if (chan_) | 110 | ares_destroy(chan_); |
114 | ares_destroy(chan_); | ||
115 | } | 111 | } |
116 | 112 | ||
117 | void LLAres::cancel() | 113 | void LLAres::cancel() |
118 | { | 114 | { |
119 | if (chan_) | 115 | ares_cancel(chan_); |
120 | ares_cancel(chan_); | ||
121 | } | 116 | } |
122 | 117 | ||
123 | static void host_callback(void *arg, int status, struct hostent *ent) | 118 | static void host_callback_1_5(void *arg, int status, int timeouts, |
119 | struct hostent *ent) | ||
124 | { | 120 | { |
125 | LLPointer<LLAres::HostResponder> *resp = | 121 | LLPointer<LLAres::HostResponder> *resp = |
126 | (LLPointer<LLAres::HostResponder> *) arg; | 122 | (LLPointer<LLAres::HostResponder> *) arg; |
@@ -135,14 +131,18 @@ static void host_callback(void *arg, int status, struct hostent *ent) | |||
135 | delete resp; | 131 | delete resp; |
136 | } | 132 | } |
137 | 133 | ||
134 | #if ARES_VERSION_MAJOR == 1 && ARES_VERSION_MINOR == 4 | ||
135 | static void host_callback(void *arg, int status, struct hostent *ent) | ||
136 | { | ||
137 | host_callback_1_5(arg, status, 0, ent); | ||
138 | } | ||
139 | #else | ||
140 | # define host_callback host_callback_1_5 | ||
141 | #endif | ||
142 | |||
138 | void LLAres::getHostByName(const char *name, HostResponder *resp, | 143 | void LLAres::getHostByName(const char *name, HostResponder *resp, |
139 | int family) | 144 | int family) |
140 | { | 145 | { |
141 | if (!chan_) | ||
142 | { | ||
143 | resp->hostError(ARES_EBADRESP); | ||
144 | return; | ||
145 | } | ||
146 | ares_gethostbyname(chan_, name, family, host_callback, | 146 | ares_gethostbyname(chan_, name, family, host_callback, |
147 | new LLPointer<LLAres::HostResponder>(resp)); | 147 | new LLPointer<LLAres::HostResponder>(resp)); |
148 | } | 148 | } |
@@ -154,7 +154,7 @@ void LLAres::getSrvRecords(const std::string &name, SrvResponder *resp) | |||
154 | 154 | ||
155 | void LLAres::rewriteURI(const std::string &uri, UriRewriteResponder *resp) | 155 | void LLAres::rewriteURI(const std::string &uri, UriRewriteResponder *resp) |
156 | { | 156 | { |
157 | LL_DEBUGS2("AppInit","Rewrite") << "Rewriting " << uri << LL_ENDL; | 157 | llinfos << "Rewriting " << uri << llendl; |
158 | 158 | ||
159 | resp->mUri = LLURI(uri); | 159 | resp->mUri = LLURI(uri); |
160 | search("_" + resp->mUri.scheme() + "._tcp." + resp->mUri.hostName(), | 160 | search("_" + resp->mUri.scheme() + "._tcp." + resp->mUri.hostName(), |
@@ -163,8 +163,7 @@ void LLAres::rewriteURI(const std::string &uri, UriRewriteResponder *resp) | |||
163 | 163 | ||
164 | LLQueryResponder::LLQueryResponder() | 164 | LLQueryResponder::LLQueryResponder() |
165 | : LLAres::QueryResponder(), | 165 | : LLAres::QueryResponder(), |
166 | mResult(ARES_ENODATA), | 166 | mResult(ARES_ENODATA) |
167 | mType(RES_INVALID) | ||
168 | { | 167 | { |
169 | } | 168 | } |
170 | 169 | ||
@@ -342,18 +341,18 @@ bail: | |||
342 | mResult = ret; | 341 | mResult = ret; |
343 | if (mResult == ARES_SUCCESS) | 342 | if (mResult == ARES_SUCCESS) |
344 | { | 343 | { |
345 | queryResult(); | 344 | querySuccess(); |
346 | } else { | 345 | } else { |
347 | queryError(mResult); | 346 | queryError(mResult); |
348 | } | 347 | } |
349 | } | 348 | } |
350 | 349 | ||
351 | void LLQueryResponder::queryResult() | 350 | void LLQueryResponder::querySuccess() |
352 | { | 351 | { |
353 | llinfos << "LLQueryResponder::queryResult not implemented" << llendl; | 352 | llinfos << "LLQueryResponder::queryResult not implemented" << llendl; |
354 | } | 353 | } |
355 | 354 | ||
356 | void LLAres::SrvResponder::queryResult() | 355 | void LLAres::SrvResponder::querySuccess() |
357 | { | 356 | { |
358 | if (mType == RES_SRV) | 357 | if (mType == RES_SRV) |
359 | { | 358 | { |
@@ -389,7 +388,8 @@ void LLAres::SrvResponder::srvError(int code) | |||
389 | << LLAres::strerror(code) << llendl; | 388 | << LLAres::strerror(code) << llendl; |
390 | } | 389 | } |
391 | 390 | ||
392 | static void nameinfo_callback(void *arg, int status, char *node, char *service) | 391 | static void nameinfo_callback_1_5(void *arg, int status, int timeouts, |
392 | char *node, char *service) | ||
393 | { | 393 | { |
394 | LLPointer<LLAres::NameInfoResponder> *resp = | 394 | LLPointer<LLAres::NameInfoResponder> *resp = |
395 | (LLPointer<LLAres::NameInfoResponder> *) arg; | 395 | (LLPointer<LLAres::NameInfoResponder> *) arg; |
@@ -404,20 +404,24 @@ static void nameinfo_callback(void *arg, int status, char *node, char *service) | |||
404 | delete resp; | 404 | delete resp; |
405 | } | 405 | } |
406 | 406 | ||
407 | #if ARES_VERSION_MAJOR == 1 && ARES_VERSION_MINOR == 4 | ||
408 | static void nameinfo_callback(void *arg, int status, char *node, char *service) | ||
409 | { | ||
410 | nameinfo_callback_1_5(arg, status, 0, node, service); | ||
411 | } | ||
412 | #else | ||
413 | # define nameinfo_callback nameinfo_callback_1_5 | ||
414 | #endif | ||
415 | |||
407 | void LLAres::getNameInfo(const struct sockaddr &sa, socklen_t salen, int flags, | 416 | void LLAres::getNameInfo(const struct sockaddr &sa, socklen_t salen, int flags, |
408 | NameInfoResponder *resp) | 417 | NameInfoResponder *resp) |
409 | { | 418 | { |
410 | if (!chan_) | ||
411 | { | ||
412 | resp->nameInfoError(ARES_EBADRESP); | ||
413 | return; | ||
414 | } | ||
415 | ares_getnameinfo(chan_, &sa, salen, flags, nameinfo_callback, | 419 | ares_getnameinfo(chan_, &sa, salen, flags, nameinfo_callback, |
416 | new LLPointer<NameInfoResponder>(resp)); | 420 | new LLPointer<NameInfoResponder>(resp)); |
417 | } | 421 | } |
418 | 422 | ||
419 | static void search_callback(void *arg, int status, unsigned char *abuf, | 423 | static void search_callback_1_5(void *arg, int status, int timeouts, |
420 | int alen) | 424 | unsigned char *abuf, int alen) |
421 | { | 425 | { |
422 | LLPointer<LLAres::QueryResponder> *resp = | 426 | LLPointer<LLAres::QueryResponder> *resp = |
423 | (LLPointer<LLAres::QueryResponder> *) arg; | 427 | (LLPointer<LLAres::QueryResponder> *) arg; |
@@ -432,14 +436,19 @@ static void search_callback(void *arg, int status, unsigned char *abuf, | |||
432 | delete resp; | 436 | delete resp; |
433 | } | 437 | } |
434 | 438 | ||
439 | #if ARES_VERSION_MAJOR == 1 && ARES_VERSION_MINOR == 4 | ||
440 | static void search_callback(void *arg, int status, unsigned char *abuf, | ||
441 | int alen) | ||
442 | { | ||
443 | search_callback_1_5(arg, status, 0, abuf, alen); | ||
444 | } | ||
445 | #else | ||
446 | # define search_callback search_callback_1_5 | ||
447 | #endif | ||
448 | |||
435 | void LLAres::search(const std::string &query, LLResType type, | 449 | void LLAres::search(const std::string &query, LLResType type, |
436 | QueryResponder *resp) | 450 | QueryResponder *resp) |
437 | { | 451 | { |
438 | if (!chan_) | ||
439 | { | ||
440 | resp->queryError(ARES_EBADRESP); | ||
441 | return; | ||
442 | } | ||
443 | ares_search(chan_, query.c_str(), ns_c_in, type, search_callback, | 452 | ares_search(chan_, query.c_str(), ns_c_in, type, search_callback, |
444 | new LLPointer<QueryResponder>(resp)); | 453 | new LLPointer<QueryResponder>(resp)); |
445 | } | 454 | } |
@@ -459,11 +468,6 @@ bool LLAres::process(U64 timeout) | |||
459 | int nactive = 0; | 468 | int nactive = 0; |
460 | int bitmask; | 469 | int bitmask; |
461 | 470 | ||
462 | if (!chan_) | ||
463 | { | ||
464 | goto bail; | ||
465 | } | ||
466 | |||
467 | bitmask = ares_getsock(chan_, socks, ARES_GETSOCK_MAXNUM); | 471 | bitmask = ares_getsock(chan_, socks, ARES_GETSOCK_MAXNUM); |
468 | 472 | ||
469 | if (bitmask == 0) | 473 | if (bitmask == 0) |
@@ -535,11 +539,6 @@ bail: | |||
535 | 539 | ||
536 | bool LLAres::processAll() | 540 | bool LLAres::processAll() |
537 | { | 541 | { |
538 | if (!chan_) | ||
539 | { | ||
540 | return false; | ||
541 | } | ||
542 | |||
543 | bool anyProcessed = false, ret; | 542 | bool anyProcessed = false, ret; |
544 | 543 | ||
545 | do { | 544 | do { |
@@ -735,7 +734,7 @@ void LLAres::UriRewriteResponder::queryError(int code) | |||
735 | rewriteResult(uris); | 734 | rewriteResult(uris); |
736 | } | 735 | } |
737 | 736 | ||
738 | void LLAres::UriRewriteResponder::queryResult() | 737 | void LLAres::UriRewriteResponder::querySuccess() |
739 | { | 738 | { |
740 | std::vector<std::string> uris; | 739 | std::vector<std::string> uris; |
741 | 740 | ||