diff options
author | Richard Levitte <levitte@openssl.org> | 2000-06-19 17:35:39 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2000-06-19 17:35:39 +0000 |
commit | d8c4d0e81948e5ed4a7cb60039c57bfca1d6991c (patch) | |
tree | 0c6354d0fd428d51eee8c290721743576cac14ed | |
parent | b215f70a0ee3081b99d0b45241c0b12cdcb4a97c (diff) | |
download | openssl-d8c4d0e81948e5ed4a7cb60039c57bfca1d6991c.tar.gz |
Merge of stuff from main trunk, all conflicts resolved, and addition
of dynamic lock support in the nCipher code.
-rw-r--r-- | crypto/cryptlib.c | 55 | ||||
-rw-r--r-- | crypto/crypto.h | 15 | ||||
-rw-r--r-- | doc/crypto/threads.pod | 14 | ||||
-rwxr-xr-x | util/libeay.num | 51 |
4 files changed, 109 insertions, 26 deletions
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index df90841d5a..9e78d637fc 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -123,7 +123,7 @@ static int (MS_FAR *add_lock_callback)(int *pointer,int amount, static unsigned long (MS_FAR *id_callback)(void)=NULL; static struct CRYPTO_dynlock_value *(MS_FAR *dynlock_create_callback) (const char *file,int line)=NULL; -static void (MS_FAR *dynlock_locking_callback)(int mode, +static void (MS_FAR *dynlock_lock_callback)(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line)=NULL; static void (MS_FAR *dynlock_destroy_callback)(struct CRYPTO_dynlock_value *l, const char *file,int line)=NULL; @@ -200,7 +200,11 @@ int CRYPTO_get_new_dynlockid(void) } CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK); - i=sk_CRYPTO_dynlock_push(dyn_locks,pointer); + /* First, try to find an existing empty slot */ + i=sk_CRYPTO_dynlock_find(dyn_locks,NULL); + /* If there was none, push, thereby creating a new one */ + if (i == -1) + i=sk_CRYPTO_dynlock_push(dyn_locks,pointer); CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); if (!i) @@ -273,16 +277,47 @@ struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i) return NULL; } -void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, - int line) +struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void)) + (const char *file,int line) { - return(locking_callback); + return(dynlock_create_callback); } void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line) { - return(dynlock_locking_callback); + return(dynlock_lock_callback); + } + +void (*CRYPTO_get_dynlock_destroy_callback(void)) + (struct CRYPTO_dynlock_value *l, const char *file,int line) + { + return(dynlock_destroy_callback); + } + +void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*func) + (const char *file, int line)) + { + dynlock_create_callback=func; + } + +void CRYPTO_set_dynlock_lock_callback(void (*func)(int mode, + struct CRYPTO_dynlock_value *l, const char *file, int line)) + { + dynlock_lock_callback=func; + } + +void CRYPTO_set_dynlock_destroy_callback(void (*func) + (struct CRYPTO_dynlock_value *l, const char *file, int line)) + { + dynlock_destroy_callback=func; + } + + +void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, + int line) + { + return(locking_callback); } int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, @@ -297,12 +332,6 @@ void CRYPTO_set_locking_callback(void (*func)(int mode,int type, locking_callback=func; } -void CRYPTO_set_dynlock_locking_callback(void (*func)(int mode, - struct CRYPTO_dynlock_value *l, const char *file, int line)) - { - dynlock_locking_callback=func; - } - void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, const char *file,int line)) { @@ -373,7 +402,7 @@ void CRYPTO_lock(int mode, int type, const char *file, int line) if (pointer) { - dynlock_locking_callback(mode, pointer, file, line); + dynlock_lock_callback(mode, pointer, file, line); } CRYPTO_destroy_dynlockid(i); diff --git a/crypto/crypto.h b/crypto/crypto.h index 11f75b7e3a..f538f0b67a 100644 --- a/crypto/crypto.h +++ b/crypto/crypto.h @@ -312,17 +312,16 @@ unsigned long CRYPTO_thread_id(void); const char *CRYPTO_get_lock_name(int type); int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, int line); -void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function) - (char *file, int line)); -void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function) - (int mode, struct CRYPTO_dynlock_value *l, - const char *file, int line)); -void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function) - (struct CRYPTO_dynlock_value *l, const char *file, int line)); -void CRYPTO_set_dynlock_size(int dynlock_size); + int CRYPTO_get_new_dynlockid(void); void CRYPTO_destroy_dynlockid(int i); struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); +void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); +void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); +void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); +struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); +void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); +void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- * call the latter last if you need different functions */ diff --git a/doc/crypto/threads.pod b/doc/crypto/threads.pod index a31b170806..0df1074d31 100644 --- a/doc/crypto/threads.pod +++ b/doc/crypto/threads.pod @@ -17,14 +17,15 @@ CRYPTO_set_locking_callback, CRYPTO_set_id_callback - OpenSSL thread support /* struct CRYPTO_dynlock_value needs to be defined by the user */ - typedef struct CRYPTO_dynlock_value CRYPTO_dynlock; + struct CRYPTO_dynlock_value; - void CRYPTO_set_dynlock_create_callback(CRYPTO_dynlock *(*dyn_create_function) - (char *file, int line)); + void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value * + (*dyn_create_function)(char *file, int line)); void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function) - (int mode, CRYPTO_dynlock *l, const char *file, int line)); + (int mode, struct CRYPTO_dynlock_value *l, + const char *file, int line)); void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function) - (CRYPTO_dynlock *l, const char *file, int line)); + (struct CRYPTO_dynlock_value *l, const char *file, int line)); int CRYPTO_get_new_dynlockid(void); @@ -115,6 +116,9 @@ You can find out if OpenSSL was configured with thread support: // no thread support #endif +Also, dynamic locks are currently not used internally by OpenSSL, but +may do so in the future. + =head1 EXAMPLES B<crypto/threads/mttest.c> shows examples of the callback functions on diff --git a/util/libeay.num b/util/libeay.num index 5500838638..c73ca9b407 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -1838,3 +1838,54 @@ CRYPTO_destroy_dynlockid 2413 CRYPTO_set_dynlock_size 2414 CRYPTO_set_dynlock_create_callback 2415 CRYPTO_set_dynlock_lock_callback 2416 +CRYPTO_get_dynlock_lock_callback 2417 +CRYPTO_get_dynlock_destroy_callback 2418 +CRYPTO_get_dynlock_value 2419 +CRYPTO_get_dynlock_create_callback 2420 +ERR_load_ENGINE_strings 2421 +ENGINE_set_DSA 2422 +ENGINE_get_default_RSA 2423 +ENGINE_get_BN_mod_exp 2424 +DSA_get_default_openssl_method 2425 +ENGINE_set_DH 2426 +ENGINE_set_default_BN_mod_exp_crt 2427 +ENGINE_init 2428 +DH_get_default_openssl_method 2429 +RSA_set_default_openssl_method 2430 +ENGINE_finish 2431 +ENGINE_get_DH 2432 +ENGINE_set_default_DSA 2433 +ENGINE_get_name 2434 +ENGINE_get_last 2435 +ENGINE_get_prev 2436 +ENGINE_get_default_DH 2437 +ENGINE_get_RSA 2438 +ENGINE_set_default 2439 +ENGINE_get_RAND 2440 +ENGINE_get_first 2441 +ENGINE_by_id 2442 +ENGINE_get_default_BN_mod_exp_crt 2443 +RSA_get_default_openssl_method 2444 +ENGINE_set_RSA 2445 +ENGINE_set_default_RAND 2446 +ENGINE_set_BN_mod_exp 2447 +ENGINE_remove 2448 +ENGINE_free 2449 +ENGINE_get_BN_mod_exp_crt 2450 +ENGINE_get_next 2451 +ENGINE_set_name 2452 +ENGINE_get_default_DSA 2453 +ENGINE_set_default_BN_mod_exp 2454 +ENGINE_set_default_RSA 2455 +ENGINE_get_default_RAND 2456 +ENGINE_get_default_BN_mod_exp 2457 +ENGINE_set_RAND 2458 +ENGINE_set_id 2459 +ENGINE_set_BN_mod_exp_crt 2460 +ENGINE_set_default_DH 2461 +ENGINE_new 2462 +ENGINE_get_id 2463 +DSA_set_default_openssl_method 2464 +ENGINE_add 2465 +DH_set_default_openssl_method 2466 +ENGINE_get_DSA 2467 |