- Remo Inverardi noticed that ENGINEs don't have an "up_ref" function in the
authorGeoff Thorpe <geoff@openssl.org>
Wed, 16 Oct 2002 01:32:46 +0000 (01:32 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Wed, 16 Oct 2002 01:32:46 +0000 (01:32 +0000)
normal 'structural' case (ENGINE_init() satisfies this in the less normal
'functional' case). This change provides such a function.

- Correct some "read" locks that should actually be "write" locks.

- make update.

crypto/engine/eng_err.c
crypto/engine/eng_list.c
crypto/engine/engine.h
util/libeay.num

index f6c56303959ab80acfa353dc0853b461c41a0a7a..814d95ee3283472968f88e73a843798e2e5a2424 100644 (file)
@@ -1,6 +1,6 @@
 /* crypto/engine/eng_err.c */
 /* ====================================================================
- * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2002 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -96,6 +96,7 @@ static ERR_STRING_DATA ENGINE_str_functs[]=
 {ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0),       "ENGINE_set_name"},
 {ERR_PACK(0,ENGINE_F_ENGINE_TABLE_REGISTER,0), "ENGINE_TABLE_REGISTER"},
 {ERR_PACK(0,ENGINE_F_ENGINE_UNLOAD_KEY,0),     "ENGINE_UNLOAD_KEY"},
+{ERR_PACK(0,ENGINE_F_ENGINE_UP_REF,0), "ENGINE_up_ref"},
 {ERR_PACK(0,ENGINE_F_INT_CTRL_HELPER,0),       "INT_CTRL_HELPER"},
 {ERR_PACK(0,ENGINE_F_INT_ENGINE_CONFIGURE,0),  "INT_ENGINE_CONFIGURE"},
 {ERR_PACK(0,ENGINE_F_LOG_MESSAGE,0),   "LOG_MESSAGE"},
index 0c220558e78592e741e6323e669ce5783c036892..1cc3217f4cc1bc85f06d603aa3c74a950ae399f8 100644 (file)
@@ -191,14 +191,14 @@ ENGINE *ENGINE_get_first(void)
        {
        ENGINE *ret;
 
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        ret = engine_list_head;
        if(ret)
                {
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        return ret;
        }
 
@@ -206,14 +206,14 @@ ENGINE *ENGINE_get_last(void)
        {
        ENGINE *ret;
 
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
-               ret = engine_list_tail;
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
+       ret = engine_list_tail;
        if(ret)
                {
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        return ret;
        }
 
@@ -227,7 +227,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
                        ERR_R_PASSED_NULL_PARAMETER);
                return 0;
                }
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        ret = e->next;
        if(ret)
                {
@@ -235,7 +235,7 @@ ENGINE *ENGINE_get_next(ENGINE *e)
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        /* Release the structural reference to the previous ENGINE */
        ENGINE_free(e);
        return ret;
@@ -250,7 +250,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
                        ERR_R_PASSED_NULL_PARAMETER);
                return 0;
                }
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        ret = e->prev;
        if(ret)
                {
@@ -258,7 +258,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
                ret->struct_ref++;
                engine_ref_debug(ret, 0, 1)
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        /* Release the structural reference to the previous ENGINE */
        ENGINE_free(e);
        return ret;
@@ -346,7 +346,7 @@ ENGINE *ENGINE_by_id(const char *id)
                        ERR_R_PASSED_NULL_PARAMETER);
                return NULL;
                }
-       CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_lock(CRYPTO_LOCK_ENGINE);
        iterator = engine_list_head;
        while(iterator && (strcmp(id, iterator->id) != 0))
                iterator = iterator->next;
@@ -372,7 +372,7 @@ ENGINE *ENGINE_by_id(const char *id)
                        engine_ref_debug(iterator, 0, 1)
                        }
                }
-       CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
+       CRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);
        if(iterator == NULL)
                {
                ENGINEerr(ENGINE_F_ENGINE_BY_ID,
@@ -381,3 +381,14 @@ ENGINE *ENGINE_by_id(const char *id)
                }
        return iterator;
        }
+
+int ENGINE_up_ref(ENGINE *e)
+       {
+       if (e == NULL)
+               {
+               ENGINEerr(ENGINE_F_ENGINE_UP_REF,ERR_R_PASSED_NULL_PARAMETER);
+               return 0;
+               }
+       CRYPTO_add(&e->struct_ref,1,CRYPTO_LOCK_ENGINE);
+       return 1;
+       }
index 9bed7cdbd25e4b9f0a35508f1255d9b0d45c09ff..10e744417225986e5943cc0cd1908a1a379d0426 100644 (file)
@@ -406,6 +406,7 @@ int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg,
  * compatibility! */
 ENGINE *ENGINE_new(void);
 int ENGINE_free(ENGINE *e);
+int ENGINE_up_ref(ENGINE *e);
 int ENGINE_set_id(ENGINE *e, const char *id);
 int ENGINE_set_name(ENGINE *e, const char *name);
 int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
@@ -662,6 +663,7 @@ void ERR_load_ENGINE_strings(void);
 #define ENGINE_F_ENGINE_SET_NAME                        130
 #define ENGINE_F_ENGINE_TABLE_REGISTER                  184
 #define ENGINE_F_ENGINE_UNLOAD_KEY                      152
+#define ENGINE_F_ENGINE_UP_REF                          190
 #define ENGINE_F_INT_CTRL_HELPER                        172
 #define ENGINE_F_INT_ENGINE_CONFIGURE                   188
 #define ENGINE_F_LOG_MESSAGE                            141
index 3e328a71362996148ca141da2393c4072e0eddb1..439f5b2153100b6c32e66ac817c74b6e9950ec96 100755 (executable)
@@ -2793,3 +2793,4 @@ ASN1_UNIVERSALSTRING_it                 3234      EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTI
 d2i_ASN1_UNIVERSALSTRING                3235   EXIST::FUNCTION:
 EVP_des_ede3_ecb                        3236   EXIST::FUNCTION:DES
 X509_REQ_print_ex                       3237   EXIST::FUNCTION:BIO
+ENGINE_up_ref                           3238   EXIST::FUNCTION: