mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-24 23:57:57 +01:00
LMDB does not guarantee alignment.
This commit is contained in:
parent
648026574f
commit
a145efc948
@ -144,6 +144,7 @@ impl<A: Adapter> DB<A>
|
|||||||
-> Result<Option<&'txn Archived<A::Value>>, A::Error>
|
-> Result<Option<&'txn Archived<A::Value>>, A::Error>
|
||||||
{
|
{
|
||||||
if let Some(buf) = self.db.get(txn, key).map_err(A::from_db_err)? {
|
if let Some(buf) = self.db.get(txn, key).map_err(A::from_db_err)? {
|
||||||
|
tracing::trace!(?buf, ptr=?buf.as_ptr(), "db read");
|
||||||
Ok(Some(unsafe { archived_root::<A::Value>(buf.as_ref()) }))
|
Ok(Some(unsafe { archived_root::<A::Value>(buf.as_ref()) }))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
@ -171,10 +172,19 @@ impl<'a, A> DB<A>
|
|||||||
let pos = serializer.serialize_value(val)
|
let pos = serializer.serialize_value(val)
|
||||||
.map_err(A::from_ser_err)?;
|
.map_err(A::from_ser_err)?;
|
||||||
|
|
||||||
|
|
||||||
let buf = serializer.into_slice();
|
let buf = serializer.into_slice();
|
||||||
self.db.put(txn, key, &buf, flags)
|
let buf = buf.as_ref();
|
||||||
|
println!("{:?}", buf);
|
||||||
|
|
||||||
|
tracing::trace!(len=buf.len(), pos, "writing value into db");
|
||||||
|
|
||||||
|
let mut stor = self.db.reserve(txn, key, buf.len(), flags)
|
||||||
.map_err(A::from_db_err)?;
|
.map_err(A::from_db_err)?;
|
||||||
|
|
||||||
|
tracing::trace!(store=?stor.as_ptr(), "store");
|
||||||
|
stor.copy_from_slice(&buf[..]);
|
||||||
|
|
||||||
Ok(pos)
|
Ok(pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,11 @@ impl Inner {
|
|||||||
state
|
state
|
||||||
} else {
|
} else {
|
||||||
tracing::info!(%id, "No previous state, defaulting to `free`");
|
tracing::info!(%id, "No previous state, defaulting to `free`");
|
||||||
MachineState::free(None)
|
let state = MachineState::used(UserRef::new("test".to_string()), Some(UserRef::new
|
||||||
|
("prev".to_string())));
|
||||||
|
let update = state.to_state();
|
||||||
|
db.update(id.as_bytes(), &update, &update).unwrap();
|
||||||
|
state
|
||||||
};
|
};
|
||||||
let signal = Mutable::new(state.to_state());
|
let signal = Mutable::new(state.to_state());
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ pub struct StateDB {
|
|||||||
impl StateDB {
|
impl StateDB {
|
||||||
pub fn open_env<P: AsRef<Path>>(path: P) -> lmdb::Result<Arc<Environment>> {
|
pub fn open_env<P: AsRef<Path>>(path: P) -> lmdb::Result<Arc<Environment>> {
|
||||||
Environment::new()
|
Environment::new()
|
||||||
.set_flags( EnvironmentFlags::WRITE_MAP
|
.set_flags( EnvironmentFlags::WRITE_MAP
|
||||||
| EnvironmentFlags::NO_SUB_DIR
|
| EnvironmentFlags::NO_SUB_DIR
|
||||||
| EnvironmentFlags::NO_TLS
|
| EnvironmentFlags::NO_TLS
|
||||||
| EnvironmentFlags::NO_READAHEAD)
|
| EnvironmentFlags::NO_READAHEAD)
|
||||||
.set_max_dbs(4)
|
.set_max_dbs(4)
|
||||||
|
Loading…
Reference in New Issue
Block a user