More thoughts on threads...

Hal Murray hmurray at megapathdsl.net
Thu Dec 17 04:21:55 UTC 2020


I'm still scheming on this topic.

Here is what I'd like to end up with:
  N server threads, each with their own socket listening on UDP 123
  a client thread for each server we are using (with own socket)
  a thread for each refclock
  the main thread for whatever is left

Getting there is a lot of work, but I think the code will be a lot cleaner and 
easier to understand.  The big select and the dispatching logic goes away.  
The DNS thread and the dance to get to it and back goes away...

But maybe I'm fooling myself.  Are people comfortable with threads and locks?  
(I've been working with them since 1976.)

The client threads will have their own socket so the NTP replies don't go to 
port 123.

I'd like to move the mode6/ntpq server to a separate port so the only traffic 
the server threads see is NTP requests.  For now, it's a few lines of code to 
split that out.

My short term plan is to change the current code to listen on port 8123 (or 
whatever) so I can add server threads using port 123.  That will break ntpq.  
I can hack it to use 8123.  ...  I think I can do what with a configure option.

Mumble.  Feedback encouraged.




-- 
These are my opinions.  I hate spam.





More information about the devel mailing list