/** \file sched.c Paraslash's scheduling functions. */
#include <regex.h>
-#include <dirent.h> /* readdir() */
#include <assert.h>
#include <sys/time.h>
list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) {
if (t->pre_select)
t->pre_select(s, t);
-// PARA_INFO_LOG("%s \n", t->status);
- if (t->error >= 0)
- continue;
- /*
- * We have to check whether the list is empty because the call
- * to ->pre_select() might have called sched_shutdown(). In
- * this case t has been unregistered already, so we must not
- * unregister it again.
- */
- if (list_empty(&pre_select_list))
- return;
- unregister_task(t);
+ if (t->error < 0)
+ unregister_task(t);
}
}
struct task *t, *tmp;
list_for_each_entry_safe(t, tmp, &post_select_list, post_select_node) {
- call_post_select(s, t);
+ if (t->error >= 0)
+ call_post_select(s, t);
// PARA_INFO_LOG("%s: %d\n", t->status, t->ret);
if (t->error >= 0)
continue;
- /* nec., see sched_preselect() */
+ /*
+ * We have to check whether the list is empty because the call
+ * to ->post_select() might have called sched_shutdown(). In
+ * this case t has been unregistered already, so we must not
+ * unregister it again.
+ */
if (list_empty(&post_select_list))
return;
unregister_task(t);
* Unregister all tasks.
*
* This will cause \a schedule() to return immediately because both the
- * \a pre_select_list and the \a post_select_list are empty.
+ * \a pre_select_list and the \a post_select_list are empty. This function
+ * must be called from the post_select (rather than the pre_select) method.
*/
void sched_shutdown(void)
{
*/
void sched_min_delay(struct sched *s)
{
- s->select_timeout.tv_sec = 0;
- s->select_timeout.tv_usec = 1;
+ s->select_timeout.tv_sec = s->select_timeout.tv_usec = 0;
}
/**