rec_io_del(struct main_rec_io *rio)
{
timer_del(&rio->timer);
- if (clist_is_linked(&rio->start_read_hook.n))
+ if (hook_is_active(&rio->start_read_hook))
hook_del(&rio->start_read_hook);
file_del(&rio->file);
* of the work to a main_hook, which will be called in the next iteration
* of the main loop.
*/
- if (!clist_is_linked(&rio->start_read_hook.n))
+ if (!hook_is_active(&rio->start_read_hook))
{
DBG("RIO: Scheduling start of reading");
hook_add(&rio->start_read_hook);
}
else
{
- if (clist_is_linked(&rio->start_read_hook.n))
+ if (hook_is_active(&rio->start_read_hook))
{
DBG("RIO: Descheduling start of reading");
hook_del(&rio->start_read_hook);
void
rec_io_start_read(struct main_rec_io *rio)
{
- ASSERT(clist_is_linked(&rio->file.n));
+ ASSERT(rec_io_is_active(rio));
rio->read_started = 1;
rec_io_recalc_read(rio);
}
void
rec_io_stop_read(struct main_rec_io *rio)
{
- ASSERT(clist_is_linked(&rio->file.n));
+ ASSERT(rec_io_is_active(rio));
rio->read_started = 0;
rec_io_recalc_read(rio);
}
rec_io_write(struct main_rec_io *rio, void *data, uns len)
{
byte *bdata = data;
- ASSERT(clist_is_linked(&rio->file.n));
+ ASSERT(rec_io_is_active(rio));
if (!len)
return;
main_loop();
msg(L_INFO, "Finished.");
- if (clist_is_linked(&rio.file.n))
+ if (file_is_active(&rio.file))
rec_io_del(&rio);
main_cleanup();
return 0;
struct main_context *m = main_current();
DBG("MAIN: Adding file %p (fd=%d)", fi, fi->fd);
- ASSERT(!clist_is_linked(&fi->n));
+ ASSERT(!file_is_active(fi));
clist_add_tail(&m->file_list, &fi->n);
m->file_cnt++;
#ifdef CONFIG_UCW_EPOLL
// XXX: Can be called on a non-current context
DBG("MAIN: Deleting file %p (fd=%d)", fi, fi->fd);
- ASSERT(clist_is_linked(&fi->n));
+ ASSERT(file_is_active(fi));
clist_unlink(&fi->n);
m->file_cnt--;
#ifdef CONFIG_UCW_EPOLL
struct main_context *m = main_current();
DBG("MAIN: Adding hook %p", ho);
- ASSERT(!clist_is_linked(&ho->n));
+ ASSERT(!hook_is_active(ho));
clist_add_tail(&m->hook_list, &ho->n);
}
hook_del(struct main_hook *ho)
{
DBG("MAIN: Deleting hook %p", ho);
- ASSERT(clist_is_linked(&ho->n));
+ ASSERT(hook_is_active(ho));
clist_unlink(&ho->n);
}
struct main_context *m = main_current();
DBG("MAIN: Adding process %p (pid=%d)", mp, mp->pid);
- ASSERT(!clist_is_linked(&mp->n));
+ ASSERT(!process_is_active(mp));
ASSERT(mp->handler);
clist_add_tail(&m->process_list, &mp->n);
if (!m->sigchld_handler)
process_del(struct main_process *mp)
{
DBG("MAIN: Deleting process %p (pid=%d)", mp, mp->pid);
- ASSERT(clist_is_linked(&mp->n));
+ ASSERT(process_is_active(mp));
clist_unlink(&mp->n);
}
DBG("MAIN: Adding signal %p (sig=%d)", ms, ms->signum);
- ASSERT(!clist_is_linked(&ms->n));
+ ASSERT(!signal_is_active(ms));
// Adding at the head of the list is better if we are in the middle of walking the list.
clist_add_head(&m->signal_list, &ms->n);
if (m->sig_pipe_recv < 0)
// XXX: Can be called on a non-current context
DBG("MAIN: Deleting signal %p (sig=%d)", ms, ms->signum);
- ASSERT(clist_is_linked(&ms->n));
+ ASSERT(signal_is_active(ms));
clist_unlink(&ms->n);
int another = 0;
**/
void timer_del(struct main_timer *tm);
+/** Tells whether a timer is running. **/
+static inline int timer_is_active(struct main_timer *tm)
+{
+ return !!tm->expires;
+}
+
/**
* Forces refresh of the current timestamp cached in the active context.
* You usually do not need to call this, since it is called every time the
**/
void hook_del(struct main_hook *ho);
+/** Tells if a hook is active (i.e., added). **/
+static inline int hook_is_active(struct main_hook *ho)
+{
+ return clist_is_linked(&ho->n);
+}
+
/** Show current state of a hook. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
void hook_debug(struct main_hook *ho);
**/
void file_del(struct main_file *fi);
+/** Tells if a file is active (i.e., added). **/
+static inline int file_is_active(struct main_file *fi)
+{
+ return clist_is_linked(&fi->n);
+}
+
/** Show current state of a file. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
void file_debug(struct main_file *fi);
**/
void block_io_set_timeout(struct main_block_io *bio, timestamp_t expires_delta);
+/** Tells if a @bio is active (i.e., added). **/
+static inline int block_io_is_active(struct main_block_io *bio)
+{
+ return file_is_active(&bio->file);
+}
+
/***
* [[recordio]]
* Asynchronous record I/O
RIO_EVENT_EOF = 3, /* Read: EOF seen */
};
+/** Tells if a @rio is active (i.e., added). **/
+static inline int rec_io_is_active(struct main_rec_io *rio)
+{
+ return file_is_active(&rio->file);
+}
+
/***
* [[process]]
* Child processes
**/
int process_fork(struct main_process *mp);
+/** Tells if a process is active (i.e., added). **/
+static inline int process_is_active(struct main_process *mp)
+{
+ return clist_is_linked(&mp->n);
+}
+
/** Show current state of a process. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
void process_debug(struct main_process *pr);
/** Cancel a request for signal catching. **/
void signal_del(struct main_signal *ms);
+/** Tells if a signal catcher is active (i.e., added). **/
+static inline int signal_is_active(struct main_signal *ms)
+{
+ return clist_is_linked(&ms->n);
+}
+
/** Show current state of a signal catcher. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
void signal_debug(struct main_signal *sg);