disabling_thread=0; CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
num_disable--; if (num_disable == 0) { mh_mode|=CRYPTO_MEM_CHECK_ENABLE; CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2); }
int CRYPTO_mem_ctrl(int mode)	{	int ret=mh_mode;	CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);	switch (mode)		{	/* for applications: */	case CRYPTO_MEM_CHECK_ON: /* aka MemCheck_start() */		mh_mode = CRYPTO_MEM_CHECK_ON|CRYPTO_MEM_CHECK_ENABLE;		disabling_thread = 0;		break;	case CRYPTO_MEM_CHECK_OFF: /* aka MemCheck_stop() */		mh_mode = 0;		disabling_thread = 0;		break;	/* switch off temporarily (for library-internal use): */	case CRYPTO_MEM_CHECK_DISABLE: /* aka MemCheck_off() */		if (mh_mode & CRYPTO_MEM_CHECK_ON)			{			mh_mode&= ~CRYPTO_MEM_CHECK_ENABLE;			if (disabling_thread != CRYPTO_thread_id()) /* otherwise we already have the MALLOC2 lock */				{				/* Long-time lock CRYPTO_LOCK_MALLOC2 must not be claimed while				 * we're holding CRYPTO_LOCK_MALLOC, or we'll deadlock if				 * somebody else holds CRYPTO_LOCK_MALLOC2 (and cannot release				 * it because we block entry to this function).				 * Give them a chance, first, and then claim the locks in				 * appropriate order (long-time lock first).				 */				CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);				/* Note that after we have waited for CRYPTO_LOCK_MALLOC2				 * and CRYPTO_LOCK_MALLOC, we'll still be in the right				 * "case" and "if" branch because MemCheck_start and				 * MemCheck_stop may never be used while there are multiple				 * OpenSSL threads. */				CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);				CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);				disabling_thread=CRYPTO_thread_id();				}			}		break;	case CRYPTO_MEM_CHECK_ENABLE: /* aka MemCheck_on() */		if (mh_mode & CRYPTO_MEM_CHECK_ON)			{			mh_mode|=CRYPTO_MEM_CHECK_ENABLE;			if (disabling_thread != 0)				{				disabling_thread=0;				CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);				}			}		break;	default:		break;		}	CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);	return(ret);	}