ntpsec | Converted stat_count struct to a module level global. (!1026)

Hal Murray hmurray at megapathdsl.net
Wed Aug 28 19:56:33 UTC 2019


Thanks.

Ahh...  Part of the problem is that I misread the diffs.  I didn't notice that 
the additions were procedures.  I thought it was restoring the individual 
counters.


ianbruene at gmail.com said:
> It is reducing unnecessary globals because globals are a good thing to
> reduce.

In general, I agree that reducing globals is a good idea.  It's not globals 
that are evil, it's the complexity they normally introduce.

It's not clear that replacing a global with a procedure to read it reduces 
that complexity when the counter is a simple counter.


> !1026 moves the variables from a struct defined globally for the entire
> program to a struct defined globally within a single module  (ntp_proto.c).
> Most usage of those fields is in that module, and almost  all of the
> exceptions are reads in ntp_control. Now all access from  outside of
> ntp_proto is done via functions. 

If I was trying to clean up this area, I think the important step would be to 
move the API for those counters out of ntpd.h into a new header file.  
(Mostly, that's reducing clutter in ntpd.h.  I may be more sensitive to 
clutter than other people.)

Are counters an important enough concept that they deserve special treatement?

------

This discussion reminds me that the counters for DNS and NTS can be bumped by 
various threads so they need a lock.



-- 
These are my opinions.  I hate spam.





More information about the devel mailing list