diff options
Diffstat (limited to 'linden/indra/llcommon/llares.cpp')
-rw-r--r-- | linden/indra/llcommon/llares.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/linden/indra/llcommon/llares.cpp b/linden/indra/llcommon/llares.cpp index cf5ff18..4adf0c3 100644 --- a/linden/indra/llcommon/llares.cpp +++ b/linden/indra/llcommon/llares.cpp | |||
@@ -103,18 +103,21 @@ void LLAres::QueryResponder::queryError(int code) | |||
103 | } | 103 | } |
104 | 104 | ||
105 | LLAres::LLAres() | 105 | LLAres::LLAres() |
106 | : chan_(NULL) | ||
106 | { | 107 | { |
107 | ares_init(&chan_); | 108 | ares_init(&chan_); |
108 | } | 109 | } |
109 | 110 | ||
110 | LLAres::~LLAres() | 111 | LLAres::~LLAres() |
111 | { | 112 | { |
112 | ares_destroy(chan_); | 113 | if (chan_) |
114 | ares_destroy(chan_); | ||
113 | } | 115 | } |
114 | 116 | ||
115 | void LLAres::cancel() | 117 | void LLAres::cancel() |
116 | { | 118 | { |
117 | ares_cancel(chan_); | 119 | if (chan_) |
120 | ares_cancel(chan_); | ||
118 | } | 121 | } |
119 | 122 | ||
120 | static void host_callback(void *arg, int status, struct hostent *ent) | 123 | static void host_callback(void *arg, int status, struct hostent *ent) |
@@ -135,6 +138,11 @@ static void host_callback(void *arg, int status, struct hostent *ent) | |||
135 | void LLAres::getHostByName(const char *name, HostResponder *resp, | 138 | void LLAres::getHostByName(const char *name, HostResponder *resp, |
136 | int family) | 139 | int family) |
137 | { | 140 | { |
141 | if (!chan_) | ||
142 | { | ||
143 | resp->hostError(ARES_EBADRESP); | ||
144 | return; | ||
145 | } | ||
138 | ares_gethostbyname(chan_, name, family, host_callback, | 146 | ares_gethostbyname(chan_, name, family, host_callback, |
139 | new LLPointer<LLAres::HostResponder>(resp)); | 147 | new LLPointer<LLAres::HostResponder>(resp)); |
140 | } | 148 | } |
@@ -398,6 +406,11 @@ static void nameinfo_callback(void *arg, int status, char *node, char *service) | |||
398 | void LLAres::getNameInfo(const struct sockaddr &sa, socklen_t salen, int flags, | 406 | void LLAres::getNameInfo(const struct sockaddr &sa, socklen_t salen, int flags, |
399 | NameInfoResponder *resp) | 407 | NameInfoResponder *resp) |
400 | { | 408 | { |
409 | if (!chan_) | ||
410 | { | ||
411 | resp->nameInfoError(ARES_EBADRESP); | ||
412 | return; | ||
413 | } | ||
401 | ares_getnameinfo(chan_, &sa, salen, flags, nameinfo_callback, | 414 | ares_getnameinfo(chan_, &sa, salen, flags, nameinfo_callback, |
402 | new LLPointer<NameInfoResponder>(resp)); | 415 | new LLPointer<NameInfoResponder>(resp)); |
403 | } | 416 | } |
@@ -421,6 +434,11 @@ static void search_callback(void *arg, int status, unsigned char *abuf, | |||
421 | void LLAres::search(const std::string &query, LLResType type, | 434 | void LLAres::search(const std::string &query, LLResType type, |
422 | QueryResponder *resp) | 435 | QueryResponder *resp) |
423 | { | 436 | { |
437 | if (!chan_) | ||
438 | { | ||
439 | resp->queryError(ARES_EBADRESP); | ||
440 | return; | ||
441 | } | ||
424 | ares_search(chan_, query.c_str(), ns_c_in, type, search_callback, | 442 | ares_search(chan_, query.c_str(), ns_c_in, type, search_callback, |
425 | new LLPointer<QueryResponder>(resp)); | 443 | new LLPointer<QueryResponder>(resp)); |
426 | } | 444 | } |
@@ -440,6 +458,11 @@ bool LLAres::process(U64 timeout) | |||
440 | int nactive = 0; | 458 | int nactive = 0; |
441 | int bitmask; | 459 | int bitmask; |
442 | 460 | ||
461 | if (!chan_) | ||
462 | { | ||
463 | goto bail; | ||
464 | } | ||
465 | |||
443 | bitmask = ares_getsock(chan_, socks, ARES_GETSOCK_MAXNUM); | 466 | bitmask = ares_getsock(chan_, socks, ARES_GETSOCK_MAXNUM); |
444 | 467 | ||
445 | if (bitmask == 0) | 468 | if (bitmask == 0) |
@@ -511,6 +534,11 @@ bail: | |||
511 | 534 | ||
512 | bool LLAres::processAll() | 535 | bool LLAres::processAll() |
513 | { | 536 | { |
537 | if (!chan_) | ||
538 | { | ||
539 | return false; | ||
540 | } | ||
541 | |||
514 | bool anyProcessed = false, ret; | 542 | bool anyProcessed = false, ret; |
515 | 543 | ||
516 | do { | 544 | do { |