// when overriding, call base method at end (using finally clause) protected internal virtual void Dispose(bool disposing) { lock (rscLock) { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { releaseVal = ReleaseUnmanagedResources(); } } }
public static string DotNetStr(DbRetVal ret) { if (ret > DotNetLowError && ret <= (DotNetLowError + dotNetStr.Length)) { return(dotNetStr[(int)ret - (int)DotNetLowError - 1]); } else { return(UnknownStr(ret)); } }
// should be run in a CER, under a lock on rscLock, and not throw exceptions DbRetVal ReleaseUnmanagedResources() { DB_LOGC *logcp = this.logcp; if (logcp == null) { return(DbRetVal.SUCCESS); } // DB_LOGC->Close() could be a lengthy call, so we call Disposed() first, and the // CER ensures that we reach DB_LOGC->Close() without external interruption. // This is OK because one must not use the handle after DB_LOGC->Close() was called, // regardless of the return value. Disposed(); DbRetVal ret = logcp->Close(logcp, 0); return(ret); }
public SequenceStats GetStats(StatFlags flags) { SequenceStats value; DB_SEQUENCE_STAT *sp; lock (rscLock) { DB_SEQUENCE *seqp = CheckDisposed(); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { DbRetVal ret = seqp->Stat(seqp, out sp, unchecked ((UInt32)flags)); Util.CheckRetVal(ret); value.seqStats = *sp; LibDb.os_ufree(null, sp); } } return(value); }
public static void CheckRetVal(DbRetVal ret) { if (ret != DbRetVal.SUCCESS) { string errStr; if (ret > BdbLowError) { errStr = LibDb.db_strerror(ret); } else if (ret > DotNetLowError) { errStr = DotNetStr(ret); } else { errStr = UnknownStr(ret); } throw new BdbException(ret, errStr); } }
// should be run in a CER, under a lock on rscLock, and not throw exceptions DbRetVal ReleaseUnmanagedResources() { // don't touch the handle if this instance is owned by a database if (env == null) { return(DbRetVal.SUCCESS); } DB_MPOOLFILE *mpf = this.mpf; if (mpf == null) { return(DbRetVal.SUCCESS); } // DB_MPOOLFILE->Close() could be a lengthy call, so we call Disposed() first, and the // CER ensures that we reach DB_MPOOLFILE->Close() without external interruption. // This is OK because one must not use the handle after DB_MPOOLFILE->Close() was called, // regardless of the return value. Disposed(); DbRetVal ret = mpf->Close(mpf, 0); return(ret); }
public static string UnknownStr(DbRetVal ret) { return(string.Format("Unknown error code: {0}.", ret)); }
public LockException(DbRetVal error, int failIndex, string message) : base(error, message) { this.failIndex = failIndex; }
public LockException(DbRetVal error, int failIndex) : base(error) { this.failIndex = failIndex; }
public BdbException(DbRetVal error, string message) : base(message) { this.error = error; }
public BdbException(DbRetVal error) { this.error = error; }
public static string db_strerror(DbRetVal error) { IntPtr errStr = _db_strerror((int)error); return Marshal.PtrToStringAnsi(errStr); }
// when overriding, call base method at end (using finally clause) protected virtual void Dispose(bool disposing) { lock (rscLock) { RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { DisposeDependents(disposing); releaseVal = ReleaseUnmanagedResources(); } if (instanceHandle.IsAllocated) instanceHandle.Free(); } }
private void ThrowLockException(DbRetVal ret, int failedIndx) { string errStr; if (ret > Util.BdbLowError) errStr = LibDb.db_strerror(ret); else if (ret > Util.DotNetLowError) errStr = Util.DotNetStr(ret); else errStr = Util.UnknownStr(ret); throw new LockException(ret, failedIndx, errStr); }