]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/frrcu.h
Merge pull request #10953 from leonshaw/fix/bgp-rm-leak
[mirror_frr.git] / lib / frrcu.h
index 8f789303cc5cdfc43a27378d2f026dd7d1140dc9..ae840926b559c6064e4457c3f7c5d84db31bc5ae 100644 (file)
 #ifndef _FRRCU_H
 #define _FRRCU_H
 
+#include <assert.h>
+
 #include "memory.h"
 #include "atomlist.h"
-#include "seqlock.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /* quick RCU primer:
  *   There's a global sequence counter.  Whenever a thread does a
@@ -113,7 +118,7 @@ struct rcu_action {
 };
 
 /* RCU cleanup function queue item */
-PREDECL_ATOMLIST(rcu_heads)
+PREDECL_ATOMLIST(rcu_heads);
 struct rcu_head {
        struct rcu_heads_item head;
        const struct rcu_action *action;
@@ -139,6 +144,8 @@ extern void rcu_enqueue(struct rcu_head *head, const struct rcu_action *action);
 #define rcu_free(mtype, ptr, field)                                            \
        do {                                                                   \
                typeof(ptr) _ptr = (ptr);                                      \
+               if (!_ptr)                                                     \
+                       break;                                                 \
                struct rcu_head *_rcu_head = &_ptr->field;                     \
                static const struct rcu_action _rcu_action = {                 \
                        .type = RCUA_FREE,                                     \
@@ -169,4 +176,8 @@ extern void rcu_enqueue(struct rcu_head *head, const struct rcu_action *action);
 
 extern void rcu_close(struct rcu_head_close *head, int fd);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FRRCU_H */