Check-in [e5c9bfe50f]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merged in trunk
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-fix-io-layer
Files: files | file ages | folders
SHA1:e5c9bfe50fb4ebeb1ee1d7c3037a716123d830e2
User & Date: rkeene 2016-12-13 03:21:09
Context
2016-12-13
03:27
Silence warnings about ignoring this return value by explicitly ignoring it check-in: 41f972bfbf user: rkeene tags: wip-fix-io-layer
03:21
Merged in trunk check-in: e5c9bfe50f user: rkeene tags: wip-fix-io-layer
03:20
Updated to deal with locking slightly better, maybe check-in: 387697ce68 user: rkeene tags: trunk
2016-12-12
22:40
Merged in trunk check-in: 83a3aff031 user: rkeene tags: wip-fix-io-layer
Changes

Changes to tls.c.

116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
....
1723
1724
1725
1726
1727
1728
1729

1730
1731
1732
1733
1734
1735
1736
....
1750
1751
1752
1753
1754
1755
1756



1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
 * Threaded operation requires locking callbacks
 * Based from /crypto/cryptlib.c of OpenSSL and NSOpenSSL.
 */

static Tcl_Mutex *locks = NULL;
static Tcl_Mutex init_mx;

static void          CryptoThreadLockCallback(int mode, int n, const char *file, int line);
static unsigned long CryptoThreadIdCallback(void);

static void CryptoThreadLockCallback(int mode, int n, const char *file, int line) {
	if (mode & CRYPTO_LOCK) {
		Tcl_MutexLock(&locks[n]);
	} else {
		Tcl_MutexUnlock(&locks[n]);
	}
}

static unsigned long CryptoThreadIdCallback(void) {
	return (unsigned long) Tcl_GetCurrentThread();
}
#endif /* OPENSSL_THREADS */
#endif /* TCL_THREADS */

 
/*
................................................................................
		if (!initialized) {
			dprintf("Asked to uninitialize, but we are not initialized");

			return(TCL_OK);
		}

		dprintf("Asked to uninitialize");

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
		Tcl_MutexLock(&init_mx);

		CRYPTO_set_locking_callback(NULL);
		CRYPTO_set_id_callback(NULL);

		if (locks) {
................................................................................
	if (initialized) {
		dprintf("Called, but using cached value");
		return(status);
	}

	dprintf("Called");




	initialized = 1;

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
	Tcl_MutexLock(&init_mx);

	num_locks = CRYPTO_num_locks();
	locks = malloc(sizeof(*locks) * num_locks);

	CRYPTO_set_locking_callback(CryptoThreadLockCallback);
	CRYPTO_set_id_callback(CryptoThreadIdCallback);
#endif








<
<
<
|







|







 







>







 







>
>
>



<
<







116
117
118
119
120
121
122



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
....
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
....
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760


1761
1762
1763
1764
1765
1766
1767
 * Threaded operation requires locking callbacks
 * Based from /crypto/cryptlib.c of OpenSSL and NSOpenSSL.
 */

static Tcl_Mutex *locks = NULL;
static Tcl_Mutex init_mx;




void CryptoThreadLockCallback(int mode, int n, const char *file, int line) {
	if (mode & CRYPTO_LOCK) {
		Tcl_MutexLock(&locks[n]);
	} else {
		Tcl_MutexUnlock(&locks[n]);
	}
}

unsigned long CryptoThreadIdCallback(void) {
	return (unsigned long) Tcl_GetCurrentThread();
}
#endif /* OPENSSL_THREADS */
#endif /* TCL_THREADS */

 
/*
................................................................................
		if (!initialized) {
			dprintf("Asked to uninitialize, but we are not initialized");

			return(TCL_OK);
		}

		dprintf("Asked to uninitialize");

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
		Tcl_MutexLock(&init_mx);

		CRYPTO_set_locking_callback(NULL);
		CRYPTO_set_id_callback(NULL);

		if (locks) {
................................................................................
	if (initialized) {
		dprintf("Called, but using cached value");
		return(status);
	}

	dprintf("Called");

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
	Tcl_MutexLock(&init_mx);
#endif
	initialized = 1;

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)


	num_locks = CRYPTO_num_locks();
	locks = malloc(sizeof(*locks) * num_locks);

	CRYPTO_set_locking_callback(CryptoThreadLockCallback);
	CRYPTO_set_id_callback(CryptoThreadIdCallback);
#endif