From dd0104dbce6e943997c4f039f13a2b8f8d4ec0a0 Mon Sep 17 00:00:00 2001 From: ~hatteb-mitlyd Date: Sat, 31 May 2014 20:26:18 -0700 Subject: [PATCH] Add basic synclog code to try and track sync issues --- include/v/vere.h | 9 +++++++++ v/unix.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/v/vere.h b/include/v/vere.h index 200454cfa3..e5135886af 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -354,6 +354,15 @@ u2_bean alm; // alarm u2_uhot* hot_u; // host state u2_usig* sig_u; // signal list +#ifdef SYNCLOG + c3_w lot_w; // sync-slot + struct _u2_sylo { + u2_bean unx; // from unix + c3_m wer_m; // mote saying where + c3_m wot_m; // mote saying what + c3_c* pax_c; // path + } sylo[1024]; +#endif } u2_unix; /* u2_batz: just a timer for now diff --git a/v/unix.c b/v/unix.c index c046b06550..82e036873c 100644 --- a/v/unix.c +++ b/v/unix.c @@ -183,6 +183,16 @@ _unix_fs_event_cb(uv_fs_event_t* was_u, { u2_unod* nod_u = (void*)was_u; +#ifdef SYNCLOG + c3_w slot = u2_Host.unx_u.lot_w++ % 1024; + free(u2_Host.unx_u.sylo[slot].pax_c); + u2_Host.unx_u.sylo[slot].pax_c = 0; + u2_Host.unx_u.sylo[slot].unx = u2_yes; + u2_Host.unx_u.sylo[slot].wer_m = c3_s4('u','v','s','y'); + u2_Host.unx_u.sylo[slot].wot_m = 0; + u2_Host.unx_u.sylo[slot].pax_c = strdup(nod_u->pax_c); +#endif + // uL(fprintf(uH, "fs: %s in %s\n", pax_c, nod_u->pax_c)); u2_lo_open(); { @@ -978,6 +988,12 @@ _unix_desk_sync_tofu(u2_udir* dir_u, // uL(fprintf(uH, "tofu pox_c %s op %s\n", pox_c, u2_cr_string(u2h(mis)))); +#ifdef SYNCLOG + c3_w slot = u2_Host.unx_u.lot_w++ % 1024; + free(u2_Host.unx_u.sylo[slot].pax_c); + u2_Host.unx_u.sylo[slot].pax_c = 0; +#endif + fil_u = &(dir_u->fil_u); while ( 1 ) { // XX crude! if ( !*fil_u || @@ -992,6 +1008,13 @@ _unix_desk_sync_tofu(u2_udir* dir_u, if ( *fil_u && (c3__del == u2h(mis)) ) { u2_ufil* ded_u = *fil_u; +#ifdef SYNCLOG + u2_Host.unx_u.sylo[slot].unx = u2_no; + u2_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u'); + u2_Host.unx_u.sylo[slot].wot_m = c3__del; + u2_Host.unx_u.sylo[slot].pax_c = strdup(ded_u->pax_c); +#endif + *fil_u = ded_u->nex_u; _unix_unlink(ded_u->pax_c); _unix_file_free(ded_u); @@ -1024,6 +1047,13 @@ _unix_desk_sync_tofu(u2_udir* dir_u, pax_c = pox_c; free(pux_c); } +#ifdef SYNCLOG + u2_Host.unx_u.sylo[slot].unx = u2_no; + u2_Host.unx_u.sylo[slot].wer_m = c3_s4('t','o','f','u'); + u2_Host.unx_u.sylo[slot].wot_m = u2h(mis); + u2_Host.unx_u.sylo[slot].pax_c = strdup(pax_c); +#endif + _unix_save(pax_c, oat); if ( *fil_u ) { @@ -1363,6 +1393,10 @@ u2_unix_io_init(void) sig_u->nex_u = unx_u->sig_u; unx_u->sig_u = sig_u; } +#if SYNCLOG + unx_u->lot_w = 0; + memset(unx_u->sylo, 0, sizeof(unx_u->sylo)); +#endif uv_check_init(u2_Host.lup_u, &u2_Host.unx_u.syn_u); } @@ -1391,6 +1425,11 @@ u2_unix_io_exit(void) u2_unix_release(hot_u->dir_u.pax_c); } } +#ifdef SYNCLOG + for (int i = 0; i<1024; i++) { + free(u2_Host.unx_u.sylo[i].pax_c); + } +#endif } /* u2_unix_io_poll(): update unix IO state. @@ -1422,4 +1461,3 @@ u2_unix_io_poll(void) } u2z(wen); } -