- /* Call dns */
- status = dns_process(dns_conn->dns_socket->dns, call, &call->in, &call->out);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("dns_process returned %s\n", nt_errstr(status)));
+ subreq = dns_process_send(call, dns->task->event_ctx, dns,
+ &call->in);
+ if (subreq == NULL) {
+ dns_tcp_terminate_connection(
+ dns_conn, "dns_tcp_call_loop: dns_process_send "
+ "failed\n");
+ return;
+ }
+ tevent_req_set_callback(subreq, dns_tcp_call_process_done, call);
+
+ /*
+ * The dns tcp pdu's has the length as 2 byte (initial_read_size),
+ * packet_full_request_u16 provides the pdu length then.
+ */
+ subreq = tstream_read_pdu_blob_send(dns_conn,
+ dns_conn->conn->event.ctx,
+ dns_conn->tstream,
+ 2, /* initial_read_size */
+ packet_full_request_u16,
+ dns_conn);
+ if (subreq == NULL) {
+ dns_tcp_terminate_connection(dns_conn, "dns_tcp_call_loop: "
+ "no memory for tstream_read_pdu_blob_send");
+ return;
+ }
+ tevent_req_set_callback(subreq, dns_tcp_call_loop, dns_conn);
+}
+
+static void dns_tcp_call_process_done(struct tevent_req *subreq)
+{
+ struct dns_tcp_call *call = tevent_req_callback_data(subreq,
+ struct dns_tcp_call);
+ struct dns_tcp_connection *dns_conn = call->dns_conn;
+ WERROR err;
+
+ err = dns_process_recv(subreq, call, &call->out);
+ TALLOC_FREE(subreq);
+ if (!W_ERROR_IS_OK(err)) {
+ DEBUG(1, ("dns_process returned %s\n", win_errstr(err)));