[Home]

Summary:ASTERISK-24565: kqueue not working correctly on OSX
Reporter:Morgan Aldridge (morgant)Labels:
Date Opened:2014-11-28 13:19:12.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Core/PBX
Versions:12.7.1 13.18.4 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) asterisk_12.7.0-osx_10.9.5-kqueue_test.txt
Description:kqueue not working correctly on OSX
Comments:By: George Joseph (gjoseph) 2014-11-28 13:22:33.958-0600

Can you add some detail here?

By: Morgan Aldridge (morgant) 2014-12-16 15:56:46.768-0600

On OS X 10.9.5 & 10.10.1 (though the attached file is only from 10.9.5), asterisk 12.7.0 successfully finds kqueue support, builds the the kqueue timing interface, and loads it without error, but running `timing test` gives the following result showing that it is non-functional:

 Attempting to test a timer with 50 ticks per second.
 Using the 'kqueue' timing module for this test.
 Timer failed to acknowledge.
 Command 'timing test ' failed.

Naturally, MoH, message playback, etc., do not function in this state. The pthreads timing interface does function correctly, but kqueue is advised for OS X & BSD.

By: David M. Lee (dlee) 2015-01-12 09:54:58.526-0600

[~morgant] I took a few minutes to look at this. The way res_timing_kqueue is structured, I don't think it will ever pass the timing test. In fact, the only reason why it passes its own unit test on OS X is b/c a section of the test is {{#if 0}}'ed out.

By: David M. Lee (dlee) 2015-01-12 10:08:42.321-0600

[~morgant] In r271657 (which was June 2010), there was an attempt to disable kqueue on OS X with the comment:

bq. Conflict kqueue on OS X, since it doesn't work there yet, anyway.

Given that comment, and the lack of commits that attempt to fix res_timing_kqueue, I'd say that it's been broken on OS X for a really long time. Getting this module in shape will require someone who actually knows how kqueue is supposed to work. The code that's there doesn't look anything like the kqueue timing examples that I've seen, and I can't find any timing examples that work with poll the way the timing API works.

By: David M. Lee (dlee) 2015-01-13 20:59:01.544-0600

I've updated my [patch to fixup Asterisk 13|https://reviewboard.asterisk.org/r/4327/] on OS X to "fix the glitch" and properly inhibit res_timing_kqueue from being selectable on OS X.

Feedback welcome.

https://reviewboard.asterisk.org/r/4327/

By: Richard Mudgett (rmudgett) 2016-02-16 10:42:37.367-0600

The patch [~dlee] put up on reviewboard was committed over a year ago.  Did it take care of this issue?

See git commit 702d79de2a2341954ef599f4c5a4c5f31c1b5edc

By: David M. Lee (dlee) 2016-02-16 11:27:26.574-0600

My patch prohibits kqueue from being selectable on OS X, but doesn't fix any of the problems in kqueue. So, technically, kqueue is still broken on OS X. And it wouldn't surprise me if it was broken on all BSDs, given the state of the code. But now we have checks in place preventing you from enabling the broken kqueue support on OS X.

I would be fine closing this as a won't fix, until someone who cares enough about kqueue comes along and cleans up the module. The default res_timing module, while not great, is Good Enoughâ„¢ for what most people use Asterisk on OS X for.

By: Morgan Aldridge (morgant) 2016-02-16 15:46:16.344-0600

Naturally, we would like to see better performing timing support on OS X and kqueue seems to be the way to do that. I'll have to do some testing, but is there any chance that the fix for ASTERISK-24857 will have cleaned up that code?

By: David M. Lee (dlee) 2016-02-16 17:02:36.421-0600

Great catch. It seems that my statement about kqueue being broken is quite a bit dated. I totally missed that patch giving it some much needed TLC.

If kqueue supports is working well on a BSD, then it's probably a small patch away from working on OS X. If we're really lucky, maybe it's just removing the {{<conflict>launchd</conflict>}} line from res_timing_kqueue.

[~morgant]: let us know how the testing goes, and maybe we can close this issue as fixed :-)

By: Morgan Aldridge (morgant) 2016-04-14 12:36:03.088-0500

Okay, I have built asterisk 13.8.0 on OS X 10.11.4 and res_timing_kqueue (by removing the {{<conflict>launchd</conflict>}} lines from res/.res_timing_kqueue.moduleinfo & res/res_timing_kqueue.c... think it was just in a comment in the latter, IIRC) and my initial tests show it as functional.

Running {{timing test}} works, but seems to be missing 1-3 ticks (it always misses at least one), while it consistently takes 1000 milliseconds. In comparison, res_timing_pthread never misses a tick but rarely takes 1000 milliseconds (usually sometime between 1003-1009 milliseconds). Naturally, I still have more testing to do.