mirror of
https://github.com/urbit/vere.git
synced 2024-09-11 03:45:31 +03:00
Merge release to develop (#597)
This commit is contained in:
commit
4ffc07f3cb
@ -628,17 +628,15 @@ u3_disk_walk_done(u3_disk_walk* wok_u)
|
||||
/* _disk_save_meta(): serialize atom, save as metadata at [key_c].
|
||||
*/
|
||||
static c3_o
|
||||
_disk_save_meta(MDB_env* mdb_u, const c3_c* key_c, u3_atom dat)
|
||||
_disk_save_meta(MDB_env* mdb_u, const c3_c* key_c, c3_w len_w, c3_y* byt_y)
|
||||
{
|
||||
c3_w len_w = u3r_met(3, dat);
|
||||
c3_y* byt_y = c3_malloc(len_w);
|
||||
u3r_bytes(0, len_w, byt_y, dat);
|
||||
|
||||
{
|
||||
c3_o ret_o = u3_lmdb_save_meta(mdb_u, key_c, len_w, byt_y);
|
||||
c3_free(byt_y);
|
||||
return ret_o;
|
||||
// strip trailing zeroes.
|
||||
//
|
||||
while ( len_w && !byt_y[len_w - 1] ) {
|
||||
len_w--;
|
||||
}
|
||||
|
||||
return u3_lmdb_save_meta(mdb_u, key_c, len_w, byt_y);
|
||||
}
|
||||
|
||||
/* u3_disk_save_meta(): save metadata.
|
||||
@ -650,12 +648,15 @@ u3_disk_save_meta(MDB_env* mdb_u,
|
||||
c3_o fak_o,
|
||||
c3_w lif_w)
|
||||
{
|
||||
u3_assert( c3y == u3a_is_cat(ver_w) );
|
||||
u3_assert( c3y == u3a_is_cat(lif_w) );
|
||||
|
||||
if ( (c3n == _disk_save_meta(mdb_u, "version", ver_w))
|
||||
|| (c3n == _disk_save_meta(mdb_u, "who", u3i_chubs(2, who_d)))
|
||||
|| (c3n == _disk_save_meta(mdb_u, "fake", fak_o))
|
||||
|| (c3n == _disk_save_meta(mdb_u, "life", lif_w)) )
|
||||
// XX assumes little-endian
|
||||
//
|
||||
if ( (c3n == _disk_save_meta(mdb_u, "version", 4, (c3_y*)&ver_w))
|
||||
|| (c3n == _disk_save_meta(mdb_u, "who", 16, (c3_y*)who_d))
|
||||
|| (c3n == _disk_save_meta(mdb_u, "fake", 1, (c3_y*)&fak_o))
|
||||
|| (c3n == _disk_save_meta(mdb_u, "life", 4, (c3_y*)&lif_w)) )
|
||||
{
|
||||
return c3n;
|
||||
}
|
||||
@ -1423,9 +1424,12 @@ _disk_migrate(u3_disk* log_u, c3_d eve_d)
|
||||
}
|
||||
|
||||
// set version to 2 (migration in progress)
|
||||
if ( c3n == _disk_save_meta(log_u->mdb_u, "version", (c3_w)U3D_VER2) ) {
|
||||
fprintf(stderr, "disk: failed to set version to 2\r\n");
|
||||
return c3n;
|
||||
{
|
||||
c3_w ver_w = U3D_VER2;
|
||||
if ( c3n == _disk_save_meta(log_u->mdb_u, "version", 4, (c3_y*)&ver_w) ) {
|
||||
fprintf(stderr, "disk: failed to set version to 2\r\n");
|
||||
return c3n;
|
||||
}
|
||||
}
|
||||
|
||||
// finish with old log
|
||||
@ -1796,17 +1800,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
||||
return log_u;
|
||||
}
|
||||
|
||||
if ( c3n == exs_o ) {
|
||||
c3_d lat_d;
|
||||
if ( c3n == u3_disk_epoc_last(log_u, &lat_d) ) {
|
||||
fprintf(stderr, "disk: no event log anywhere\r\n");
|
||||
c3_free(log_u);
|
||||
return 0;
|
||||
}
|
||||
// presume pre-release migrated pier
|
||||
log_u->ver_w = U3D_VERLAT;
|
||||
}
|
||||
else {
|
||||
if ( c3y == exs_o ) {
|
||||
// load the old data.mdb file
|
||||
if ( 0 == (log_u->mdb_u = u3_lmdb_init(log_c, siz_i)) ) {
|
||||
fprintf(stderr, "disk: failed to initialize lmdb\r\n");
|
||||
@ -1817,8 +1811,21 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
||||
// read version from old log
|
||||
if ( c3n == u3_disk_read_meta(log_u->mdb_u, &log_u->ver_w, 0, 0, 0) ) {
|
||||
fprintf(stderr, "disk: failed to read metadata\r\n");
|
||||
c3_free(log_u);
|
||||
return 0;
|
||||
goto try_epoc_no;
|
||||
}
|
||||
}
|
||||
else {
|
||||
try_epoc_no:
|
||||
{
|
||||
c3_d lat_d;
|
||||
if ( c3n == u3_disk_epoc_last(log_u, &lat_d) ) {
|
||||
fprintf(stderr, "disk: no event log anywhere\r\n");
|
||||
c3_free(log_u);
|
||||
return 0;
|
||||
}
|
||||
// presume pre-release migrated pier
|
||||
log_u->ver_w = U3D_VERLAT;
|
||||
exs_o = c3n;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1838,7 +1845,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
||||
return log_u;
|
||||
}
|
||||
|
||||
case U3D_VERLAT: break;
|
||||
case U3D_VER3: break;
|
||||
|
||||
default: {
|
||||
fprintf(stderr, "disk: unknown log version: %d\r\n", log_u->ver_w);
|
||||
|
@ -1081,7 +1081,7 @@ _ames_czar_here(u3_pact* pac_u, time_t now, struct sockaddr_in* add_u)
|
||||
u3_noun nam = u3dc("scot", c3__if, u3i_word(pip_w));
|
||||
c3_c* nam_c = u3r_string(nam);
|
||||
|
||||
u3l_log("ames: czar %s: ip %s", pac_u->rut_u.dns_c, nam_c);
|
||||
u3l_log("ames: czar %s ip %s", pac_u->rut_u.dns_c, nam_c);
|
||||
|
||||
c3_free(nam_c);
|
||||
u3z(nam);
|
||||
@ -1107,7 +1107,7 @@ _stun_czar_here(u3_ames* sam_u, time_t now, struct sockaddr_in* add_u)
|
||||
u3_noun nam = u3dc("scot", c3__if, u3i_word(pip_w));
|
||||
c3_c* nam_c = u3r_string(nam);
|
||||
|
||||
u3l_log("stun: czar %s: ip %s", sam_u->dns_c, nam_c);
|
||||
u3l_log("stun: czar %s ip %s", sam_u->sun_u.dns_c, nam_c);
|
||||
|
||||
c3_free(nam_c);
|
||||
u3z(nam);
|
||||
|
Loading…
Reference in New Issue
Block a user