@@ -139,26 +139,20 @@ static mi_response_t *tls_trace_mi_1(const mi_params_t *params,
139
139
140
140
trace_dest t_dst ;
141
141
142
- #ifndef NO_SSL_GLOBAL_LOCK
143
- gen_lock_t * ssl_global_lock ;
144
- #else
145
- #define ssl_global_lock NULL
146
- #endif
147
-
148
142
static int w_tls_blocking_write (struct tcp_connection * c , int fd , const char * buf ,
149
143
size_t len )
150
144
{
151
145
int ret ;
152
146
153
147
lock_get (& c -> write_lock );
154
148
ret = tls_blocking_write (c , fd , buf , len ,
155
- tls_handshake_tout , tls_send_tout , t_dst , ssl_global_lock );
149
+ tls_handshake_tout , tls_send_tout , t_dst , & tls_mgm_api );
156
150
lock_release (& c -> write_lock );
157
151
return ret ;
158
152
}
159
153
160
154
static int tls_write_on_socket (struct tcp_connection * c , int fd ,
161
- char * buf , int len , gen_lock_t * ssl_global_lock )
155
+ char * buf , int len )
162
156
{
163
157
int n ;
164
158
@@ -174,7 +168,7 @@ static int tls_write_on_socket(struct tcp_connection* c, int fd,
174
168
goto release ;
175
169
}
176
170
177
- n = tls_write (c , fd , buf , len , NULL , ssl_global_lock );
171
+ n = tls_write (c , fd , buf , len , NULL , & tls_mgm_api );
178
172
if (n >= 0 && len - n ) {
179
173
/* if could not write entire buffer, delay it */
180
174
n = tcp_async_add_chunk (c , buf + n , len - n , 0 );
@@ -184,7 +178,7 @@ static int tls_write_on_socket(struct tcp_connection* c, int fd,
184
178
}
185
179
} else {
186
180
n = tls_blocking_write (c , fd , buf , len ,
187
- tls_handshake_tout , tls_send_tout , t_dst , ssl_global_lock );
181
+ tls_handshake_tout , tls_send_tout , t_dst , & tls_mgm_api );
188
182
}
189
183
release :
190
184
lock_release (& c -> write_lock );
@@ -334,14 +328,6 @@ static int mod_init(void)
334
328
sroutes -> request , RT_NO );
335
329
}
336
330
337
- #ifndef NO_SSL_GLOBAL_LOCK
338
- ssl_global_lock = lock_alloc ();
339
- if (!ssl_global_lock || !lock_init (ssl_global_lock )) {
340
- LM_ERR ("could not initialize openssl lock!\n" );
341
- return -1 ;
342
- }
343
- #endif
344
-
345
331
return 0 ;
346
332
}
347
333
@@ -351,11 +337,6 @@ static int mod_init(void)
351
337
*/
352
338
static void mod_destroy (void )
353
339
{
354
- #ifndef NO_SSL_GLOBAL_LOCK
355
- lock_destroy (ssl_global_lock );
356
- lock_dealloc (ssl_global_lock );
357
- #endif
358
-
359
340
/* library destroy */
360
341
ERR_free_strings ();
361
342
/*SSL_free_comp_methods(); - this function is not on std. openssl*/
@@ -459,7 +440,7 @@ static void proto_tls_conn_clean(struct tcp_connection* c)
459
440
c -> proto_data = NULL ;
460
441
}
461
442
462
- tls_conn_clean (c , ssl_global_lock , & tls_mgm_api );
443
+ tls_conn_clean (c , & tls_mgm_api );
463
444
}
464
445
465
446
@@ -557,7 +538,7 @@ static int proto_tls_send(struct socket_info* send_sock,
557
538
* connect status */
558
539
tls_update_fd (c , fd );
559
540
n = tls_async_connect (c , fd , tls_async_handshake_connect_timeout , t_dst ,
560
- ssl_global_lock );
541
+ & tls_mgm_api );
561
542
lock_release (& c -> write_lock );
562
543
if (n < 0 ) {
563
544
LM_ERR ("failed async TLS connect\n" );
@@ -601,7 +582,7 @@ static int proto_tls_send(struct socket_info* send_sock,
601
582
send_it :
602
583
LM_DBG ("sending via fd %d...\n" ,fd );
603
584
604
- rlen = tls_write_on_socket (c , fd , buf , len , ssl_global_lock );
585
+ rlen = tls_write_on_socket (c , fd , buf , len );
605
586
tcp_conn_set_lifetime ( c , tcp_con_lifetime );
606
587
607
588
LM_DBG ("after write: c=%p n=%d fd=%d\n" ,c , rlen , fd );
@@ -655,7 +636,7 @@ static int tls_read_req(struct tcp_connection* con, int* bytes_read)
655
636
}
656
637
657
638
/* do this trick in order to trace whether if it's an error or not */
658
- ret = tls_fix_read_conn (con , tls_handshake_tout , t_dst , ssl_global_lock );
639
+ ret = tls_fix_read_conn (con , tls_handshake_tout , t_dst , & tls_mgm_api );
659
640
if (ret < 0 ) {
660
641
LM_ERR ("failed to do pre-tls handshake!\n" );
661
642
return -1 ;
@@ -697,7 +678,7 @@ static int tls_read_req(struct tcp_connection* con, int* bytes_read)
697
678
if (req -> parsed < req -> pos ){
698
679
bytes = 0 ;
699
680
}else {
700
- bytes = tls_read (con ,req , ssl_global_lock );
681
+ bytes = tls_read (con ,req , & tls_mgm_api );
701
682
if (bytes < 0 ) {
702
683
LM_ERR ("failed to read \n" );
703
684
goto error ;
@@ -761,7 +742,7 @@ static int tls_async_write(struct tcp_connection* con, int fd)
761
742
SSL * ssl = (SSL * )con -> extra_data ;
762
743
763
744
err = tls_fix_read_conn_unlocked (con , fd , tls_handshake_tout , t_dst ,
764
- ssl_global_lock );
745
+ & tls_mgm_api );
765
746
if (err < 0 ) {
766
747
LM_ERR ("failed to do pre-tls handshake!\n" );
767
748
return -1 ;
@@ -776,7 +757,7 @@ static int tls_async_write(struct tcp_connection* con, int fd)
776
757
chunk -> len , chunk , con , chunk -> ticks , get_ticks ());
777
758
778
759
#ifndef NO_SSL_GLOBAL_LOCK
779
- lock_get ( ssl_global_lock );
760
+ tls_mgm_api . global_lock_get ( );
780
761
#endif
781
762
782
763
n = SSL_write (con -> extra_data , chunk -> buf , chunk -> len );
@@ -785,15 +766,15 @@ static int tls_async_write(struct tcp_connection* con, int fd)
785
766
switch (err ) {
786
767
case SSL_ERROR_ZERO_RETURN :
787
768
#ifndef NO_SSL_GLOBAL_LOCK
788
- lock_release ( ssl_global_lock );
769
+ tls_mgm_api . global_lock_release ( );
789
770
#endif
790
771
791
772
LM_DBG ("connection closed cleanly\n" );
792
773
return -1 ;
793
774
case SSL_ERROR_WANT_READ :
794
775
case SSL_ERROR_WANT_WRITE :
795
776
#ifndef NO_SSL_GLOBAL_LOCK
796
- lock_release ( ssl_global_lock );
777
+ tls_mgm_api . global_lock_release ( );
797
778
#endif
798
779
799
780
LM_DBG ("Can't finish to write chunk %p on conn %p\n" ,
@@ -806,7 +787,7 @@ static int tls_async_write(struct tcp_connection* con, int fd)
806
787
tls_print_errstack ();
807
788
808
789
#ifndef NO_SSL_GLOBAL_LOCK
809
- lock_release ( ssl_global_lock );
790
+ tls_mgm_api . global_lock_release ( );
810
791
#endif
811
792
812
793
/* report the conn as broken */
0 commit comments