Lines Matching refs:query

44   struct query *query;
48 /* Verify that the query is at least long enough to hold the header. */
55 /* Allocate space for query and allocated fields. */
56 query = malloc(sizeof(struct query));
57 if (!query)
62 query->tcpbuf = malloc(qlen + 2);
63 if (!query->tcpbuf)
65 free(query);
69 query->server_info = malloc(channel->nservers *
70 sizeof(query->server_info[0]));
71 if (!query->server_info)
73 free(query->tcpbuf);
74 free(query);
79 /* Compute the query ID. Start with no timeout. */
80 query->qid = (unsigned short)DNS_HEADER_QID(qbuf);
81 query->timeout.tv_sec = 0;
82 query->timeout.tv_usec = 0;
84 /* Form the TCP query buffer by prepending qlen (as two
87 query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff);
88 query->tcpbuf[1] = (unsigned char)(qlen & 0xff);
89 memcpy(query->tcpbuf + 2, qbuf, qlen);
90 query->tcplen = qlen + 2;
92 /* Fill in query arguments. */
93 query->qbuf = query->tcpbuf + 2;
94 query->qlen = qlen;
95 query->callback = callback;
96 query->arg = arg;
98 /* Initialize query status. */
99 query->try_count = 0;
101 /* Choose the server to send the query to. If rotation is enabled, keep track
103 query->server = channel->last_server;
109 query->server_info[i].skip_server = 0;
110 query->server_info[i].tcp_connection_generation = 0;
112 query->using_tcp = (channel->flags & ARES_FLAG_USEVC) || qlen > PACKETSZ;
113 query->error_status = ARES_ECONNREFUSED;
114 query->timeouts = 0;
117 ares__init_list_node(&(query->queries_by_qid), query);
118 ares__init_list_node(&(query->queries_by_timeout), query);
119 ares__init_list_node(&(query->queries_to_server), query);
120 ares__init_list_node(&(query->all_queries), query);
122 /* Chain the query into the list of all queries. */
123 ares__insert_in_list(&(query->all_queries), &(channel->all_queries));
128 &(query->queries_by_qid),
129 &(channel->queries_by_qid[query->qid % ARES_QID_TABLE_SIZE]));
131 /* Perform the first query action. */
133 ares__send_query(channel, query, &now);