<div dir="ltr">Hi,<br><br>I am trying to hack unbound to support concurrent processing for queries from the same TCP connection. <div><br></div><div>My understanding of the current Unbound code:</div><div>Current Unbound code uses a data struct "comm_point" for each TCP connection. </div>
<div>Each "comm_point" corresponds to one TCP connection (to handle all queries from that connection). But each "comm_point" has only one buffer, which is used to store query and response at different time.</div>
<div><br></div><div>Current Unbound code restricts the concurrent processing for TCP. It reads only one query from the TCP connection each time, after that, it stops receiving queries until it sends back the response for the previously received query. In this way, all queries/responses are sequentialized, so there won't be any conflict of using one buffer. </div>
<div><br></div><div>However, if we remove the restriction (let unbound keep reading queries without blocking from the same TCP connection, so that it can process queries concurrently), using only one buffer might cause problems. For example, buffer in the "comm_point" might get overwritten if queries and responses arrive at the same time. </div>
<div><br></div><div>I will really appreciate if someone can give me some hints about how to hack this : to support concurrent processing for queries from the same TCP connection. </div><div>Any ideas are welcomed. </div><div>
<br></div><div><br></div><div><br></div><div>----------------------------</div><div><br></div><div>I made a naive attempt, but failed. Maybe someone can also comment on my attempt:</div><div>a) comment out "if(c->type == comm_tcp) comm_point_stop_listening(c);" </div>
<div>and let "c->tcp_is_reading“ always equal to 1 in the "tcp_callback_reader" function, to make unbound keep receiving queries without blocking. </div><div>b) add "(repinfo->c)->tcp_is_reading = 0;" in the "comm_point_send_reply" function, to schedule write event when response is coming back from authoritative.</div>
<div><br></div><div>In this way, unbound does keep reading queries without blocking, and queries get handled concurrently. However, some of the queries never get responses. e.g. I only get 6~8 responses when I send 10 queries back to back on the same connection. </div>
<div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"><font color="#000000" face="sans-serif"><span style="line-height:19.049999237060547px"><br></span></font></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<font color="#000000" face="sans-serif"><span style="line-height:19.049999237060547px">I debugged the problem for a while, and confirmed that:</span></font></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<font color="#000000" face="sans-serif"><span style="line-height:19.049999237060547px">1) unbound receives all the queries from client on the same TCP connection.</span></font></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<font color="#000000" face="sans-serif"><span style="line-height:19.049999237060547px">2) unbound gets answers for all the queries (performed recursive process for all queries). </span></font></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<font color="#000000" face="sans-serif"><span style="line-height:19.049999237060547px">3) unbound sets the write event for each response (with libevent). </span></font></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<font color="#000000" face="sans-serif"><span style="line-height:19.049999237060547px">problem: some of the write events are not executed which causes that some responses are not returned to the client. </span></font></div>
</div><div><span style="line-height:19.049999237060547px;font-family:sans-serif">But I am not sure why some of the write events are not executed. </span><br></div><div><br></div><div>I understand that this attempt seems quite naive, and probably it is not the right way. But I hope it could bring in discussions/suggestions about how to do the hack. </div>
<div><br></div><div>Thanks in advance for your help.<br><br>Best Regards,<br>-Zi</div></div>