mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-05 22:03:50 +03:00
vere: corrects database/disk error printfs
This commit is contained in:
parent
c96705e755
commit
ff6e26f069
@ -38,7 +38,7 @@ u3_lmdb_init(const c3_c* pax_c, size_t siz_i)
|
|||||||
c3_w ret_w;
|
c3_w ret_w;
|
||||||
|
|
||||||
if ( (ret_w = mdb_env_create(&env_u)) ) {
|
if ( (ret_w = mdb_env_create(&env_u)) ) {
|
||||||
fprintf(stderr, "lmdb: init fail: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: init fail: %s\r\n", mdb_strerror(ret_w));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ u3_lmdb_init(const c3_c* pax_c, size_t siz_i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( (ret_w = mdb_env_open(env_u, pax_c, 0, 0664)) ) {
|
if ( (ret_w = mdb_env_open(env_u, pax_c, 0, 0664)) ) {
|
||||||
fprintf(stderr, "lmdb: failed to open event log: %s\n",
|
fprintf(stderr, "lmdb: failed to open event log: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
// XX dispose env_u
|
// XX dispose env_u
|
||||||
//
|
//
|
||||||
@ -93,7 +93,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d)
|
|||||||
// XX why no MDB_RDONLY?
|
// XX why no MDB_RDONLY?
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) {
|
if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) {
|
||||||
fprintf(stderr, "lmdb: gulf: txn_begin fail: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: gulf: txn_begin fail: %s\r\n", mdb_strerror(ret_w));
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d)
|
|||||||
c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY;
|
c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY;
|
||||||
|
|
||||||
if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) {
|
if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) {
|
||||||
fprintf(stderr, "lmdb: gulf: dbi_open fail: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: gulf: dbi_open fail: %s\r\n", mdb_strerror(ret_w));
|
||||||
// XX confirm
|
// XX confirm
|
||||||
//
|
//
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
@ -120,7 +120,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d)
|
|||||||
// creates a cursor to point to the last event
|
// creates a cursor to point to the last event
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_cursor_open(txn_u, mdb_u, &cur_u)) ) {
|
if ( (ret_w = mdb_cursor_open(txn_u, mdb_u, &cur_u)) ) {
|
||||||
fprintf(stderr, "lmdb: gulf: cursor_open fail: %s\n",
|
fprintf(stderr, "lmdb: gulf: cursor_open fail: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
// XX confirm
|
// XX confirm
|
||||||
//
|
//
|
||||||
@ -140,7 +140,7 @@ u3_lmdb_gulf(MDB_env* env_u, c3_d* low_d, c3_d* hig_d)
|
|||||||
return c3y;
|
return c3y;
|
||||||
}
|
}
|
||||||
else if ( ret_w ) {
|
else if ( ret_w ) {
|
||||||
fprintf(stderr, "lmdb: gulf: head fail: %s\n",
|
fprintf(stderr, "lmdb: gulf: head fail: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
mdb_cursor_close(cur_u);
|
mdb_cursor_close(cur_u);
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
@ -191,7 +191,7 @@ u3_lmdb_read(MDB_env* env_u,
|
|||||||
// create a read-only transaction.
|
// create a read-only transaction.
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_txn_begin(env_u, 0, MDB_RDONLY, &txn_u)) ) {
|
if ( (ret_w = mdb_txn_begin(env_u, 0, MDB_RDONLY, &txn_u)) ) {
|
||||||
fprintf(stderr, "lmdb: read txn_begin fail: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: read txn_begin fail: %s\r\n", mdb_strerror(ret_w));
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ u3_lmdb_read(MDB_env* env_u,
|
|||||||
c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY;
|
c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY;
|
||||||
|
|
||||||
if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) {
|
if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) {
|
||||||
fprintf(stderr, "lmdb: read: dbi_open fail: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: read: dbi_open fail: %s\r\n", mdb_strerror(ret_w));
|
||||||
// XX confirm
|
// XX confirm
|
||||||
//
|
//
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
@ -220,7 +220,7 @@ u3_lmdb_read(MDB_env* env_u,
|
|||||||
// creates a cursor to iterate over keys starting at [eve_d]
|
// creates a cursor to iterate over keys starting at [eve_d]
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_cursor_open(txn_u, mdb_u, &cur_u)) ) {
|
if ( (ret_w = mdb_cursor_open(txn_u, mdb_u, &cur_u)) ) {
|
||||||
fprintf(stderr, "lmdb: read: cursor_open fail: %s\n",
|
fprintf(stderr, "lmdb: read: cursor_open fail: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
// XX confirm
|
// XX confirm
|
||||||
//
|
//
|
||||||
@ -312,7 +312,7 @@ u3_lmdb_save(MDB_env* env_u,
|
|||||||
// create a write transaction
|
// create a write transaction
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) {
|
if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) {
|
||||||
fprintf(stderr, "lmdb: write: txn_begin fail: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: write: txn_begin fail: %s\r\n", mdb_strerror(ret_w));
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ u3_lmdb_save(MDB_env* env_u,
|
|||||||
c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY;
|
c3_w ops_w = MDB_CREATE | MDB_INTEGERKEY;
|
||||||
|
|
||||||
if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) {
|
if ( (ret_w = mdb_dbi_open(txn_u, "EVENTS", ops_w, &mdb_u)) ) {
|
||||||
fprintf(stderr, "lmdb: write: dbi_open fail: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: write: dbi_open fail: %s\r\n", mdb_strerror(ret_w));
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
@ -343,7 +343,7 @@ u3_lmdb_save(MDB_env* env_u,
|
|||||||
MDB_val val_u = { .mv_size = siz_i[i_d], .mv_data = byt_p[i_d] };
|
MDB_val val_u = { .mv_size = siz_i[i_d], .mv_data = byt_p[i_d] };
|
||||||
|
|
||||||
if ( (ret_w = mdb_put(txn_u, mdb_u, &key_u, &val_u, ops_w)) ) {
|
if ( (ret_w = mdb_put(txn_u, mdb_u, &key_u, &val_u, ops_w)) ) {
|
||||||
fprintf(stderr, "lmdb: write failed on event %" PRIu64 "\n", key_d);
|
fprintf(stderr, "lmdb: write failed on event %" PRIu64 "\r\n", key_d);
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
@ -354,7 +354,7 @@ u3_lmdb_save(MDB_env* env_u,
|
|||||||
// commit transaction
|
// commit transaction
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_txn_commit(txn_u)) ) {
|
if ( (ret_w = mdb_txn_commit(txn_u)) ) {
|
||||||
fprintf(stderr, "lmdb: write failed: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: write failed: %s\r\n", mdb_strerror(ret_w));
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ u3_lmdb_read_meta(MDB_env* env_u,
|
|||||||
// create a read transaction
|
// create a read transaction
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_txn_begin(env_u, 0, MDB_RDONLY, &txn_u)) ) {
|
if ( (ret_w = mdb_txn_begin(env_u, 0, MDB_RDONLY, &txn_u)) ) {
|
||||||
fprintf(stderr, "lmdb: meta read: txn_begin fail: %s\n",
|
fprintf(stderr, "lmdb: meta read: txn_begin fail: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
return read_f(ptr_v, 0, 0);
|
return read_f(ptr_v, 0, 0);
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ u3_lmdb_read_meta(MDB_env* env_u,
|
|||||||
// open the database in the transaction
|
// open the database in the transaction
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_dbi_open(txn_u, "META", 0, &mdb_u)) ) {
|
if ( (ret_w = mdb_dbi_open(txn_u, "META", 0, &mdb_u)) ) {
|
||||||
fprintf(stderr, "lmdb: meta read: dbi_open fail: %s\n",
|
fprintf(stderr, "lmdb: meta read: dbi_open fail: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
return read_f(ptr_v, 0, 0);
|
return read_f(ptr_v, 0, 0);
|
||||||
@ -396,7 +396,7 @@ u3_lmdb_read_meta(MDB_env* env_u,
|
|||||||
MDB_val val_u;
|
MDB_val val_u;
|
||||||
|
|
||||||
if ( (ret_w = mdb_get(txn_u, mdb_u, &key_u, &val_u)) ) {
|
if ( (ret_w = mdb_get(txn_u, mdb_u, &key_u, &val_u)) ) {
|
||||||
fprintf(stderr, "lmdb: read failed: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: read failed: %s\r\n", mdb_strerror(ret_w));
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
return read_f(ptr_v, 0, 0);
|
return read_f(ptr_v, 0, 0);
|
||||||
}
|
}
|
||||||
@ -425,7 +425,7 @@ u3_lmdb_save_meta(MDB_env* env_u,
|
|||||||
// create a write transaction
|
// create a write transaction
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) {
|
if ( (ret_w = mdb_txn_begin(env_u, 0, 0, &txn_u)) ) {
|
||||||
fprintf(stderr, "lmdb: meta write: txn_begin fail: %s\n",
|
fprintf(stderr, "lmdb: meta write: txn_begin fail: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ u3_lmdb_save_meta(MDB_env* env_u,
|
|||||||
// opens the database in the transaction
|
// opens the database in the transaction
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_dbi_open(txn_u, "META", MDB_CREATE, &mdb_u)) ) {
|
if ( (ret_w = mdb_dbi_open(txn_u, "META", MDB_CREATE, &mdb_u)) ) {
|
||||||
fprintf(stderr, "lmdb: meta write: dbi_open fail: %s\n",
|
fprintf(stderr, "lmdb: meta write: dbi_open fail: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
return c3n;
|
return c3n;
|
||||||
@ -446,7 +446,7 @@ u3_lmdb_save_meta(MDB_env* env_u,
|
|||||||
MDB_val val_u = { .mv_size = val_i, .mv_data = val_p };
|
MDB_val val_u = { .mv_size = val_i, .mv_data = val_p };
|
||||||
|
|
||||||
if ( (ret_w = mdb_put(txn_u, mdb_u, &key_u, &val_u, 0)) ) {
|
if ( (ret_w = mdb_put(txn_u, mdb_u, &key_u, &val_u, 0)) ) {
|
||||||
fprintf(stderr, "lmdb: write failed: %s\n", mdb_strerror(ret_w));
|
fprintf(stderr, "lmdb: write failed: %s\r\n", mdb_strerror(ret_w));
|
||||||
mdb_txn_abort(txn_u);
|
mdb_txn_abort(txn_u);
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
@ -455,7 +455,7 @@ u3_lmdb_save_meta(MDB_env* env_u,
|
|||||||
// commit txn
|
// commit txn
|
||||||
//
|
//
|
||||||
if ( (ret_w = mdb_txn_commit(txn_u)) ) {
|
if ( (ret_w = mdb_txn_commit(txn_u)) ) {
|
||||||
fprintf(stderr, "lmdb: meta write: commit failed: %s\n",
|
fprintf(stderr, "lmdb: meta write: commit failed: %s\r\n",
|
||||||
mdb_strerror(ret_w));
|
mdb_strerror(ret_w));
|
||||||
return c3n;
|
return c3n;
|
||||||
}
|
}
|
||||||
|
@ -692,7 +692,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
|||||||
//
|
//
|
||||||
{
|
{
|
||||||
if ( 0 == (log_u->dir_u = u3_foil_folder(pax_c)) ) {
|
if ( 0 == (log_u->dir_u = u3_foil_folder(pax_c)) ) {
|
||||||
fprintf(stderr, "disk: failed to load pier at %s", pax_c);
|
fprintf(stderr, "disk: failed to load pier at %s\r\n", pax_c);
|
||||||
c3_free(log_u);
|
c3_free(log_u);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -707,7 +707,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
|||||||
strcat(urb_c, "/.urb");
|
strcat(urb_c, "/.urb");
|
||||||
|
|
||||||
if ( 0 == (log_u->urb_u = u3_foil_folder(urb_c)) ) {
|
if ( 0 == (log_u->urb_u = u3_foil_folder(urb_c)) ) {
|
||||||
fprintf(stderr, "disk: failed to load /.urb in %s", pax_c);
|
fprintf(stderr, "disk: failed to load /.urb in %s\r\n", pax_c);
|
||||||
c3_free(urb_c);
|
c3_free(urb_c);
|
||||||
c3_free(log_u);
|
c3_free(log_u);
|
||||||
return 0;
|
return 0;
|
||||||
@ -740,7 +740,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
|||||||
strcat(log_c, "/.urb/log");
|
strcat(log_c, "/.urb/log");
|
||||||
|
|
||||||
if ( 0 == (log_u->com_u = u3_foil_folder(log_c)) ) {
|
if ( 0 == (log_u->com_u = u3_foil_folder(log_c)) ) {
|
||||||
fprintf(stderr, "disk: failed to load /.urb/log in %s", pax_c);
|
fprintf(stderr, "disk: failed to load /.urb/log in %s\r\n", pax_c);
|
||||||
c3_free(log_c);
|
c3_free(log_c);
|
||||||
c3_free(log_u);
|
c3_free(log_u);
|
||||||
return 0;
|
return 0;
|
||||||
@ -755,7 +755,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
|||||||
const size_t siz_i = 1099511627776;
|
const size_t siz_i = 1099511627776;
|
||||||
|
|
||||||
if ( 0 == (log_u->mdb_u = u3_lmdb_init(log_c, siz_i)) ) {
|
if ( 0 == (log_u->mdb_u = u3_lmdb_init(log_c, siz_i)) ) {
|
||||||
fprintf(stderr, "disk: failed to initialize database");
|
fprintf(stderr, "disk: failed to initialize database\r\n");
|
||||||
c3_free(log_c);
|
c3_free(log_c);
|
||||||
c3_free(log_u);
|
c3_free(log_u);
|
||||||
return 0;
|
return 0;
|
||||||
@ -772,7 +772,7 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
|
|||||||
c3_d fir_d;
|
c3_d fir_d;
|
||||||
|
|
||||||
if ( c3n == u3_lmdb_gulf(log_u->mdb_u, &fir_d, &log_u->dun_d) ) {
|
if ( c3n == u3_lmdb_gulf(log_u->mdb_u, &fir_d, &log_u->dun_d) ) {
|
||||||
fprintf(stderr, "disk: failed to load latest event from database");
|
fprintf(stderr, "disk: failed to load latest event from database\r\n");
|
||||||
c3_free(log_u);
|
c3_free(log_u);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user