Lines Matching refs:query
55 struct query *query;
63 /* Verify that the query is at least long enough to hold the header. */
73 /* Check query cache */
83 /* Allocate space for query and allocated fields. */
84 query = ares_malloc(sizeof(struct query));
85 if (!query) {
89 memset(query, 0, sizeof(*query));
91 query->channel = channel;
92 query->qbuf = ares_malloc(qlen);
93 if (!query->qbuf) {
94 ares_free(query);
99 query->qid = id;
100 query->timeout.tv_sec = 0;
101 query->timeout.tv_usec = 0;
103 /* Ignore first 2 bytes, assign our own query id */
104 query->qbuf[0] = (unsigned char)((id >> 8) & 0xFF);
105 query->qbuf[1] = (unsigned char)(id & 0xFF);
106 memcpy(query->qbuf + 2, qbuf + 2, qlen - 2);
107 query->qlen = qlen;
109 /* Fill in query arguments. */
110 query->callback = callback;
111 query->arg = arg;
113 /* Initialize query status. */
114 query->try_count = 0;
117 query->using_tcp = (channel->flags & ARES_FLAG_USEVC) || qlen > packetsz;
119 query->error_status = ARES_SUCCESS;
120 query->timeouts = 0;
123 query->node_queries_by_timeout = NULL;
124 query->node_queries_to_conn = NULL;
126 /* Chain the query into the list of all queries. */
127 query->node_all_queries =
128 ares__llist_insert_last(channel->all_queries, query);
129 if (query->node_all_queries == NULL) {
131 ares__free_query(query);
138 if (!ares__htable_szvp_insert(channel->queries_by_qid, query->qid, query)) {
140 ares__free_query(query);
144 /* Perform the first query action. */
146 status = ares__send_query(query, &now);