AllStarLink / app_rpt

Refactoring and upgrade of AllStarLink's app_rpt, etc.
8 stars 6 forks source link

chan_simpleusb: Replace time() with clock_gettime() #344

Closed jxmx closed 2 months ago

jxmx commented 3 months ago

Based on https://github.com/AllStarLink/ASL3/issues/76, the boot-time clock skew seems to cause chan_simpleusb to lock the PTT open until a restart of asterisk. Delaying asterisk start on boot until NTP has synchronized seems to resolve the issue but that is not a reliable fix. Within the code, comparisons are being made using time(2) when the likely resolution is to use clock_gettime(2) with a CLOCK_MONOTONIC type. That way, "wallclock" time changes in the OS don't affect the USB channel driver.

Allan-N commented 3 months ago

My suggestion would be to add an rpt_time() function that behaves like time() but is based off of clock_gettime(). Then search/replace all calls to time() that are used for time comparison with rpt_time().

... and a good place for rpt_time() would be next to rpt_starttime()

Note: in .../asterisk/include/asterisk/time.h you will find ast_tsnow() that calls clock_gettime()

mpannen1979 commented 3 months ago

I have a pi3 and a pi4 with USB interfaces that seem to be affected by this--there is USB HID error messages.

I am trying the 'wait for time sync' change to the asterisk.service file in the meantime