Example #1
0
        public override int PrepareShutdown()
        {
            int result;

            var shutdownState = this.shutdownState;

            switch (shutdownState)
            {
            case ShutdownState.NotStarted:
                this.shutdownState = ShutdownState.ShuttingDown;
                /* remove event handlers when preparing shutdown, to prevent recursive issues */
                this.RemoveEventHandlers();
                new Thread(BruteForceSaveAll).Start();
                result = 1;
                break;

            case ShutdownState.ShuttingDown:
                result = 1;
                break;

            default:
                result = base.PrepareShutdown();
                break;
            }

            return(result);
        }
Example #2
0
        public bool Shutdown(bool waitForReply)
        {
            if (shutdownState == ShutdownState.Error)
            {
                return(false);
            }
            else if (shutdownState == ShutdownState.Closed)
            {
                return(true);
            }
            var ret = native_openssl_shutdown(handle);

            if (ret == 1)
            {
                shutdownState = ShutdownState.Closed;
                return(true);
            }
            if (!waitForReply)
            {
                shutdownState = ShutdownState.SentShutdown;
                return(false);
            }
            ret = native_openssl_shutdown(handle);
            if (ret != 1)
            {
                throw new IOException("Shutdown failed.");
            }
            shutdownState = ShutdownState.Closed;
            return(true);
        }
Example #3
0
 public void Cleanup()
 {
     ShutdownState = ShutdownState.Finished;
     CleanupSendState(this);
     Handle?.Dispose();
     Marshal.FreeHGlobal(SendQuicBuffers);
     SendQuicBuffers = IntPtr.Zero;
     if (StateGCHandle.IsAllocated)
     {
         StateGCHandle.Free();
     }
     ConnectionState?.RemoveStream(null);
 }
Example #4
0
 /// <summary>
 /// This is part of an attempt to stop the 'do you want to save' popups; save
 /// everything we've touched, whether or not we've set anything on it.
 /// </summary>
 private void BruteForceSaveAll()
 {
     try
     {
         /* brute force save everything. Not happy about this... */
         foreach (var syncState in this.ItemsSyncState)
         {
             this.SaveItem(syncState.OutlookItem);
         }
     }
     finally
     {
         this.shutdownState = ShutdownState.Completed;
     }
 }
Example #5
0
        bool Shutdown_internal(bool waitForReply)
        {
            Debug("SHUTDOWN: {0} {1}", shutdownState, waitForReply);
            if (shutdownState == ShutdownState.Error)
            {
                return(false);
            }
            else if (shutdownState == ShutdownState.Closed)
            {
                return(true);
            }

            try {
                var ret = native_openssl_shutdown(handle);
                Debug("SHUTDOWN #1: {0}", ret);
                if (ret == 1)
                {
                    shutdownState = ShutdownState.Closed;
                    return(true);
                }
                if (!waitForReply)
                {
                    shutdownState = ShutdownState.SentShutdown;
                    return(false);
                }
                ret = native_openssl_shutdown(handle);
                Debug("SHUTDOWN #2: {0}", ret);
                if (ret != 1)
                {
                    throw new IOException("Shutdown failed.");
                }
                shutdownState = ShutdownState.Closed;
                return(true);
            } finally {
                lockReadState = 0;
            }
        }
Example #6
0
		bool Shutdown_internal (bool waitForReply)
		{
			Debug ("SHUTDOWN: {0} {1}", shutdownState, waitForReply);
			if (shutdownState == ShutdownState.Error)
				return false;
			else if (shutdownState == ShutdownState.Closed)
				return true;

			try {
				var ret = native_openssl_shutdown (handle);
				Debug ("SHUTDOWN #1: {0}", ret);
				if (ret == 1) {
					shutdownState = ShutdownState.Closed;
					return true;
				}
				if (!waitForReply) {
					shutdownState = ShutdownState.SentShutdown;
					return false;
				}
				ret = native_openssl_shutdown (handle);
				Debug ("SHUTDOWN #2: {0}", ret);
				if (ret != 1)
					throw new IOException ("Shutdown failed.");
				shutdownState = ShutdownState.Closed;
				return true;
			} finally {
				lockReadState = 0;
			}
		}
Example #7
0
		public bool Shutdown (bool waitForReply)
		{
			if (shutdownState == ShutdownState.Error)
				return false;
			else if (shutdownState == ShutdownState.Closed)
				return true;
			var ret = native_openssl_shutdown (handle);
			if (ret == 1) {
				shutdownState = ShutdownState.Closed;
				return true;
			}
			if (!waitForReply) {
				shutdownState = ShutdownState.SentShutdown;
				return false;
			}
			ret = native_openssl_shutdown (handle);
			if (ret != 1)
				throw new IOException ("Shutdown failed.");
			shutdownState = ShutdownState.Closed;
			return true;
		}