[Pdns-users] remote backend
Brian Candler
b.candler at pobox.com
Wed Nov 29 10:29:27 UTC 2023
On 29/11/2023 10:19, Alexis Fidalgo wrote:
>
> by the responder, what im not understanding is, why in 2 different languages (golang and python) i get the same behavior.
>
Well, you haven't shown the code from either.
>> 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.
> 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)
Note that accept() returns you a *new* fd (socket) representing this
connection.
> . Reads from the socket
...where "the socket" here means the new one returned from accept()
> . Answer to the socket (*)
> . Locks for ever if i dont close it
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.
> 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.
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.powerdns.com/pipermail/pdns-users/attachments/20231129/e2c9f2aa/attachment.htm>
More information about the Pdns-users
mailing list