]> git.puffer.fish Git - matthieu/frr.git/commit
lib: allow nonblocking thread_fetch()
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 28 Apr 2017 22:45:59 +0000 (22:45 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Sun, 30 Apr 2017 23:06:14 +0000 (23:06 +0000)
commit705f21797e348a02660a638b6d1b2751ef37372e
tree181a9b3d635fb4df4eb7b2a79542a47213089721
parent98f14af8bf8340115049e0df4888b6acc8701ea5
lib: allow nonblocking thread_fetch()

This change adds three fields to thread_master and associated code to
use them. The fields are:

 * long selectpoll_timeout

This is a millisecond value that, if nonzero, will override the
internally calculated timeout for select()/poll(). -1 indicates
nonblocking while a positive value indicates the desired timeout in
milliseconds.

 * bool spin

This indicates whether a call to thread_fetch() should result in a loop
until work is available. By default this is set to true, in order to
keep the default behavior. In this case a return value of NULL indicates
that a fatal signal was received in select() or poll(). If it is set to
false, thread_fetch() will return immediately. NULL is then an
acceptable return value if there is no work to be done.

 * bool handle_signals

This indicates whether or not the pthread that owns the thread master
is responsible for handling signals (since this is an MT-unsafe
operation, it is best to have just the root thread do it). It is set to
true by default. Non-root pthreads should set this to false.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/thread.c
lib/thread.h