Lines Matching refs:channel
129 static ares_status_t init_by_defaults(ares_channel_t *channel)
140 if (!(channel->optmask & ARES_OPT_FLAGS)) {
141 channel->flags = ARES_FLAG_EDNS;
143 if (channel->ednspsz == 0) {
144 channel->ednspsz = EDNSPACKETSZ;
147 if (channel->timeout == 0) {
148 channel->timeout = DEFAULT_TIMEOUT;
151 if (channel->tries == 0) {
152 channel->tries = DEFAULT_TRIES;
155 if (channel->ndots == 0) {
156 channel->ndots = 1;
159 if (ares__slist_len(channel->servers) == 0) {
160 /* Add a default local named server to the channel unless configured not
163 if (channel->flags & ARES_FLAG_NO_DFLT_SVR) {
176 rc = ares__servers_update(channel, sconfig, ARES_FALSE);
193 if (channel->ndomains == 0) {
198 channel->ndomains = 0; /* default to none */
203 channel->ndomains = 0; /* default to none */
237 channel->domains = ares_malloc(sizeof(char *));
238 if (!channel->domains) {
242 channel->domains[0] = ares_strdup(dot + 1);
243 if (!channel->domains[0]) {
247 channel->ndomains = 1;
252 if (channel->nsort == 0) {
253 channel->sortlist = NULL;
256 if (!channel->lookups) {
257 channel->lookups = ares_strdup("fb");
258 if (!channel->lookups) {
265 if (channel->domains && channel->domains[0]) {
266 ares_free(channel->domains[0]);
268 if (channel->domains) {
269 ares_free(channel->domains);
270 channel->domains = NULL;
273 if (channel->lookups) {
274 ares_free(channel->lookups);
275 channel->lookups = NULL;
278 if (channel->resolvconf_path) {
279 ares_free(channel->resolvconf_path);
280 channel->resolvconf_path = NULL;
283 if (channel->hosts_path) {
284 ares_free(channel->hosts_path);
285 channel->hosts_path = NULL;
299 ares_channel_t *channel;
306 channel = ares_malloc_zero(sizeof(*channel));
307 if (!channel) {
312 status = ares__channel_threading_init(channel);
318 channel->rand_state = ares__init_rand_state();
319 if (channel->rand_state == NULL) {
327 channel->servers =
328 ares__slist_create(channel->rand_state, server_sort_cb, server_destroy_cb);
329 if (channel->servers == NULL) {
335 channel->all_queries = ares__llist_create(NULL);
336 if (channel->all_queries == NULL) {
341 channel->queries_by_qid = ares__htable_szvp_create(NULL);
342 if (channel->queries_by_qid == NULL) {
347 channel->queries_by_timeout =
348 ares__slist_create(channel->rand_state, ares_query_timeout_cmp_cb, NULL);
349 if (channel->queries_by_timeout == NULL) {
354 channel->connnode_by_socket = ares__htable_asvp_create(NULL);
355 if (channel->connnode_by_socket == NULL) {
364 status = ares__init_by_options(channel, options, optmask);
373 if (channel->qcache_max_ttl > 0) {
374 status = ares__qcache_create(channel->rand_state, channel->qcache_max_ttl,
375 &channel->qcache);
382 status = ares__init_by_sysconfig(channel);
393 status = init_by_defaults(channel);
401 if (channel->optmask & ARES_OPT_EVENT_THREAD) {
402 status = ares_event_thread_init(channel);
410 ares_destroy(channel);
414 *channelptr = channel;
418 ares_status_t ares_reinit(ares_channel_t *channel)
422 if (channel == NULL) {
426 ares__channel_lock(channel);
428 status = ares__init_by_sysconfig(channel);
435 if (channel->qcache) {
436 ares__qcache_flush(channel->qcache);
439 ares__channel_unlock(channel);
444 /* ares_dup() duplicates a channel handle with all its options and returns a
445 new channel handle */
467 /* Then create the new channel with those options */
526 void ares_set_local_ip4(ares_channel_t *channel, unsigned int local_ip)
528 if (channel == NULL) {
531 ares__channel_lock(channel);
532 channel->local_ip4 = local_ip;
533 ares__channel_unlock(channel);
537 void ares_set_local_ip6(ares_channel_t *channel, const unsigned char *local_ip6)
539 if (channel == NULL) {
542 ares__channel_lock(channel);
543 memcpy(&channel->local_ip6, local_ip6, sizeof(channel->local_ip6));
544 ares__channel_unlock(channel);
548 void ares_set_local_dev(ares_channel_t *channel, const char *local_dev_name)
550 if (channel == NULL) {
554 ares__channel_lock(channel);
555 ares_strcpy(channel->local_dev_name, local_dev_name,
556 sizeof(channel->local_dev_name));
557 channel->local_dev_name[sizeof(channel->local_dev_name) - 1] = 0;
558 ares__channel_unlock(channel);
561 int ares_set_sortlist(ares_channel_t *channel, const char *sortstr)
567 if (!channel) {
570 ares__channel_lock(channel);
574 if (channel->sortlist) {
575 ares_free(channel->sortlist);
577 channel->sortlist = sortlist;
578 channel->nsort = nsort;
581 channel->optmask |= ARES_OPT_SORTLIST;
583 ares__channel_unlock(channel);