[Openvpn-devel,v2] schedule: Rework documentation for schedule_add_entry

Message ID 20251215144656.17299-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v2] schedule: Rework documentation for schedule_add_entry | expand

Commit Message

Gert Doering Dec. 15, 2025, 2:46 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

The previous documentation was very misleading and made
it hard to understand how the sigma parameter is used.

Rewrite it so that it better reflects the actual
implementation.

Change-Id: Idd79f7cbd38e8b0831f15866339c3677a367cd49
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1439
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1439
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering Dec. 15, 2025, 3:31 p.m. UTC | #1
"Just documentation", but to +2 that I had to actually read into all these
macros... "yep, this sounds easier to understand and factually correct" :-)

Nothing to test here, comment only (and BB confirms that nothing sneaked
in that could break a compile).

Your patch has been applied to the master branch.

commit 223192a092eacda12ee1ac93fd017bd43fb60f01
Author: Frank Lichtenheld
Date:   Mon Dec 15 15:46:50 2025 +0100

     schedule: Rework documentation for schedule_add_entry

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1439
     Message-Id: <20251215144656.17299-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35070.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/schedule.h b/src/openvpn/schedule.h
index 79311c5..3e2a2ad 100644
--- a/src/openvpn/schedule.h
+++ b/src/openvpn/schedule.h
@@ -81,17 +81,26 @@ 
 
 /* Public inline functions */
 
-/*
- * Add a struct schedule_entry (whose storage is managed by
- * caller) to the btree.  tv signifies the wakeup time for
- * a future event.  sigma is a time interval measured
- * in microseconds -- the event window being represented
- * starts at (tv - sigma) and ends at (tv + sigma).
- * Event signaling can occur anywere within this interval.
- * Making the interval larger makes the scheduler more efficient,
- * while making it smaller results in more precise scheduling.
- * The caller should treat the passed struct schedule_entry as
- * an opaque object.
+/**
+ * Add a struct schedule_entry to the scheduler btree or
+ * update an existing entry with a new wakeup time.
+ *
+ * @p sigma is only used when the entry is already present
+ * in the schedule. If the originally scheduled time and the new
+ * time are within @p sigma microseconds of each other then the
+ * entry is not rescheduled and will occur at the original time.
+ * When adding a new entry @p sigma will be ignored.
+ *
+ * @param s     scheduler tree
+ * @param e     entry to add to the schedule
+ * @param tv    wakeup time for the entry
+ * @param sigma window size for the event in microseconds
+ *
+ * @note The caller should treat @p e as opaque data. Only
+ * the scheduler functions should change the object. The
+ * caller is expected to manage the memory for the object
+ * and must only free it once it has been removed from the
+ * schedule.
  */
 static inline void
 schedule_add_entry(struct schedule *s, struct schedule_entry *e, const struct timeval *tv,