Changeset 5139
- Timestamp:
- 05/01/11 00:12:34 (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-http-helpers.c
r5134 r5139 724 724 } 725 725 726 #ifdef WITH_SSL 727 /* Locking functions for SSL multithreading */ 728 static pthread_mutex_t *lock_cs; 729 struct CRYPTO_dynlock_value{ 730 pthread_mutex_t mutex; 731 }; 732 733 uintptr_t SSL_id_function(void){ 734 return ((uintptr_t) pthread_self()); 735 } 736 737 void SSL_locking_function(int32_t mode, int32_t type, const char *file, int32_t line){ 738 if (mode & CRYPTO_LOCK) { 739 pthread_mutex_lock(&lock_cs[type]); 740 } else { 741 pthread_mutex_unlock(&lock_cs[type]); 742 } 743 // just to remove compiler warnings... 744 if(file || line) return; 745 } 746 747 struct CRYPTO_dynlock_value *SSL_dyn_create_function(const char *file, int line){ 748 struct CRYPTO_dynlock_value *value; 749 if(!cs_malloc(&value, sizeof(struct CRYPTO_dynlock_value), -1)) return (NULL); 750 pthread_mutex_init(&value->mutex, NULL); 751 // just to remove compiler warnings... 752 if(file || line) return value; 753 return value; 754 } 755 756 void SSL_dyn_lock_function(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line){ 757 if (mode & CRYPTO_LOCK) { 758 pthread_mutex_lock(&l->mutex); 759 } else { 760 pthread_mutex_unlock(&l->mutex); 761 } 762 // just to remove compiler warnings... 763 if(file || line) return; 764 } 765 766 void SSL_dyn_destroy_function(struct CRYPTO_dynlock_value *l, const char *file, int line){ 767 pthread_mutex_destroy(&l->mutex); 768 free(l); 769 // just to remove compiler warnings... 770 if(file || line) return; 771 } 726 772 #endif 773 #endif -
trunk/oscam-http.c
r5133 r5139 3398 3398 3399 3399 static const char *cs_cert="oscam.pem"; 3400 3401 // set locking callbacks for SSL 3402 int32_t i, num = CRYPTO_num_locks(); 3403 lock_cs = (pthread_mutex_t*) OPENSSL_malloc(num * sizeof(pthread_mutex_t)); 3404 3405 for (i = 0; i < num; ++i) { 3406 pthread_mutex_init(&lock_cs[i], NULL); 3407 } 3408 /* static lock callbacks */ 3409 CRYPTO_set_id_callback(SSL_id_function); 3410 CRYPTO_set_locking_callback(SSL_locking_function); 3411 /* dynamic lock callbacks */ 3412 CRYPTO_set_dynlock_create_callback(SSL_dyn_create_function); 3413 CRYPTO_set_dynlock_lock_callback(SSL_dyn_lock_function); 3414 CRYPTO_set_dynlock_destroy_callback(SSL_dyn_destroy_function); 3400 3415 3401 3416 meth = SSLv23_server_method(); … … 3599 3614 } 3600 3615 #ifdef WITH_SSL 3601 if (cfg.http_use_ssl) 3616 if (cfg.http_use_ssl){ 3617 int32_t i, num = CRYPTO_num_locks();; 3602 3618 SSL_CTX_free(ctx); 3619 CRYPTO_set_dynlock_create_callback(NULL); 3620 CRYPTO_set_dynlock_lock_callback(NULL); 3621 CRYPTO_set_dynlock_destroy_callback(NULL); 3622 CRYPTO_set_locking_callback(NULL); 3623 CRYPTO_set_id_callback(NULL); 3624 for (i = 0; i < num; ++i) { 3625 pthread_mutex_destroy(&lock_cs[i]); 3626 } 3627 OPENSSL_free(lock_cs); 3628 lock_cs = NULL; 3629 } 3603 3630 #endif 3604 3631 cs_log("HTTP Server: Shutdown requested.");
Note:
See TracChangeset
for help on using the changeset viewer.