]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/thread.h
Merge pull request #11076 from routingrocks/vrrp_master_ad_cli
[mirror_frr.git] / lib / thread.h
index c5f0ffbf773daeded9195195091c4ec3236a7f72..a2049ae52a38e2747af26a6bed487204c045aeaa 100644 (file)
@@ -114,7 +114,7 @@ struct thread {
        struct thread_timer_list_item timeritem;
        struct thread **ref;      /* external reference (if given) */
        struct thread_master *master; /* pointer to the struct thread_master */
-       int (*func)(struct thread *); /* event function */
+       void (*func)(struct thread *); /* event function */
        void *arg;                    /* event argument */
        union {
                int val;              /* second argument of the event. */
@@ -126,12 +126,18 @@ struct thread {
        unsigned long yield;             /* yield time in microseconds */
        const struct xref_threadsched *xref;   /* origin location */
        pthread_mutex_t mtx;   /* mutex for thread.c functions */
+       bool ignore_timer_late;
 };
 
+#ifdef _FRR_ATTRIBUTE_PRINTFRR
+#pragma FRR printfrr_ext "%pTH" (struct thread *)
+#endif
+
 struct cpu_thread_history {
-       int (*func)(struct thread *);
+       void (*func)(struct thread *);
        atomic_size_t total_cpu_warn;
        atomic_size_t total_wall_warn;
+       atomic_size_t total_starv_warn;
        atomic_size_t total_calls;
        atomic_size_t total_active;
        struct time_stats {
@@ -219,30 +225,34 @@ void thread_master_set_name(struct thread_master *master, const char *name);
 extern void thread_master_free(struct thread_master *);
 extern void thread_master_free_unused(struct thread_master *);
 
-extern struct thread *_thread_add_read_write(
-       const struct xref_threadsched *xref, struct thread_master *master,
-       int (*fn)(struct thread *), void *arg, int fd, struct thread **tref);
+extern void _thread_add_read_write(const struct xref_threadsched *xref,
+                                  struct thread_master *master,
+                                  void (*fn)(struct thread *), void *arg,
+                                  int fd, struct thread **tref);
 
-extern struct thread *_thread_add_timer(
-       const struct xref_threadsched *xref, struct thread_master *master,
-       int (*fn)(struct thread *), void *arg, long t, struct thread **tref);
+extern void _thread_add_timer(const struct xref_threadsched *xref,
+                             struct thread_master *master,
+                             void (*fn)(struct thread *), void *arg, long t,
+                             struct thread **tref);
 
-extern struct thread *_thread_add_timer_msec(
-       const struct xref_threadsched *xref, struct thread_master *master,
-       int (*fn)(struct thread *), void *arg, long t, struct thread **tref);
+extern void _thread_add_timer_msec(const struct xref_threadsched *xref,
+                                  struct thread_master *master,
+                                  void (*fn)(struct thread *), void *arg,
+                                  long t, struct thread **tref);
 
-extern struct thread *_thread_add_timer_tv(
-       const struct xref_threadsched *xref, struct thread_master *master,
-       int (*fn)(struct thread *), void *arg, struct timeval *tv,
-       struct thread **tref);
+extern void _thread_add_timer_tv(const struct xref_threadsched *xref,
+                                struct thread_master *master,
+                                void (*fn)(struct thread *), void *arg,
+                                struct timeval *tv, struct thread **tref);
 
-extern struct thread *_thread_add_event(
-       const struct xref_threadsched *xref, struct thread_master *master,
-       int (*fn)(struct thread *), void *arg, int val, struct thread **tref);
+extern void _thread_add_event(const struct xref_threadsched *xref,
+                             struct thread_master *master,
+                             void (*fn)(struct thread *), void *arg, int val,
+                             struct thread **tref);
 
 extern void _thread_execute(const struct xref_threadsched *xref,
                            struct thread_master *master,
-                           int (*fn)(struct thread *), void *arg, int val);
+                           void (*fn)(struct thread *), void *arg, int val);
 
 extern void thread_cancel(struct thread **event);
 extern void thread_cancel_async(struct thread_master *, struct thread **,
@@ -277,6 +287,11 @@ extern bool thread_is_scheduled(struct thread *thread);
 /* Debug signal mask */
 void debug_signals(const sigset_t *sigs);
 
+static inline void thread_ignore_late_timer(struct thread *thread)
+{
+       thread->ignore_timer_late = true;
+}
+
 #ifdef __cplusplus
 }
 #endif