summaryrefslogtreecommitdiffstats
path: root/lib/thread.h
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2017-06-09 05:40:27 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2017-06-16 21:56:58 +0200
commit8797240ea4de5163f8633c1c561edbfd8ecf1c2a (patch)
treee9385194d4e449149400bce366055ee243d3e3bf /lib/thread.h
parentlib: add mt-safe thread_cancel (diff)
downloadfrr-8797240ea4de5163f8633c1c561edbfd8ecf1c2a.tar.xz
frr-8797240ea4de5163f8633c1c561edbfd8ecf1c2a.zip
lib: mt-safe cancel, round deux
* Update pollfds copy as well as the original * Keep array count for copy in thread_master * Remove last remnants of POLLHUP in .events field * Remove unused snmpcount (lolwut) * Improve docs * Add missing do_thread_cancel() call in thread_cancel_event() * Change thread_fetch() to always enter poll() to avoid starving i/o * Remember to free up cancel_req when destroying thread_master * Fix dereference of null pointer * Fix dead store to timeval * Fix missing condition for condition variable :-) Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/thread.h')
-rw-r--r--lib/thread.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/thread.h b/lib/thread.h
index d49d325f7..e48068b17 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -47,16 +47,19 @@ struct pqueue;
struct fd_handler
{
- /* number of pfd stored in pfds */
- nfds_t pfdcount;
- /* number of pfd stored in pfds + number of snmp pfd */
- nfds_t pfdcountsnmp;
- /* number of pfd that fit in the allocated space of pfds */
+ /* number of pfd that fit in the allocated space of pfds. This is a constant
+ * and is the same for both pfds and copy. */
nfds_t pfdsize;
+
/* file descriptors to monitor for i/o */
struct pollfd *pfds;
+ /* number of pollfds stored in pfds */
+ nfds_t pfdcount;
+
/* chunk used for temp copy of pollfds */
struct pollfd *copy;
+ /* number of pollfds stored in copy */
+ nfds_t copycount;
};
struct cancel_req {
@@ -75,6 +78,7 @@ struct thread_master
struct thread_list ready;
struct thread_list unuse;
struct list *cancel_req;
+ bool canceled;
pthread_cond_t cancel_cond;
int io_pipe[2];
int fd_limit;