[MEDIUM] minor update to the task api: let the scheduler queue itself
All the tasks callbacks had to requeue the task themselves, and update
a global timeout. This was not convenient at all. Now the API has been
simplified. The tasks callbacks only have to update their expire timer,
and return either a pointer to the task or NULL if the task has been
deleted. The scheduler will take care of requeuing the task at the
proper place in the wait queue.
diff --git a/include/common/appsession.h b/include/common/appsession.h
index 616766f..6c12926 100644
--- a/include/common/appsession.h
+++ b/include/common/appsession.h
@@ -38,7 +38,7 @@
/* Callback for destroy */
void destroy(appsess *data);
-void appsession_refresh(struct task *t, int *next);
+struct task *appsession_refresh(struct task *t);
int appsession_task_init(void);
int appsession_init(void);
void appsession_cleanup(void);
diff --git a/include/proto/checks.h b/include/proto/checks.h
index 8499175..6f0aa8b 100644
--- a/include/proto/checks.h
+++ b/include/proto/checks.h
@@ -2,7 +2,7 @@
include/proto/checks.h
Functions prototypes for the checks.
- Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
+ Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@
#include <types/task.h>
#include <common/config.h>
-void process_chk(struct task *t, struct timeval *next);
+struct task *process_chk(struct task *t);
int start_checks();
#endif /* _PROTO_CHECKS_H */
diff --git a/include/proto/proto_uxst.h b/include/proto/proto_uxst.h
index e770942..bf487b6 100644
--- a/include/proto/proto_uxst.h
+++ b/include/proto/proto_uxst.h
@@ -28,8 +28,7 @@
int uxst_event_accept(int fd);
void uxst_add_listener(struct listener *listener);
-void process_uxst_stats(struct task *t, int *next);
-void uxst_process_session(struct task *t, int *next);
+struct task *uxst_process_session(struct task *t);
#endif /* _PROTO_PROTO_UXST_H */
diff --git a/include/proto/session.h b/include/proto/session.h
index ad0a57e..7cc50f6 100644
--- a/include/proto/session.h
+++ b/include/proto/session.h
@@ -36,7 +36,7 @@
void session_process_counters(struct session *s);
void sess_change_server(struct session *sess, struct server *newsrv);
-void process_session(struct task *t, int *next);
+struct task *process_session(struct task *t);
static void inline trace_term(struct session *s, unsigned int code)
{
diff --git a/include/types/protocols.h b/include/types/protocols.h
index 5c3b608..e91fdb3 100644
--- a/include/types/protocols.h
+++ b/include/types/protocols.h
@@ -85,7 +85,7 @@
struct listener *next; /* next address for the same proxy, or NULL */
struct list proto_list; /* list in the protocol header */
int (*accept)(int fd); /* accept() function passed to fdtab[] */
- void (*handler)(struct task *t, int *next); /* protocol handler */
+ struct task * (*handler)(struct task *t); /* protocol handler. It is a task */
int *timeout; /* pointer to client-side timeout */
void *private; /* any private data which may be used by accept() */
unsigned int analysers; /* bitmap of required protocol analysers */
diff --git a/include/types/task.h b/include/types/task.h
index 4302ec0..1cc12a9 100644
--- a/include/types/task.h
+++ b/include/types/task.h
@@ -50,11 +50,18 @@
struct eb32_node rq; /* ebtree node used to hold the task in the run queue */
int state; /* task state : bit field of TASK_* */
unsigned int expire; /* next expiration time for this task */
- void (*process)(struct task *t, int *next); /* the function which processes the task */
+ struct task * (*process)(struct task *t); /* the function which processes the task */
void *context; /* the task's context */
int nice; /* the task's current nice value from -1024 to +1024 */
};
+/*
+ * The task callback (->process) is responsible for updating ->expire. It must
+ * return a pointer to the task itself, except if the task has been deleted, in
+ * which case it returns NULL so that the scheduler knows it must not check the
+ * expire timer. The scheduler will requeue the task at the proper location.
+ */
+
#endif /* _TYPES_TASK_H */
/*