mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 11:40:11 +03:00
Hub before clay/ze refactor.
This commit is contained in:
parent
3e0fe1bd0e
commit
fdf68275ed
@ -170,6 +170,7 @@
|
||||
typedef struct _u2_save {
|
||||
uv_timer_t tim_u; // checkpoint timer
|
||||
c3_w ent_w; // event number, XX 64
|
||||
c3_w pid_w; // pid of checkpoint process
|
||||
} u2_save;
|
||||
|
||||
/* u2_ubuf: unix tty i/o buffer.
|
||||
@ -821,6 +822,11 @@
|
||||
|
||||
/** Autosave.
|
||||
**/
|
||||
/* u2_save_ef_chld(): report SIGCHLD.
|
||||
*/
|
||||
void
|
||||
u2_save_ef_chld(void);
|
||||
|
||||
/* u2_save_io_init(): initialize autosave.
|
||||
*/
|
||||
void
|
||||
|
40
v/save.c
40
v/save.c
@ -24,15 +24,51 @@ _save_time_cb(uv_timer_t* tim_u, c3_i sas_i)
|
||||
{
|
||||
u2_save* sav_u = &u2_Host.sav_u;
|
||||
|
||||
if ( sav_u->pid_w ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( u2A->ent_w > sav_u->ent_w ) {
|
||||
c3_w pid_w;
|
||||
|
||||
// uL(fprintf(uH, "autosaving... ent_w %d\n", u2A->ent_w));
|
||||
|
||||
u2_cm_purge();
|
||||
// u2_ve_grab(0);
|
||||
|
||||
#ifdef FORKPT
|
||||
if ( 0 == (pid_w = fork()) ) {
|
||||
u2_loom_save(u2A->ent_w);
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
uL(fprintf(uH, "checkpoint: process %d\n", pid_w));
|
||||
|
||||
sav_u->ent_w = u2A->ent_w;
|
||||
sav_u->pid_w = pid_w;
|
||||
}
|
||||
#else
|
||||
u2_loom_save(u2A->ent_w);
|
||||
sav_u->ent_w = u2A->ent_w;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/* u2_save_ef_chld(): report save termination.
|
||||
*/
|
||||
void
|
||||
u2_save_ef_chld(void)
|
||||
{
|
||||
u2_save* sav_u = &u2_Host.sav_u;
|
||||
c3_i loc_i;
|
||||
c3_w pid_w;
|
||||
|
||||
c3_assert(0 != sav_u->pid_w);
|
||||
uL(fprintf(uH, "checkpoint: complete %d\n", sav_u->pid_w));
|
||||
pid_w = wait(&loc_i);
|
||||
c3_assert(pid_w == sav_u->pid_w);
|
||||
|
||||
sav_u->pid_w = 0;
|
||||
}
|
||||
|
||||
/* u2_save_io_init(): initialize autosave.
|
||||
@ -43,6 +79,8 @@ u2_save_io_init(void)
|
||||
u2_save* sav_u = &u2_Host.sav_u;
|
||||
|
||||
sav_u->ent_w = 0;
|
||||
sav_u->pid_w = 0;
|
||||
|
||||
uv_timer_init(u2L, &sav_u->tim_u);
|
||||
uv_timer_start(&sav_u->tim_u, _save_time_cb, 5000, 5000);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user