2013-09-16 21:57:40 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- I/O and event loop
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
#ifndef _BIRD_SYSDEP_UNIX_IO_LOOP_H_
|
|
|
|
#define _BIRD_SYSDEP_UNIX_IO_LOOP_H_
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-11-30 22:57:14 +00:00
|
|
|
#include "nest/bird.h"
|
|
|
|
|
|
|
|
#include "lib/lists.h"
|
|
|
|
#include "lib/event.h"
|
|
|
|
#include "lib/timer.h"
|
|
|
|
|
|
|
|
struct free_pages
|
|
|
|
{
|
|
|
|
list list; /* List of empty pages */
|
|
|
|
event *cleanup; /* Event to call when number of pages is outside bounds */
|
|
|
|
u16 min, max; /* Minimal and maximal number of free pages kept */
|
|
|
|
uint cnt; /* Number of empty pages */
|
|
|
|
};
|
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
struct birdloop
|
|
|
|
{
|
2021-11-30 17:16:49 +00:00
|
|
|
resource r;
|
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
pool *pool;
|
2021-11-30 17:16:49 +00:00
|
|
|
pool *parent;
|
2013-09-16 21:57:40 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
struct timeloop time;
|
|
|
|
event_list event_list;
|
|
|
|
list sock_list;
|
|
|
|
uint sock_num;
|
2013-09-16 21:57:40 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
BUFFER(sock *) poll_sk;
|
|
|
|
BUFFER(struct pollfd) poll_fd;
|
|
|
|
u8 poll_changed;
|
|
|
|
u8 close_scheduled;
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
_Atomic u32 ping_sent;
|
|
|
|
int wakeup_fds[2];
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
uint links;
|
2013-11-19 21:33:48 +00:00
|
|
|
|
2021-11-30 22:57:14 +00:00
|
|
|
struct free_pages pages;
|
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
void (*stopped)(void *data);
|
|
|
|
void *stop_data;
|
2013-09-16 21:57:40 +00:00
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
struct birdloop *prev_loop;
|
|
|
|
};
|
2013-09-10 10:09:36 +00:00
|
|
|
|
2021-11-30 22:57:14 +00:00
|
|
|
extern _Thread_local struct birdloop *birdloop_current;
|
|
|
|
|
|
|
|
void init_pages(struct birdloop *loop);
|
|
|
|
void flush_pages(struct birdloop *loop);
|
|
|
|
|
2021-06-19 18:50:18 +00:00
|
|
|
#endif
|