public void SetTimeout(int timeout, TimeoutKind flags) { DbRetVal ret; lock (rscLock) { DB_TXN *txp = CheckDisposed(); ret = txp->SetTimeout(txp, unchecked ((UInt32)timeout), unchecked ((UInt32)flags)); } Util.CheckRetVal(ret); }
protected void SetBeginLsn(ref DB_LSN *lsnp) { DbRetVal ret; lock (rscLock) { DB_TXN *txp = CheckDisposed(); ret = txp->SetBeginLsnp(txp, out lsnp); } Util.CheckRetVal(ret); }
protected internal DB_TXN *CheckDisposed() { // avoid multiple volatile memory access DB_TXN *txp = this.txp; if (txp == null) { throw new ObjectDisposedException(disposedStr); } return(txp); }
void *GetPage(ref uint pageNo, DB_TXN *txp, CachePageGetFlags flags) { DbRetVal ret; void * page; lock (rscLock) { DB_MPOOLFILE *mpf = CheckDisposed(); ret = mpf->Get(mpf, ref pageNo, txp, flags, out page); } Util.CheckRetVal(ret); return(page); }
public Int64 Get(Txn txn, Int32 delta, ReadFlags flags) { if (txn != null) { lock (txn.rscLock) { DB_TXN *txp = txn.CheckDisposed(); return(Get(txp, delta, flags)); } } else { return(Get((DB_TXN *)null, delta, flags)); } }
IntPtr GetPage(ref uint pageNo, Txn txn, CachePageGetFlags flags) { if (txn != null) { lock (txn.rscLock) { DB_TXN *txp = txn.CheckDisposed(); return((IntPtr)GetPage(ref pageNo, txp, flags)); } } else { return((IntPtr)GetPage(ref pageNo, (DB_TXN *)null, flags)); } }
Int64 Get(DB_TXN *txp, Int32 delta, ReadFlags flags) { Int64 value; DbRetVal ret; lock (rscLock) { DB_SEQUENCE *seqp = CheckDisposed(); if (SeqGet == null) { throw new BdbException("Sequence must be open."); } ret = SeqGet(seqp, txp, delta, out value, unchecked ((UInt32)flags)); } Util.CheckRetVal(ret); return(value); }
DbRetVal Open(DB_TXN *txp, ref DbEntry key, OpenFlags flags) { DbRetVal ret; lock (rscLock) { DB_SEQUENCE *seqp = CheckDisposed(); fixed(byte *keyBufP = key.Buffer) { key.dbt.data = keyBufP + key.Start; ret = seqp->Open(seqp, txp, ref key.dbt, unchecked ((UInt32)flags)); } // initialize function pointer delegates SeqGet = seqp->Get; } return(ret); }
// should be run in a CER, under a lock on rscLock, and not throw exceptions DbRetVal ReleaseUnmanagedResources() { DB_TXN *txp = this.txp; if (txp == null) { return(DbRetVal.SUCCESS); } // DB_TXN->Abort() could be a lengthy call, so we call Disposed() first, and the // CER ensures that we reach DB_TXN->Abort() without external interruption. // This is OK because one must not use the handle after DB_TXN->Abort() was called, // regardless of the return value. Disposed(); DbRetVal ret = txp->Abort(txp); return(ret); }
public void Open(Txn txn, ref DbEntry key, OpenFlags flags) { DbRetVal ret; if (txn != null) { lock (txn.rscLock) { DB_TXN *txp = txn.CheckDisposed(); ret = Open(txp, ref key, flags); } } else { ret = Open((DB_TXN *)null, ref key, flags); } Util.CheckRetVal(ret); }
public void Remove(Txn txn, RemoveFlags flags) { DbRetVal ret; if (txn != null) { lock (txn.rscLock) { DB_TXN *txp = txn.CheckDisposed(); ret = Remove(txp, flags); } } else { ret = Remove((DB_TXN *)null, flags); } GC.SuppressFinalize(this); Util.CheckRetVal(ret); }
// gid must be a byte array of fixed size Const.DB_XIDDATASIZE public void Prepare(byte[] gid) { if (gid.Length != DbConst.DB_XIDDATASIZE) { string msg = string.Format("Size must be %d.", DbConst.DB_XIDDATASIZE); throw new ArgumentException(msg, "gid"); } DbRetVal ret; lock (rscLock) { DB_TXN *txp = CheckDisposed(); fixed(byte *gidp = gid) { ret = txp->Prepare(txp, gidp); } } Util.CheckRetVal(ret); }
public static Txn GetTxn(DB_TXN *txp) { if (txp == null) { return(null); } else { IntPtr gh = txp->api_internal; if (gh == IntPtr.Zero) { return(null); } else { return((Txn)((GCHandle)gh).Target); } } }
DbRetVal Remove(DB_TXN *txp, RemoveFlags flags) { DbRetVal ret; // always lock Db first, to avoid deadlock lock (db.rscLock) { lock (rscLock) { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { DB_SEQUENCE *seqp = CheckDisposed(); // DB_SEQUENCE->Remove() could be a lengthy call, so we call Disposed() first, and the // CER ensures that we reach DB_SEQUENCE->Remove() without external interruption. // This is OK because one must not use the handle after DB_SEQUENCE->Remove() was called, // regardless of the return value. Disposed(); ret = seqp->Remove(seqp, txp, unchecked ((UInt32)flags)); } } } return(ret); }
public void Discard() { DbRetVal ret; // always lock environment first, to avoid deadlocks lock (env.rscLock) { lock (rscLock) { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { DB_TXN *txp = CheckDisposed(); // DB_TXN->Discard() could be a lengthy call, so we call Disposed() first, and the // CER ensures that we reach DB_TXN->Discard() without external interruption. // This is OK because one must not use the handle after DB_TXN->Discard() was called, // regardless of the return value. Disposed(); ret = txp->Discard(txp, 0); } } } GC.SuppressFinalize(this); Util.CheckRetVal(ret); }
// assumes that env != null and txp != null! internal void Initialize(DB_TXN* txp) { this.txp = txp; txp->api_internal = (IntPtr)instanceHandle; }
void Disposed() { txp = null; // unregister with resource manager env.RemoveTransaction(this); ; }
// assumes that env != null and txp != null! internal void Initialize(DB_TXN *txp) { this.txp = txp; txp->api_internal = (IntPtr)instanceHandle; }
void Disposed() { txp = null; // unregister with resource manager env.RemoveTransaction(this);; }