- Timestamp:
- Jun 7, 2007 3:47:31 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/resolver.c
r1323 r1348 63 63 }; 64 64 65 static const char *state_names[3] = 66 { 67 "Probing", 68 "Active", 69 "Bad" 70 }; 71 72 65 73 /* 66 74 * Each nameserver entry. … … 217 225 218 226 227 /* Initialize DNS settings with default values */ 228 PJ_DEF(void) pj_dns_settings_default(pj_dns_settings *s) 229 { 230 pj_bzero(s, sizeof(pj_dns_settings)); 231 s->qretr_delay = PJ_DNS_RESOLVER_QUERY_RETRANSMIT_DELAY; 232 s->qretr_count = PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT; 233 s->cache_max_ttl = PJ_DNS_RESOLVER_MAX_TTL; 234 s->good_ns_ttl = PJ_DNS_RESOLVER_GOOD_NS_TTL; 235 s->bad_ns_ttl = PJ_DNS_RESOLVER_BAD_NS_TTL; 236 } 237 238 219 239 /* 220 240 * Create the resolver. … … 258 278 resv->ioqueue = ioqueue; 259 279 resv->last_id = 1; 280 281 pj_dns_settings_default(&resv->settings); 260 282 resv->settings.options = options; 261 resv->settings.qretr_delay = PJ_DNS_RESOLVER_QUERY_RETRANSMIT_DELAY;262 resv->settings.qretr_count = PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT;263 resv->settings.cache_max_ttl = PJ_DNS_RESOLVER_MAX_TTL;264 283 265 284 /* Create the timer heap if one is not specified */ … … 791 810 { 792 811 struct nameserver *ns = &resolver->ns[index]; 812 enum ns_state old_state = ns->state; 793 813 794 814 ns->state = state; … … 796 816 797 817 if (state == STATE_PROBING) 798 ns->state_expiry.sec += (( PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT+ 2) *799 PJ_DNS_RESOLVER_QUERY_RETRANSMIT_DELAY) / 1000;818 ns->state_expiry.sec += ((resolver->settings.qretr_count + 2) * 819 resolver->settings.qretr_delay) / 1000; 800 820 else if (state == STATE_ACTIVE) 801 ns->state_expiry.sec += PJ_DNS_RESOLVER_GOOD_NS_TTL;821 ns->state_expiry.sec += resolver->settings.good_ns_ttl; 802 822 else 803 ns->state_expiry.sec += PJ_DNS_RESOLVER_BAD_NS_TTL; 804 823 ns->state_expiry.sec += resolver->settings.bad_ns_ttl; 824 825 PJ_LOG(5, (resolver->name.ptr, "Nameserver %s:%d state changed %s --> %s", 826 pj_inet_ntoa(ns->addr.sin_addr), 827 (int)pj_ntohs(ns->addr.sin_port), 828 state_names[old_state], state_names[state])); 805 829 } 806 830 … … 1071 1095 1072 1096 /* Check to see if we should retransmit instead of time out */ 1073 if (q->transmit_cnt < PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT) {1097 if (q->transmit_cnt < resolver->settings.qretr_count) { 1074 1098 status = transmit_query(resolver, q); 1075 1099 if (status == PJ_SUCCESS) { … … 1204 1228 if (!q) { 1205 1229 PJ_LOG(5,(resolver->name.ptr, 1206 "Unable to find query for DNS response id=%d from %s:%d " 1207 "(the query may had been answered by other name servers)", 1208 (unsigned)dns_pkt->hdr.id, 1230 "DNS response from %s:%d id=%d discarded", 1209 1231 pj_inet_ntoa(resolver->udp_src_addr.sin_addr), 1210 pj_ntohs(resolver->udp_src_addr.sin_port))); 1232 pj_ntohs(resolver->udp_src_addr.sin_port), 1233 (unsigned)dns_pkt->hdr.id)); 1211 1234 goto read_next_packet; 1212 1235 }
Note: See TracChangeset
for help on using the changeset viewer.