[sr-dev] git:3.3: tls: set function to return the id

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 1 21:57:03 CEST 2012


Module: sip-router
Branch: 3.3
Commit: 5f8405f577d66069fde48202862f06cac432139b
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5f8405f577d66069fde48202862f06cac432139b

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Jul 18 19:00:38 2012 +0200

tls: set function to return the id

- starting with v1.0.0 openssl does not use anymore getpid(), but address
  of errno which can point to same virtual address in a multi-process
  application
- for refrence http://www.openssl.org/docs/crypto/threads.html
- credits to Jijo on sr-dev mailing list
(cherry picked from commit 0615826fe602c5183fbc7be7c51de5eb5eb7223c)

---

 modules/tls/tls_locking.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/tls/tls_locking.c b/modules/tls/tls_locking.c
index 86bda17..d85b14c 100644
--- a/modules/tls/tls_locking.c
+++ b/modules/tls/tls_locking.c
@@ -130,6 +130,10 @@ void tls_destroy_locks()
 }
 
 
+unsigned long sr_ssl_id_f()
+{
+	return my_pid();
+}
 
 /* returns -1 on error, 0 on success */
 int tls_init_locks()
@@ -163,10 +167,13 @@ int tls_init_locks()
 	CRYPTO_set_dynlock_lock_callback(dyn_lock_f);
 	CRYPTO_set_dynlock_destroy_callback(dyn_destroy_f);
 	
-	/* thread id callback: not needed because ser doesn't use thread and
-	 * openssl already uses getpid() (by default)
-	 * CRYPTO_set_id_callback(id_f);
+	/* starting with v1.0.0 openssl does not use anymore getpid(), but address
+	 * of errno which can point to same virtual address in a multi-process
+	 * application
+	 * - for refrence http://www.openssl.org/docs/crypto/threads.html
 	 */
+	CRYPTO_set_id_callback(sr_ssl_id_f);
+
 	/* atomic add -- since for now we don't have atomic_add
 	 *  (only atomic_inc), fallback to the default use-locks mode
 	 * CRYPTO_set_add_lock_callback(atomic_add_f);




More information about the sr-dev mailing list