<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">On 29/11/2023 10:19, Alexis Fidalgo
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:F92E75BF-C186-4EC2-9639-2E67AB97E2E0@gmail.com">
<pre class="moz-quote-pre" wrap="">
by the responder, what im not understanding is, why in 2 different languages (golang and python) i get the same behavior.
</pre>
</blockquote>
<p>Well, you haven't shown the code from either.<br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:F92E75BF-C186-4EC2-9639-2E67AB97E2E0@gmail.com">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">It would be extremely inefficient for PowerDNS to open a new connection for every message and close it immediately afterwards. That would be like HTTP without keepalive. And it would make no sense to send an "initialize" message to setup a connection, only to drop the connection immediately afterwards.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
I agree on this, makes no sense at all to close the socket after each message, what i found even worse is (again, at least in golang and python), from server side on the UDS. Im seeing
. bind the socket to the fd
. open the socket
. Accept from the socket (locks)</pre>
</blockquote>
<p>Note that accept() returns you a *new* fd (socket) representing
this connection.<br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:F92E75BF-C186-4EC2-9639-2E67AB97E2E0@gmail.com">
<pre class="moz-quote-pre" wrap="">
. Reads from the socket</pre>
</blockquote>
<p>...where "the socket" here means the new one returned from
accept()</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:F92E75BF-C186-4EC2-9639-2E67AB97E2E0@gmail.com">
<pre class="moz-quote-pre" wrap="">
. Answer to the socket (*)
. Locks for ever if i dont close it</pre>
</blockquote>
<p>Maybe you have a problem with buffering then. Perhaps you need to
flush the buffer after sending the response? If you don't show
code, I can only speculate. But I guess we're moving away from
the topic of PowerDNS, and onto the topic of socket programming.<br>
</p>
<span style="white-space: pre-wrap">
</span>
<blockquote type="cite"
cite="mid:F92E75BF-C186-4EC2-9639-2E67AB97E2E0@gmail.com">
<pre class="moz-quote-pre" wrap="">Im with you on this, right after Accept + Read, if im processing/answering in a different thread, it should go immediately to accept again and lock there waiting for a new message and so on, that’s the correct way to act, but im not getting that.</pre>
</blockquote>
<p>No, accept() is not for receiving another message, it's for
receiving another connection on the same Unix domain socket, which
will require another thread to answer. Whether this happens is a
question of whether PowerDNS will open multiple connections to the
same Unix domain socket; this doesn't seem to be documented but it
certainly could. So you need a main (thread/goroutine/green
thread) calling accept() on the socket, which starts a new
(thread/goroutine/green thread) to process each connection, and
each connection can process multiple messages in sequence.<br>
</p>
</body>
</html>