[Asterisk-Dev] Anything wrong with sleep()ing in pbx_spool.c

Jared Mauch jared at puck.Nether.net
Mon Oct 6 15:24:53 MST 2003


On Mon, Oct 06, 2003 at 05:11:08PM -0500, James Sharp wrote:
> I added some hacks into pbx_spool.c so I could read a "delay" value from
> the call spool file.  I currently sleep() for that number of seconds
> before placing the outgoing call.  Is this going to affect anything other
> than it might bottleneck the outgoing spool if there's lots of queued up
> calls in it?

	You really want to use select instead.

	eg:

-- snip --
struct timeval tv;

tv.tv_sec = 2;
tv.tv_usec = 0;
select (1, NULL, NULL, NULL, &tv);
-- snip --

	This will do the same as sleep(2) but in such a way that
you could pass it a fd_set and have it "wake up" if there were activity
on one of the file descriptors (or sockets).

	- Jared

-- 
Jared Mauch  | pgp key available via finger from jared at puck.nether.net
clue++;      | http://puck.nether.net/~jared/  My statements are only mine.



More information about the asterisk-dev mailing list