// creates a physical connection internal SNIHandle( SNINativeMethodWrapper.ConsumerInfo myInfo, string serverName, byte[] spnBuffer, bool ignoreSniOpenTimeout, int timeout, out byte[] instanceName, bool flushCache, bool fSync, bool fParallel, TransparentNetworkResolutionState transparentNetworkResolutionState, int totalTimeout) : base(IntPtr.Zero, true) { RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { _fSync = fSync; instanceName = new byte[256]; // Size as specified by netlibs. if (ignoreSniOpenTimeout) { // timeout = Timeout.Infinite; // -1 == native SNIOPEN_TIMEOUT_VALUE / INFINITE } int transparentNetworkResolutionStateNo = (int)transparentNetworkResolutionState; _status = SNINativeMethodWrapper.SNIOpenSyncEx(myInfo, serverName, ref base.handle, spnBuffer, instanceName, flushCache, fSync, timeout, fParallel, transparentNetworkResolutionStateNo, totalTimeout, ADP.IsAzureSqlServerEndpoint(serverName)); } }
// constructs SNI Handle for MARS session internal SNIHandle(SNINativeMethodWrapper.ConsumerInfo myInfo, SNIHandle parent) : base(IntPtr.Zero, true) { RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { _status = SNINativeMethodWrapper.SNIOpenMarsSession(myInfo, parent, ref base.handle, parent._fSync); } }
internal override void CreatePhysicalSNIHandle(string serverName, bool ignoreSniOpenTimeout, long timerExpire, out byte[] instanceName, ref byte[] spnBuffer, bool flushCache, bool async, bool fParallel, bool isIntegratedSecurity) { // We assume that the loadSSPILibrary has been called already. now allocate proper length of buffer spnBuffer = null; if (isIntegratedSecurity) { // now allocate proper length of buffer spnBuffer = new byte[SNINativeMethodWrapper.SniMaxComposedSpnLength]; } SNINativeMethodWrapper.ConsumerInfo myInfo = CreateConsumerInfo(async); // Translate to SNI timeout values (Int32 milliseconds) long timeout; if (long.MaxValue == timerExpire) { timeout = int.MaxValue; } else { timeout = ADP.TimerRemainingMilliseconds(timerExpire); if (timeout > int.MaxValue) { timeout = int.MaxValue; } else if (0 > timeout) { timeout = 0; } } _sessionHandle = new SNIHandle(myInfo, serverName, spnBuffer, ignoreSniOpenTimeout, checked ((int)timeout), out instanceName, flushCache, !async, fParallel); }
// creates a physical connection internal SNIHandle( SNINativeMethodWrapper.ConsumerInfo myInfo, string serverName, byte[] spnBuffer, bool ignoreSniOpenTimeout, int timeout, out byte[] instanceName, bool flushCache, bool fSync, bool fParallel) : base(IntPtr.Zero, true) { try { } finally { _fSync = fSync; instanceName = new byte[256]; // Size as specified by netlibs. if (ignoreSniOpenTimeout) { timeout = Timeout.Infinite; // -1 == native SNIOPEN_TIMEOUT_VALUE / INFINITE } _status = SNINativeMethodWrapper.SNIOpenSyncEx(myInfo, serverName, ref base.handle, spnBuffer, instanceName, flushCache, fSync, timeout, fParallel); } }
// constructs SNI Handle for MARS session internal SNIHandle(SNINativeMethodWrapper.ConsumerInfo myInfo, SNIHandle parent) : base(IntPtr.Zero, true) { try { } finally { _status = SNINativeMethodWrapper.SNIOpenMarsSession(myInfo, parent, ref base.handle, parent._fSync); } }
protected override void CreateSessionHandle(TdsParserStateObject physicalConnection, bool async) { Debug.Assert(physicalConnection is TdsParserStateObjectNative, "Expected a stateObject of type " + this.GetType()); TdsParserStateObjectNative nativeSNIObject = physicalConnection as TdsParserStateObjectNative; SNINativeMethodWrapper.ConsumerInfo myInfo = CreateConsumerInfo(async); _sessionHandle = new SNIHandle(myInfo, nativeSNIObject.Handle); }
internal SNIHandle(SNINativeMethodWrapper.ConsumerInfo myInfo, string serverName, SNIHandle parent) : base(IntPtr.Zero, true) { this._status = uint.MaxValue; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { this._status = SNINativeMethodWrapper.SNIOpen(myInfo, serverName, parent, ref this.handle, parent._fSync); } }
private SNINativeMethodWrapper.ConsumerInfo CreateConsumerInfo(bool async) { SNINativeMethodWrapper.ConsumerInfo myInfo = default; Debug.Assert(_outBuff.Length == _inBuff.Length, "Unexpected unequal buffers."); myInfo.defaultBufferSize = _outBuff.Length; // Obtain packet size from outBuff size. if (async) { myInfo.readDelegate = SNILoadHandle.SingletonInstance.ReadAsyncCallbackDispatcher; myInfo.writeDelegate = SNILoadHandle.SingletonInstance.WriteAsyncCallbackDispatcher; _gcHandle = GCHandle.Alloc(this, GCHandleType.Normal); myInfo.key = (IntPtr)_gcHandle; } return(myInfo); }
internal SNIHandle(SNINativeMethodWrapper.ConsumerInfo myInfo, string serverName, byte[] spnBuffer, bool ignoreSniOpenTimeout, int timeout, out byte[] instanceName, bool flushCache, bool fSync, bool fParallel) : base(IntPtr.Zero, true) { this._status = uint.MaxValue; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { this._fSync = fSync; instanceName = new byte[0x100]; if (ignoreSniOpenTimeout) { timeout = -1; } this._status = SNINativeMethodWrapper.SNIOpenSyncEx(myInfo, serverName, ref this.handle, spnBuffer, instanceName, flushCache, fSync, timeout, fParallel); } }
private SNINativeMethodWrapper.ConsumerInfo CreateConsumerInfo(bool async) { SNINativeMethodWrapper.ConsumerInfo myInfo = new SNINativeMethodWrapper.ConsumerInfo(); Debug.Assert(_outBuff.Length == _inBuff.Length, "Unexpected unequal buffers."); myInfo.defaultBufferSize = _outBuff.Length; // Obtain packet size from outBuff size. if (async) { myInfo.readDelegate = SNILoadHandle.SingletonInstance.ReadAsyncCallbackDispatcher; myInfo.writeDelegate = SNILoadHandle.SingletonInstance.WriteAsyncCallbackDispatcher; _gcHandle = GCHandle.Alloc(this, GCHandleType.Normal); myInfo.key = (IntPtr)_gcHandle; } return myInfo; }
private SNINativeMethodWrapper.ConsumerInfo CreateConsumerInfo(bool async) { SNINativeMethodWrapper.ConsumerInfo info = new SNINativeMethodWrapper.ConsumerInfo { defaultBufferSize = this._outBuff.Length }; if (async) { info.readDelegate = SNILoadHandle.SingletonInstance.ReadAsyncCallbackDispatcher; info.writeDelegate = SNILoadHandle.SingletonInstance.WriteAsyncCallbackDispatcher; this._gcHandle = GCHandle.Alloc(this, GCHandleType.Normal); info.key = (IntPtr) this._gcHandle; } return info; }