]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: task: define two new one-shot events for use with WOKEN_OTHER or MSG
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Sep 2024 16:19:10 +0000 (18:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 27 Sep 2024 09:56:10 +0000 (11:56 +0200)
TASK_WOKEN_MSG only says "someone sent you a message" but doesn't convey
any info about the message. TASK_WOKEN_OTHER says "you're woken for another
reason" but doesn't tell which one. Most often they're used as-is by the
task handlers to report very specific situations.

For some important control notifications, having the ability to modulate
the message a little bit is useful, so let's define two user event types
UEVT1 and UEVT2 to be used in conjunction with TASK_WOKEN_MSG or _OTHER
so that the application can know that a specific condition was explicitly
requested. It will be used this way:

  task_wakeup(s->task, TASK_WOKEN_MSG | TASK_F_UEVT1);
or:
  task_wakeup(s->task, TASK_WOKEN_OTHER | TASK_F_UEVT2);

Since events are cumulative, keep in mind not to consider a 3rd value
as the combination of EVT1+EVT2; these really mean that the two events
appeared (though in unspecified order).

include/haproxy/task-t.h

index b525420f3b072da69f36fd7daa6110b2fa108fbf..a6807a5dd214d8b8406174e86ce2fd6fdd57c3e6 100644 (file)
@@ -47,9 +47,9 @@
 #define TASK_WOKEN_TIMER  0x00000200  /* woken up because of expired timer */
 #define TASK_WOKEN_IO     0x00000400  /* woken up because of completed I/O */
 #define TASK_WOKEN_SIGNAL 0x00000800  /* woken up by a system signal */
-#define TASK_WOKEN_MSG    0x00001000  /* woken up by another task's message */
+#define TASK_WOKEN_MSG    0x00001000  /* woken up by another task's message (see also UEVT/USR1) */
 #define TASK_WOKEN_RES    0x00002000  /* woken up because of available resource */
-#define TASK_WOKEN_OTHER  0x00004000  /* woken up for an unspecified reason */
+#define TASK_WOKEN_OTHER  0x00004000  /* woken up for an unspecified reason (see also UEVT/USR1) */
 
 /* use this to check a task state or to clean it up before queueing */
 #define TASK_WOKEN_ANY    (TASK_WOKEN_OTHER|TASK_WOKEN_INIT|TASK_WOKEN_TIMER| \
@@ -58,7 +58,9 @@
 
 #define TASK_F_TASKLET    0x00008000  /* nature of this task: 0=task 1=tasklet */
 #define TASK_F_USR1       0x00010000  /* preserved user flag 1, application-specific, def:0 */
-/* unused: 0x20000..0x80000000 */
+#define TASK_F_UEVT1      0x00020000  /* one-shot user event type 1, application specific, def:0 */
+#define TASK_F_UEVT2      0x00040000  /* one-shot user event type 2, application specific, def:0 */
+/* unused: 0x80000..0x80000000 */
 
 /* These flags are persistent across scheduler calls */
 #define TASK_PERSISTENT   (TASK_SELF_WAKING | TASK_KILLED | \