Merge pull request #1167 from urbit/rereplay

replay one event at a time
This commit is contained in:
Ted Blackman 2019-01-29 14:06:58 -08:00 committed by GitHub
commit 3fd90188a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 196 additions and 154 deletions

View File

@ -326,15 +326,6 @@
c3_l tno_l; // terminal count in host c3_l tno_l; // terminal count in host
} u3_uled; } u3_uled;
/* u3_olar: event log trailer, old version.
*/
typedef struct {
c3_w syn_w; // must equal mug of address
c3_w ent_w; // event sequence number
c3_w len_w; // word length of this event
c3_w mug_w; // mug of entry
} u3_olar;
/* u3_ular: event log trailer. /* u3_ular: event log trailer.
*/ */
typedef struct { typedef struct {

View File

@ -15,10 +15,14 @@ c3_d
u3_sist_pack(c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w) u3_sist_pack(c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
{ {
u3_ulog* lug_u = &u3Z->lug_u; u3_ulog* lug_u = &u3Z->lug_u;
c3_d hed_d;
c3_d ven_d;
c3_d tar_d; c3_d tar_d;
u3_ular lar_u; u3_ular lar_u;
tar_d = lug_u->len_d + len_w; hed_d = lug_u->len_d;
ven_d = hed_d + c3_wiseof(c3_w);
tar_d = ven_d + (c3_d)len_w;
lar_u.tem_w = tem_w; lar_u.tem_w = tem_w;
lar_u.typ_w = typ_w; lar_u.typ_w = typ_w;
@ -30,6 +34,8 @@ u3_sist_pack(c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
u3A->ent_d++; u3A->ent_d++;
lar_u.len_w = len_w; lar_u.len_w = len_w;
// write trailer
//
if ( -1 == lseek64(lug_u->fid_i, 4ULL * tar_d, SEEK_SET) ) { if ( -1 == lseek64(lug_u->fid_i, 4ULL * tar_d, SEEK_SET) ) {
uL(fprintf(uH, "sist: seek failed, lseek: %s\n", strerror(errno))); uL(fprintf(uH, "sist: seek failed, lseek: %s\n", strerror(errno)));
c3_assert(0); c3_assert(0);
@ -38,7 +44,19 @@ u3_sist_pack(c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
uL(fprintf(uH, "sist: write failed, write: %s\n", strerror(errno))); uL(fprintf(uH, "sist: write failed, write: %s\n", strerror(errno)));
c3_assert(0); c3_assert(0);
} }
if ( -1 == lseek64(lug_u->fid_i, 4ULL * lug_u->len_d, SEEK_SET) ) { // write header (just a size)
//
if ( -1 == lseek64(lug_u->fid_i, 4ULL * hed_d, SEEK_SET) ) {
uL(fprintf(uH, "sist: seek failed, lseek: %s\n", strerror(errno)));
c3_assert(0);
}
if ( sizeof(c3_w) != write(lug_u->fid_i, &len_w, sizeof(c3_w)) ) {
uL(fprintf(uH, "sist: write failed, write: %s\n", strerror(errno)));
c3_assert(0);
}
// write the event in between the header and trailer
//
if ( -1 == lseek64(lug_u->fid_i, 4ULL * ven_d, SEEK_SET) ) {
uL(fprintf(uH, "sist: seek failed, lseek: %s\n", strerror(errno))); uL(fprintf(uH, "sist: seek failed, lseek: %s\n", strerror(errno)));
c3_assert(0); c3_assert(0);
} }
@ -54,7 +72,7 @@ u3_sist_pack(c3_w tem_w, c3_w typ_w, c3_w* bob_w, c3_w len_w)
uL(fprintf(uH, "sist: write failed, write: %s\n", strerror(errno))); uL(fprintf(uH, "sist: write failed, write: %s\n", strerror(errno)));
c3_assert(0); c3_assert(0);
} }
lug_u->len_d += (c3_d)(lar_u.len_w + c3_wiseof(lar_u)); lug_u->len_d += (c3_d)(lar_u.len_w + c3_wiseof(lar_u) + c3_wiseof(c3_w));
free(bob_w); free(bob_w);
// Sync. Or, what goes by sync. // Sync. Or, what goes by sync.
@ -242,7 +260,7 @@ _sist_sing(u3_noun ovo)
if ( c3__init == u3h(fav) ) { if ( c3__init == u3h(fav) ) {
u3A->own = u3k(u3t(fav)); u3A->own = u3k(u3t(fav));
u3A->fak = ( c3__fake == u3h(tag) ) ? c3y : c3n; u3A->fak = ( c3__fake == u3h(dat) ) ? c3y : c3n;
} }
vir = u3t(vir); vir = u3t(vir);
@ -554,7 +572,7 @@ _sist_zest()
{ {
u3_uled led_u; u3_uled led_u;
led_u.mag_l = u3r_mug('g'); led_u.mag_l = u3r_mug('h');
led_u.kno_w = 163; led_u.kno_w = 163;
if ( 0 == u3A->key ) { if ( 0 == u3A->key ) {
@ -595,26 +613,40 @@ _sist_rest_nuu(u3_ulog* lug_u, u3_uled led_u, c3_c* old_c)
uL(fprintf(uH, "rest: converting log from prior format\n")); uL(fprintf(uH, "rest: converting log from prior format\n"));
c3_assert(led_u.mag_l == u3r_mug('f')); c3_assert(led_u.mag_l == u3r_mug('g'));
if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { ret_i = snprintf(nuu_c, 2048, "%s/.urb/ham.hope", u3_Host.dir_c);
uL(fprintf(uH, "rest: rest_nuu failed (a), lseek64: %s\n", strerror(errno))); c3_assert(ret_i < 2048);
if ( (fud_i = open(nuu_c, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0 ) {
uL(fprintf(uH, "rest: can't open record (%s), open: %s\n", nuu_c,
strerror(errno)));
u3_lo_bail(); u3_lo_bail();
} }
led_u.mag_l = u3r_mug('h');
if ( (sizeof(led_u) != write(fud_i, &led_u, sizeof(led_u))) ) {
uL(fprintf(uH, "rest: can't write header, write: %s\n", strerror(errno)));
u3_lo_bail();
}
c3_o fir_o = c3y;
c3_d pos_d, new_d;
while ( end_d != c3_wiseof(u3_uled) ) { while ( end_d != c3_wiseof(u3_uled) ) {
c3_d tar_d; c3_d tar_d;
u3_olar lar_u; u3_ular lar_u;
c3_w* img_w; c3_w* img_w;
u3_noun ron;
tar_d = (end_d - (c3_d)c3_wiseof(u3_olar)); // read trailer
//
tar_d = (end_d - (c3_d)c3_wiseof(u3_ular));
if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) { if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) {
uL(fprintf(uH, "rest_nuu failed (b), lseek64: %s\n", strerror(errno))); uL(fprintf(uH, "rest_nuu failed (b), lseek64: %s\n", strerror(errno)));
u3_lo_bail(); u3_lo_bail();
} }
if ( sizeof(u3_olar) != read(fid_i, &lar_u, sizeof(u3_olar)) ) { if ( sizeof(u3_ular) != read(fid_i, &lar_u, sizeof(u3_ular)) ) {
uL(fprintf(uH, "rest_nuu failed (c), read: %s\n", strerror(errno))); uL(fprintf(uH, "rest_nuu failed (c), read: %s\n", strerror(errno)));
u3_lo_bail(); u3_lo_bail();
} }
@ -624,6 +656,16 @@ _sist_rest_nuu(u3_ulog* lug_u, u3_uled led_u, c3_c* old_c)
u3_lo_bail(); u3_lo_bail();
} }
// calculate new log size
//
if ( c3y == fir_o ) {
pos_d = (end_d + lar_u.ent_d + 1);
new_d = pos_d;
fir_o = c3n;
}
// read event
//
img_w = c3_malloc(4 * lar_u.len_w); img_w = c3_malloc(4 * lar_u.len_w);
end_d = (tar_d - (c3_d)lar_u.len_w); end_d = (tar_d - (c3_d)lar_u.len_w);
@ -636,15 +678,50 @@ _sist_rest_nuu(u3_ulog* lug_u, u3_uled led_u, c3_c* old_c)
u3_lo_bail(); u3_lo_bail();
} }
ron = u3i_words(lar_u.len_w, img_w); // write event trailer
free(img_w); //
pos_d -= (c3_d)c3_wiseof(lar_u);
if ( lar_u.mug_w != u3r_mug(ron) ) { lar_u.syn_w = u3r_mug_chub(pos_d);
uL(fprintf(uH, "rest_nuu failed (g)\n"));
if ( -1 == lseek64(fud_i, (4ULL * pos_d), SEEK_SET) ) {
uL(fprintf(uH, "rest_nuu failed (g), lseek64: %s\n", strerror(errno)));
u3_lo_bail(); u3_lo_bail();
} }
roe = u3nc(ron, roe); if ( sizeof(u3_ular) != write(fud_i, &lar_u, sizeof(u3_ular)) ) {
uL(fprintf(uH, "rest_nuu failed (h), read: %s\n", strerror(errno)));
u3_lo_bail();
}
// write event
//
pos_d -= (c3_d)lar_u.len_w;
if ( -1 == lseek64(fud_i, (4ULL * pos_d), SEEK_SET) ) {
uL(fprintf(uH, "rest_nuu failed (i), lseek64: %s\n", strerror(errno)));
u3_lo_bail();
}
if ( (4 * lar_u.len_w) != write(fud_i, img_w, (4 * lar_u.len_w)) ) {
uL(fprintf(uH, "rest_nuu failed (j), read: %s\n", strerror(errno)));
u3_lo_bail();
}
// write event header
//
pos_d -= c3_wiseof(c3_w);
if ( -1 == lseek64(fud_i, (4ULL * pos_d), SEEK_SET) ) {
uL(fprintf(uH, "rest_nuu failed (k), lseek64: %s\n", strerror(errno)));
u3_lo_bail();
}
if ( 4ULL != write(fud_i, &lar_u.len_w, 4ULL) ) {
uL(fprintf(uH, "rest_nuu failed (l), read: %s\n", strerror(errno)));
u3_lo_bail();
}
free(img_w);
} }
if ( 0 != close(fid_i) ) { if ( 0 != close(fid_i) ) {
@ -652,61 +729,6 @@ _sist_rest_nuu(u3_ulog* lug_u, u3_uled led_u, c3_c* old_c)
u3_lo_bail(); u3_lo_bail();
} }
ret_i = snprintf(nuu_c, 2048, "%s/.urb/ham.hope", u3_Host.dir_c);
c3_assert(ret_i < 2048);
if ( (fud_i = open(nuu_c, O_CREAT | O_TRUNC | O_RDWR, 0600)) < 0 ) {
uL(fprintf(uH, "rest: can't open record (%s), open: %s\n", nuu_c,
strerror(errno)));
u3_lo_bail();
}
led_u.mag_l = u3r_mug('g');
if ( (sizeof(led_u) != write(fud_i, &led_u, sizeof(led_u))) ) {
uL(fprintf(uH, "rest: can't write header, write: %s\n", strerror(errno)));
u3_lo_bail();
}
{
c3_d ent_d = 1;
c3_assert(end_d == c3_wiseof(u3_uled));
while ( u3_nul != roe ) {
u3_noun ovo = u3k(u3h(roe));
u3_noun nex = u3k(u3t(roe));
u3_ular lar_u;
c3_w* img_w;
c3_d tar_d;
lar_u.len_w = u3r_met(5, ovo);
tar_d = end_d + lar_u.len_w;
lar_u.syn_w = u3r_mug(tar_d);
lar_u.ent_d = ent_d;
lar_u.tem_w = 0;
lar_u.typ_w = c3__ov;
u3_noun moo = u3nt(u3k(ovo), u3_nul, c3__ov);
lar_u.mug_w = u3r_mug(moo);
u3z(moo);
img_w = c3_malloc(lar_u.len_w << 2);
u3r_words(0, lar_u.len_w, img_w, ovo);
u3z(ovo);
if ( (lar_u.len_w << 2) != write(fud_i, img_w, lar_u.len_w << 2) ) {
uL(fprintf(uH, "rest_nuu failed (h), write: %s\n", strerror(errno)));
u3_lo_bail();
}
if ( sizeof(u3_ular) != write(fud_i, &lar_u, sizeof(u3_ular)) ) {
uL(fprintf(uH, "rest_nuu failed (i), write: %s\n", strerror(errno)));
u3_lo_bail();
}
ent_d++;
end_d = tar_d + c3_wiseof(u3_ular);
u3z(roe); roe = nex;
}
}
if ( 0 != rename(nuu_c, old_c) ) { if ( 0 != rename(nuu_c, old_c) ) {
uL(fprintf(uH, "rest_nuu failed (k), rename: %s\n", strerror(errno))); uL(fprintf(uH, "rest_nuu failed (k), rename: %s\n", strerror(errno)));
u3_lo_bail(); u3_lo_bail();
@ -716,7 +738,7 @@ _sist_rest_nuu(u3_ulog* lug_u, u3_uled led_u, c3_c* old_c)
u3_lo_bail(); u3_lo_bail();
} }
lug_u->fid_i = fud_i; lug_u->fid_i = fud_i;
lug_u->len_d = end_d; lug_u->len_d = new_d;
} }
/* _sist_rest(): restore from record, or exit. /* _sist_rest(): restore from record, or exit.
@ -727,11 +749,12 @@ _sist_rest()
struct stat buf_b; struct stat buf_b;
c3_i fid_i; c3_i fid_i;
c3_c ful_c[2048]; c3_c ful_c[2048];
c3_d cur_d;
c3_d old_d = u3A->ent_d; c3_d old_d = u3A->ent_d;
c3_d las_d = 0; c3_d las_d = 0;
u3_noun roe = u3_nul;
u3_noun sev_l, key_l, sal_l; u3_noun sev_l, key_l, sal_l;
u3_noun ohh = c3n; u3_noun ohh = c3n;
u3_ular lar_u;
if ( 0 != u3A->ent_d ) { if ( 0 != u3A->ent_d ) {
u3_noun ent; u3_noun ent;
@ -779,11 +802,11 @@ _sist_rest()
u3_lo_bail(); u3_lo_bail();
} }
if ( u3r_mug('f') == led_u.mag_l ) { if ( u3r_mug('g') == led_u.mag_l ) {
_sist_rest_nuu(&u3Z->lug_u, led_u, ful_c); _sist_rest_nuu(&u3Z->lug_u, led_u, ful_c);
fid_i = u3Z->lug_u.fid_i; fid_i = u3Z->lug_u.fid_i;
} }
else if (u3r_mug('g') != led_u.mag_l ) { else if (u3r_mug('h') != led_u.mag_l ) {
uL(fprintf(uH, "record (%s) is obsolete (or corrupt)\n", ful_c)); uL(fprintf(uH, "record (%s) is obsolete (or corrupt)\n", ful_c));
u3_lo_bail(); u3_lo_bail();
} }
@ -841,26 +864,22 @@ _sist_rest()
// Read in the fscking events. These are probably corrupt as well. // Read in the fscking events. These are probably corrupt as well.
{ {
c3_d ent_d; c3_d ent_d;
c3_d end_d;
u3_noun rup = c3n; u3_noun rup = c3n;
end_d = u3Z->lug_u.len_d; cur_d = u3Z->lug_u.len_d;
ent_d = 0; ent_d = 0;
if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { if ( -1 == lseek64(fid_i, 4ULL * cur_d, SEEK_SET) ) {
uL(fprintf(uH, "end_d %" PRIu64 ", lseek64: %s\n", end_d, uL(fprintf(uH, "cur_d %" PRIu64 ", lseek64: %s\n", cur_d,
strerror(errno))); strerror(errno)));
uL(fprintf(uH, "rest: record (%s) is corrupt (c)\n", ful_c)); uL(fprintf(uH, "rest: record (%s) is corrupt (c)\n", ful_c));
u3_lo_bail(); u3_lo_bail();
} }
while ( end_d != c3_wiseof(u3_uled) ) { while ( cur_d != (c3_d)c3_wiseof(u3_uled) ) {
c3_d tar_d = (end_d - (c3_d)c3_wiseof(u3_ular)); c3_d tar_d = (cur_d - (c3_d)c3_wiseof(u3_ular));
u3_ular lar_u;
c3_w* img_w;
u3_noun ron;
// uL(fprintf(uH, "rest: reading event at %" PRIx64 "\n", end_d)); // uL(fprintf(uH, "rest: reading event at %" PRIx64 "\n", cur_d));
if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) { if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (d)\n", ful_c)); uL(fprintf(uH, "rest: record (%s) is corrupt (d)\n", ful_c));
@ -877,7 +896,7 @@ _sist_rest()
rup = c3y; rup = c3y;
} }
uL(fprintf(uH, "lar:%x mug:%x\n", lar_u.syn_w, u3r_mug_chub(tar_d))); uL(fprintf(uH, "lar:%x mug:%x\n", lar_u.syn_w, u3r_mug_chub(tar_d)));
end_d--; u3Z->lug_u.len_d--; cur_d--; u3Z->lug_u.len_d--;
continue; continue;
} }
else if ( c3y == rup ) { else if ( c3y == rup ) {
@ -897,7 +916,7 @@ _sist_rest()
lar_u.len_w, lar_u.len_w,
lar_u.mug_w)); lar_u.mug_w));
#endif #endif
if ( end_d == u3Z->lug_u.len_d ) { if ( cur_d == u3Z->lug_u.len_d ) {
ent_d = las_d = lar_u.ent_d; ent_d = las_d = lar_u.ent_d;
} }
else { else {
@ -908,27 +927,13 @@ _sist_rest()
} }
ent_d -= 1ULL; ent_d -= 1ULL;
} }
end_d = (tar_d - (c3_d)lar_u.len_w); cur_d = tar_d - (c3_d)(lar_u.len_w + c3_wiseof(c3_w));
if ( ent_d < old_d ) { if ( ent_d < old_d ) {
/* change to continue to check all events */ /* change to continue to check all events */
break; break;
} }
img_w = c3_malloc(4 * lar_u.len_w);
if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (h)\n", ful_c));
u3_lo_bail();
}
if ( (4 * lar_u.len_w) != read(fid_i, img_w, (4 * lar_u.len_w)) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (i)\n", ful_c));
u3_lo_bail();
}
ron = u3i_words(lar_u.len_w, img_w);
free(img_w);
// this validation is disabled, as it broke when mug // this validation is disabled, as it broke when mug
// was switched from FNV to Murmur3 // was switched from FNV to Murmur3
// event-log encryption is enabled, so any actual corruption // event-log encryption is enabled, so any actual corruption
@ -944,32 +949,11 @@ _sist_rest()
u3_lo_bail(); u3_lo_bail();
} }
#endif #endif
if ( c3__ov != lar_u.typ_w ) {
u3z(ron);
continue;
}
if ( u3A->key ) {
u3_noun dep;
dep = u3dc("de:crub:crypto", u3k(u3A->key), ron);
if ( c3n == u3du(dep) ) {
uL(fprintf(uH, "record (%s) is corrupt (k)\n", ful_c));
u3_lo_bail();
}
else {
ron = u3k(u3t(dep));
u3z(dep);
}
}
roe = u3nc(u3ke_cue(ron), roe);
} }
u3A->ent_d = c3_max(las_d + 1ULL, old_d); u3A->ent_d = c3_max(las_d + 1ULL, old_d);
} }
if ( u3_nul == roe ) { if ( cur_d == u3Z->lug_u.len_d ) {
// Nothing in the log that was not also in the checkpoint. // Nothing in the log that was not also in the checkpoint.
// //
c3_assert(u3A->ent_d == old_d); c3_assert(u3A->ent_d == old_d);
@ -983,22 +967,88 @@ _sist_rest()
} }
} }
else { else {
u3_noun rou = roe; // Read and execute the fscking things. This is pretty much certain to crash.
c3_w xno_w;
// Execute the fscking things. This is pretty much certain to crash.
// //
uL(fprintf(uH, "rest: replaying through event %" PRIu64 "\n", las_d)); uL(fprintf(uH, "rest: replaying through event %" PRIu64 "\n", las_d));
fprintf(uH, "---------------- playback starting----------------\n"); fprintf(uH, "---------------- playback starting----------------\n");
xno_w = 0; c3_w xno_w = 0;
while ( u3_nul != roe ) { while ( cur_d != u3Z->lug_u.len_d ) {
u3_noun i_roe = u3h(roe); u3_noun ven;
u3_noun t_roe = u3t(roe); u3_noun now, ovo;
u3_noun now = u3h(i_roe); c3_d tar_d;
u3_noun ovo = u3t(i_roe); c3_w* img_w;
c3_w len_w;
// read the size
//
if ( -1 == lseek64(fid_i, 4ULL * cur_d, SEEK_SET) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (d)\n", ful_c));
u3_lo_bail();
}
if ( sizeof(len_w) != read(fid_i, &len_w, sizeof(len_w)) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (e)\n", ful_c));
u3_lo_bail();
}
tar_d = cur_d + c3_wiseof(len_w) + len_w;
// read the trailer
//
if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (d)\n", ful_c));
u3_lo_bail();
}
if ( sizeof(u3_ular) != read(fid_i, &lar_u, sizeof(u3_ular)) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (e)\n", ful_c));
u3_lo_bail();
}
img_w = c3_malloc(4 * lar_u.len_w);
// read the event
//
if ( -1 == lseek64(fid_i, 4ULL * (cur_d + c3_wiseof(c3_w)), SEEK_SET) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (h)\n", ful_c));
u3_lo_bail();
}
if ( (4 * lar_u.len_w) != read(fid_i, img_w, (4 * lar_u.len_w)) ) {
uL(fprintf(uH, "rest: record (%s) is corrupt (i)\n", ful_c));
u3_lo_bail();
}
ven = u3i_words(lar_u.len_w, img_w);
free(img_w);
if ( c3__ov != lar_u.typ_w ) {
u3z(ven);
continue;
}
// decrypt the event
//
if ( u3A->key ) {
u3_noun dep;
dep = u3dc("de:crub:crypto", u3k(u3A->key), ven);
if ( c3n == u3du(dep) ) {
uL(fprintf(uH, "record (%s) is corrupt (k)\n", ful_c));
u3_lo_bail();
}
else {
ven = u3k(u3t(dep));
u3z(dep);
}
}
// run the event
//
ven = u3ke_cue(ven);
now = u3h(ven);
ovo = u3t(ven);
u3v_time(u3k(now)); u3v_time(u3k(now));
if ( (c3y == u3_Host.ops_u.vno) && if ( (c3y == u3_Host.ops_u.vno) &&
( (c3__veer == u3h(u3t(ovo)) || ( (c3__veer == u3h(u3t(ovo)) ||
(c3__vega == u3h(u3t(ovo)))) ) ) (c3__vega == u3h(u3t(ovo)))) ) )
@ -1012,17 +1062,18 @@ _sist_rest()
// fprintf(stderr, "playback: sing: %d\n", xno_w)); // fprintf(stderr, "playback: sing: %d\n", xno_w));
roe = t_roe;
xno_w++; xno_w++;
if ( 0 == (xno_w % 1000) ) { if ( 0 == (xno_w % 1000) ) {
uL(fprintf(uH, "{%d}\n", xno_w)); uL(fprintf(uH, "{%d}\n", xno_w));
// u3_lo_grab("rest", rou, u3_none); // u3_lo_grab("rest", rou, u3_none);
} }
u3z(ven);
cur_d += c3_wiseof(len_w) + len_w + c3_wiseof(lar_u);
} }
u3z(rou); uL(fprintf(stderr, "\n---------------- playback complete----------------\r\n"));
} }
uL(fprintf(stderr, "\n---------------- playback complete----------------\r\n"));
#if 0 #if 0
// If you see this error, your record is totally fscking broken! // If you see this error, your record is totally fscking broken!
@ -1062,13 +1113,13 @@ _sist_rest()
if ( c3y == ohh ) { if ( c3y == ohh ) {
uL(fprintf(uH, "rest: bumping ent_d\n")); uL(fprintf(uH, "rest: bumping ent_d\n"));
u3_ular lar_u; u3_ular lar_u;
c3_d end_d; c3_d cur_d;
c3_d tar_d; c3_d tar_d;
u3A->ent_d++; u3A->ent_d++;
end_d = u3Z->lug_u.len_d; cur_d = u3Z->lug_u.len_d;
while ( end_d != c3_wiseof(u3_uled) ) { while ( cur_d != c3_wiseof(u3_uled) ) {
tar_d = end_d - c3_wiseof(u3_ular); tar_d = cur_d - c3_wiseof(u3_ular);
if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) { if ( -1 == lseek64(fid_i, 4ULL * tar_d, SEEK_SET) ) {
uL(fprintf(uH, "bumping sequence numbers failed (a)\n")); uL(fprintf(uH, "bumping sequence numbers failed (a)\n"));
u3_lo_bail(); u3_lo_bail();
@ -1086,7 +1137,7 @@ _sist_rest()
uL(fprintf(uH, "bumping sequence numbers failed (d)\n")); uL(fprintf(uH, "bumping sequence numbers failed (d)\n"));
u3_lo_bail(); u3_lo_bail();
} }
end_d = tar_d - lar_u.len_w; cur_d = tar_d - (c3_d)(lar_u.len_w + c3_wiseof(c3_w));
} }
} }
@ -1094,11 +1145,11 @@ _sist_rest()
{ {
u3_uled led_u; u3_uled led_u;
led_u.mag_l = u3r_mug('g'); led_u.mag_l = u3r_mug('h');
led_u.sal_l = sal_l; led_u.sal_l = sal_l;
led_u.sev_l = u3A->sev_l; led_u.sev_l = u3A->sev_l;
led_u.key_l = u3A->key ? u3r_mug(u3A->key) : 0; led_u.key_l = u3A->key ? u3r_mug(u3A->key) : 0;
led_u.kno_w = 163; // may need actual translation! led_u.kno_w = 163; // XX very wrong
led_u.tno_l = 1; led_u.tno_l = 1;
if ( (-1 == lseek64(fid_i, 0, SEEK_SET)) || if ( (-1 == lseek64(fid_i, 0, SEEK_SET)) ||