Check-in [10e3f2e20c]
Overview
Comment:Ensure initialization happens only once even with unthreaded Tcl
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tls-1-7
Files: files | file ages | folders
SHA1: 10e3f2e20c0067cd73e6f31c2c4276ee2880ab14
User & Date: rkeene on 2016-12-02 16:41:00
Other Links: branch diff | manifest | tags
Context
2016-12-02
18:52
Updated to include a copy of the autoconf macros we use in our version control, autogen will update them check-in: f755cb09a6 user: rkeene tags: tls-1-7
16:41
Ensure initialization happens only once even with unthreaded Tcl check-in: 10e3f2e20c user: rkeene tags: tls-1-7
16:28
For unsupported options do even less check-in: 3842146243 user: rkeene tags: tls-1-7
Changes
Modified tls.c from [63f1a729cf] to [31dba4da9e].
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746


1747

1748
1749
1750
1751
1752
1753
1754
 *------------------------------------------------------*
 */
static int TlsLibInit (void) {
    static int initialized = 0;
    int i;
    char rnd_seed[16] = "GrzSlplKqUdnnzP!";	/* 16 bytes */
    int status=TCL_OK;
#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
    size_t num_locks;

    if (initialized) {
        return status;
    }
	Tcl_MutexLock(&init_mx);
	if (!initialized) {
	    initialized = 1;
#else


       {

#endif

	    if (CRYPTO_set_mem_functions((void *(*)(size_t))Tcl_Alloc,
					 (void *(*)(void *, size_t))Tcl_Realloc,
					 (void(*)(void *))Tcl_Free) == 0) {
	       /* Not using Tcl's mem functions ... not critical */
	    }







<
<




<
<
|
|
>
>
|
>







1730
1731
1732
1733
1734
1735
1736


1737
1738
1739
1740


1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
 *------------------------------------------------------*
 */
static int TlsLibInit (void) {
    static int initialized = 0;
    int i;
    char rnd_seed[16] = "GrzSlplKqUdnnzP!";	/* 16 bytes */
    int status=TCL_OK;



    if (initialized) {
        return status;
    }


    initialized = 1;

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
    size_t num_locks;

    Tcl_MutexLock(&init_mx);
#endif

	    if (CRYPTO_set_mem_functions((void *(*)(size_t))Tcl_Alloc,
					 (void *(*)(void *, size_t))Tcl_Realloc,
					 (void(*)(void *))Tcl_Free) == 0) {
	       /* Not using Tcl's mem functions ... not critical */
	    }
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
	    srand((unsigned int) time((time_t *) NULL));
	    do {
		for (i = 0; i < 16; i++) {
		    rnd_seed[i] = 1 + (char) (255.0 * rand()/(RAND_MAX+1.0));
		}
		RAND_seed(rnd_seed, sizeof(rnd_seed));
	    } while (RAND_status() != 1);
	}

done:

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
	Tcl_MutexUnlock(&init_mx);
#endif
    return status;
}







<
<







1784
1785
1786
1787
1788
1789
1790


1791
1792
1793
1794
1795
1796
1797
	    srand((unsigned int) time((time_t *) NULL));
	    do {
		for (i = 0; i < 16; i++) {
		    rnd_seed[i] = 1 + (char) (255.0 * rand()/(RAND_MAX+1.0));
		}
		RAND_seed(rnd_seed, sizeof(rnd_seed));
	    } while (RAND_status() != 1);


done:

#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
	Tcl_MutexUnlock(&init_mx);
#endif
    return status;
}