Commit d1cb910c authored by lw's avatar lw

*** empty log message ***

parent 2b392528
......@@ -20,19 +20,27 @@ wb_db_info::wb_db_info(wb_db *db) :
void wb_db_info::get(wb_db_txn *txn)
{
int index = 0;
int ret;
m_key.set_data(&index);
m_key.set_size(sizeof(index));
m_data.set_ulen(sizeof(m_volume));
m_data.set_flags(DB_DBT_USERMEM);
m_db->m_t_info->get(txn, &m_key, &m_data, 0);
ret = m_db->m_t_info->get(txn, &m_key, &m_data, 0);
printf("info get: %d\n", ret);
}
void wb_db_info::put(wb_db_txn *txn)
{
int index = 0;
int ret;
m_key.set_data(&index);
m_key.set_size(sizeof(index));
m_db->m_t_info->put(txn, &m_key, &m_data, 0);
ret = m_db->m_t_info->put(txn, &m_key, &m_data, 0);
printf("info put: %d\n", ret);
}
wb_db_class::wb_db_class(wb_db *db, wb_db_txn *txn, pwr_tCid cid) :
......@@ -161,24 +169,29 @@ void wb_db_name::name(wb_name &name)
}
wb_db_ohead::wb_db_ohead() :
m_db(0), m_key(&m_o.oid, sizeof(m_o.oid)), m_data(&m_o, sizeof(m_o))
m_db(0), m_key(&m_oid, sizeof(m_oid)), m_data(&m_o, sizeof(m_o))
{
memset(&m_o, 0, sizeof(m_o));
}
wb_db_ohead::wb_db_ohead(wb_db *db) :
m_db(db), m_key(&m_o.oid, sizeof(m_o.oid)), m_data(&m_o, sizeof(m_o))
m_db(db), m_key(&m_oid, sizeof(m_oid)), m_data(&m_o, sizeof(m_o))
{
memset(&m_o, 0, sizeof(m_o));
}
wb_db_ohead::wb_db_ohead(wb_db *db, pwr_tOid oid) :
m_db(db), m_key(&m_o.oid, sizeof(m_o.oid)), m_data(&m_o, sizeof(m_o))
m_db(db), m_key(&m_oid, sizeof(m_oid)), m_data(&m_o, sizeof(m_o))
{
m_o.oid = oid;
memset(&m_o, 0, sizeof(m_o));
m_oid = oid;
}
wb_db_ohead::wb_db_ohead(wb_db *db, wb_db_txn *txn, pwr_tOid oid) :
m_db(db), m_key(&m_o.oid, sizeof(m_o.oid)), m_data(&m_o, sizeof(m_o))
m_db(db), m_key(&m_oid, sizeof(m_oid)), m_data(&m_o, sizeof(m_o))
{
m_o.oid = oid;
memset(&m_o, 0, sizeof(m_o));
m_oid = oid;
get(txn);
}
......@@ -187,10 +200,11 @@ wb_db_ohead::wb_db_ohead(wb_db *db, pwr_tOid oid, pwr_tCid cid,
const char *name, const char *normname,
pwr_tTime ohTime, pwr_tTime rbTime, pwr_tTime dbTime,
size_t rbSize, size_t dbSize) :
m_db(db), m_key(&m_o.oid, sizeof(m_o.oid)), m_data(&m_o, sizeof(m_o))
m_db(db), m_key(&m_oid, sizeof(m_oid)), m_data(&m_o, sizeof(m_o))
{
m_o.oid = oid;
memset(&m_o, 0, sizeof(m_o));
m_oid = m_o.oid = oid;
m_o.cid = cid;
m_o.poid = poid;
strcpy(m_o.name, name);
......@@ -212,7 +226,10 @@ wb_db_ohead::wb_db_ohead(wb_db *db, pwr_tOid oid, pwr_tCid cid,
wb_db_ohead &wb_db_ohead::get(wb_db_txn *txn)
{
m_db->m_t_ohead->get(txn, &m_key, &m_data, 0);
m_data.set_ulen(sizeof(m_o));
m_data.set_flags(DB_DBT_USERMEM);
int ret = m_db->m_t_ohead->get(txn, &m_key, &m_data, 0);
return *this;
}
......@@ -223,8 +240,11 @@ void wb_db_ohead::put(wb_db_txn *txn)
wb_db_ohead &wb_db_ohead::get(wb_db_txn *txn, pwr_tOid oid)
{
m_o.oid = oid;
m_db->m_t_ohead->get(txn, &m_key, &m_data, 0);
m_oid = oid;
m_data.set_ulen(sizeof(m_o));
m_data.set_flags(DB_DBT_USERMEM);
int ret = m_db->m_t_ohead->get(txn, &m_key, &m_data, 0);
return *this;
}
......@@ -524,6 +544,7 @@ bool wb_db::importVolume(wb_export &e)
}
}
bool wb_db::importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid,
const char *name, const char *normname,
......@@ -536,6 +557,14 @@ bool wb_db::importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
n.put(m_txn);
wb_db_class c(this, cid, oid);
c.put(m_txn);
if (oid.oix == pwr_cNOix) { // This is the volume object
wb_db_info i(this);
i.cid(cid);
i.vid(oid.vid);
i.name(name);
i.put(m_txn);
}
return true;
}
......
......@@ -54,6 +54,11 @@ public:
wb_db(pwr_tVid vid);
//~wb_db();
pwr_tCid cid() { return m_cid;}
pwr_tVid vid() { return m_vid;}
//pwr_tTime time() { return m_volume.time;}
char *volumeName() { return m_volumeName;}
pwr_tOid new_oid(wb_db_txn *txn);
void close();
......@@ -131,6 +136,7 @@ class wb_db_ohead
{
public:
db_sObject m_o;
pwr_tOid m_oid;
wb_db *m_db;
Dbt m_key;
......@@ -149,6 +155,8 @@ public:
wb_db_ohead &get(wb_db_txn *txn);
wb_db_ohead &get(wb_db_txn *txn, pwr_tOid oid);
void setDb(wb_db *db) { m_db = db;}
void put(wb_db_txn *txn);
void del(wb_db_txn *txn);
......@@ -163,9 +171,9 @@ public:
pwr_tOid aoid() { return m_o.aoid;}
pwr_tTime ohTime() { return m_o.time;}
char *name() { return m_o.name;}
const char *name() { return m_o.name;}
char *normname() {return m_o.normname;}
const char *normname() {return m_o.normname;}
size_t rbSize() { return m_o.body[0].size;}
size_t dbSize() { return m_o.body[1].size;}
......
......@@ -143,14 +143,11 @@ wb_dbs::checkObject(sOentry *oep)
switch (oep->o.cid) {
case pwr_eClass_LibHier:
if (m_volume.cid == pwr_eClass_ClassVolume)
break;
if (m_volume.cid != pwr_eClass_ClassVolume)
oep->o.flags.b.devOnly = 1;
break;
case pwr_eClass_Alias:
if (m_volume.cid == pwr_eClass_ClassVolume)
break;
if (m_volume.cid != pwr_eClass_ClassVolume)
oep->o.flags.b.isAliasClient = 1;
break;
case pwr_eClass_MountVolume:
......
......@@ -419,9 +419,9 @@ void wb_erep::loadMeta( pwr_tStatus *status)
strcat( vname, ".db");
dcli_translate_filename( vname, vname);
// wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
// vrepdb->name(vol_array[0]);
// addDbs( &sts, vrepdb);
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name(vol_array[0]);
addDbs( &sts, vrepdb);
vol_cnt++;
}
}
......
......@@ -21,6 +21,22 @@ wb_orepdb::~wb_orepdb()
{
}
void *
wb_orepdb::operator new(size_t size, wb_vrepdb *v)
{
return (void *)v->new_wb_orepdb(size);
}
#if 1
void
wb_orepdb::operator delete(void *p)
{
wb_orepdb *o = (wb_orepdb *)p;
((wb_vrepdb *)o->m_vrep)->delete_wb_orepdb(p);
}
#endif
//
// Operations declared in wb_orep
//
......@@ -29,7 +45,13 @@ pwr_tOid wb_orepdb::oid() const
{
pwr_tStatus sts;
return m_vrep->oid(&sts, (wb_orep*)this);
return m_oid;
}
pwr_tVid wb_orepdb::cid() const
{
pwr_tStatus sts;
return m_vrep->cid(&sts, (wb_orep*)this);
}
pwr_tVid wb_orepdb::vid() const
......@@ -74,6 +96,11 @@ pwr_tOid wb_orepdb::aoid() const
return m_vrep->aoid(&sts, (wb_orep*)this);
}
wb_name wb_orepdb::longName()
{
return wb_name();
}
const char * wb_orepdb::name() const
{
pwr_tStatus sts;
......
......@@ -19,6 +19,9 @@ public:
wb_orepdb(db_sObject *o);
~wb_orepdb();
void* operator new(size_t size, wb_vrepdb *v);
void operator delete(void *p);
virtual pwr_tOid oid() const;
virtual pwr_tVid vid() const;
virtual pwr_tOix oix() const;
......
......@@ -110,8 +110,8 @@ public:
virtual bool isLocal(const wb_orep *o) = 0;
pwr_tVid vid() const { return m_vid;}
pwr_tCid cid() const { return m_cid;}
pwr_tVid vid(pwr_tVid vid) { m_vid = vid;}
pwr_tCid cid(pwr_tCid cid) { m_cid = cid;}
void vid(pwr_tVid vid) { m_vid = vid;}
void cid(pwr_tCid cid) { m_cid = cid;}
virtual void name( const char *n) { strcpy( m_name, n);}
virtual const char *name() { return m_name;}
......
This diff is collapsed.
......@@ -13,6 +13,8 @@ protected:
//wb_session m_wsession;
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nSession;
unsigned int m_nRef;
......@@ -125,6 +127,10 @@ public:
#endif
void unadopt(wb_db_txn *txn, wb_db_ohead &o);
void adopt(wb_db_txn *txn, wb_db_ohead &o, wb_destination &dest);
wb_orepdb *new_wb_orepdb(size_t size);
void delete_wb_orepdb(void *p);
};
#endif
......@@ -39,6 +39,7 @@ dbs_sEnv *wb_vrepdbs::dbsenv()
m_isDbsenvLoaded = true;
strcpy(m_name, m_dbsenv.vp->name);
m_vid = m_dbsenv.vp->vid;
m_cid = m_dbsenv.vp->cid;
} else {
ep = &m_dbsenv;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment