mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-25 07:52:59 +03:00
Rejigger the event loop again
This commit is contained in:
parent
3f7e6d5e94
commit
d045f31f23
@ -788,15 +788,15 @@
|
||||
|
||||
/** Main loop, new style.
|
||||
**/
|
||||
/* u2_lo_boot(): restore or create pier.
|
||||
*/
|
||||
void
|
||||
u2_lo_boot(void);
|
||||
|
||||
/* u2_lo_loop(): enter main event loop.
|
||||
*/
|
||||
void
|
||||
u2_lo_loop(u2_reck* rec_u);
|
||||
u2_lo_loop(void);
|
||||
|
||||
/* u2_lo_lead(): actions on promotion to leader.
|
||||
*/
|
||||
void
|
||||
u2_lo_lead(u2_reck* rec_u);
|
||||
|
||||
/* u2_lo_exit(): shut down io across pier.
|
||||
*/
|
||||
@ -1083,10 +1083,10 @@
|
||||
u2_bean
|
||||
u2_raft_readopt(u2_ropt* rop_u, const c3_c* arg_c);
|
||||
|
||||
/* u2_raft_io_init(): initialize raft I/O.
|
||||
/* u2_raft_init(): start Raft process.
|
||||
*/
|
||||
void
|
||||
u2_raft_io_init(void);
|
||||
u2_raft_init(void);
|
||||
|
||||
/* u2_raft_work(): poke, kick, and push pending events.
|
||||
*/
|
||||
|
15
v/loop.c
15
v/loop.c
@ -164,7 +164,6 @@ _lo_init()
|
||||
u2_term_io_init();
|
||||
u2_http_io_init();
|
||||
u2_save_io_init();
|
||||
u2_raft_io_init();
|
||||
u2_batz_io_init();
|
||||
}
|
||||
|
||||
@ -630,10 +629,10 @@ _lo_slow()
|
||||
#endif
|
||||
}
|
||||
|
||||
/* u2_lo_boot(): restore or create pier.
|
||||
/* u2_lo_boot(): begin main event loop.
|
||||
*/
|
||||
void
|
||||
u2_lo_boot()
|
||||
u2_lo_loop()
|
||||
{
|
||||
uv_loop_t* lup_u = uv_default_loop();
|
||||
|
||||
@ -643,13 +642,17 @@ u2_lo_boot()
|
||||
// signal(SIGIO, SIG_IGN); // linux is wont to produce for some reason
|
||||
|
||||
_lo_init();
|
||||
u2_sist_boot();
|
||||
u2_raft_init();
|
||||
|
||||
if ( u2_no == u2_Host.ops_u.bat ) {
|
||||
uv_run(u2L, UV_RUN_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
/* u2_lo_loop(): begin main event loop.
|
||||
/* u2_lo_lead(): actions on promotion to leader.
|
||||
*/
|
||||
void
|
||||
u2_lo_loop(u2_reck* rec_u)
|
||||
u2_lo_lead(u2_reck* rec_u)
|
||||
{
|
||||
_lo_talk();
|
||||
{
|
||||
|
5
v/main.c
5
v/main.c
@ -410,10 +410,7 @@ main(c3_i argc,
|
||||
|
||||
u2_lo_grab("main", u2_none);
|
||||
|
||||
u2_lo_boot();
|
||||
u2_lo_loop();
|
||||
|
||||
if ( u2_no == u2_Host.ops_u.bat ) {
|
||||
u2_lo_loop(u2_Host.arv_u);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
20
v/raft.c
20
v/raft.c
@ -85,6 +85,19 @@ _raft_election_rand()
|
||||
return ((float) rand() / RAND_MAX) * 150;
|
||||
}
|
||||
|
||||
/* _raft_promote(): actions on raft leader election.
|
||||
*/
|
||||
static void
|
||||
_raft_promote(u2_raft* raf_u)
|
||||
{
|
||||
raf_u->typ_e = u2_raty_lead;
|
||||
|
||||
u2_sist_boot();
|
||||
if ( u2_no == u2_Host.ops_u.bat ) {
|
||||
u2_lo_lead(u2A);
|
||||
}
|
||||
}
|
||||
|
||||
/* _raft_do_rest(): act on an incoming raft RPC request.
|
||||
*/
|
||||
static void
|
||||
@ -545,13 +558,13 @@ _raft_lone_init(u2_raft* raf_u)
|
||||
{
|
||||
uL(fprintf(uH, "raft: single-instance mode\n"));
|
||||
|
||||
raf_u->typ_e = u2_raty_lead;
|
||||
_raft_promote(raf_u);
|
||||
}
|
||||
|
||||
/* u2_raft_io_init(): begin raft I/O.
|
||||
/* u2_raft_init(): start Raft process.
|
||||
*/
|
||||
void
|
||||
u2_raft_io_init()
|
||||
u2_raft_init()
|
||||
{
|
||||
u2_raft* raf_u = u2R;
|
||||
|
||||
@ -782,7 +795,6 @@ void
|
||||
u2_raft_work(u2_reck* rec_u)
|
||||
{
|
||||
if ( u2R->typ_e != u2_raty_lead ) {
|
||||
uL(fprintf(uH, "raft: working while not leader?!\n"));
|
||||
c3_assert(rec_u->ova.egg_u == 0);
|
||||
if ( u2_nul != rec_u->roe ) {
|
||||
uL(fprintf(uH, "raft: dropping roe!!\n"));
|
||||
|
Loading…
Reference in New Issue
Block a user