@@ -20,7 +20,7 @@ limitations under the License.
20
20
#include "quicer_tls.h"
21
21
#include <msquichelper.h>
22
22
23
- extern QuicerRegistrationCTX * G_r_ctx ;
23
+ extern QuicerRegistrationCTX G_r_ctx ;
24
24
extern pthread_mutex_t MsQuicLock ;
25
25
26
26
static ERL_NIF_TERM get_stream_opt (ErlNifEnv * env ,
@@ -218,11 +218,6 @@ ServerLoadConfiguration(ErlNifEnv *env,
218
218
{
219
219
QUIC_SETTINGS Settings = { 0 };
220
220
221
- if (!G_r_ctx )
222
- {
223
- return ATOM_REG_FAILED ;
224
- }
225
-
226
221
if (!create_settings (env , option , & Settings ))
227
222
{
228
223
return ATOM_BADARG ;
@@ -275,11 +270,6 @@ ClientLoadConfiguration(ErlNifEnv *env,
275
270
QUIC_SETTINGS Settings = { 0 };
276
271
ERL_NIF_TERM ret = ATOM_OK ;
277
272
278
- if (!G_r_ctx )
279
- {
280
- return ATOM_REG_FAILED ;
281
- }
282
-
283
273
//
284
274
// Configures the client's idle timeout.
285
275
//
@@ -859,10 +849,9 @@ encode_parm_to_eterm(ErlNifEnv *env,
859
849
}
860
850
861
851
ERL_NIF_TERM
862
- getopt3 (ErlNifEnv * env ,
863
- __unused_parm__ int argc ,
864
- __unused_parm__ const ERL_NIF_TERM argv [])
852
+ getopt3 (ErlNifEnv * env , int argc , const ERL_NIF_TERM argv [])
865
853
{
854
+ CXPLAT_FRE_ASSERT (3 == argc );
866
855
ERL_NIF_TERM ctx = argv [0 ];
867
856
ERL_NIF_TERM eopt = argv [1 ];
868
857
ERL_NIF_TERM elevel = argv [2 ];
@@ -894,12 +883,12 @@ getopt3(ErlNifEnv *env,
894
883
{
895
884
return SUCCESS (ETERM_UINT_64 (((QuicerStreamCTX * )q_ctx )-> StreamID ));
896
885
}
897
- if (!get_stream_handle (q_ctx ))
886
+ if (!LOCAL_REFCNT ( get_stream_handle (q_ctx ) ))
898
887
{
899
888
goto Exit ;
900
889
}
901
890
res = get_stream_opt (env , (QuicerStreamCTX * )q_ctx , eopt , elevel );
902
- put_stream_handle (q_ctx );
891
+ LOCAL_REFCNT ( put_stream_handle (q_ctx ) );
903
892
}
904
893
else if (enif_get_resource (env , ctx , ctx_connection_t , & q_ctx ))
905
894
{
@@ -971,8 +960,9 @@ set_level_param(ErlNifEnv *env,
971
960
}
972
961
973
962
ERL_NIF_TERM
974
- setopt4 (ErlNifEnv * env , __unused_parm__ int argc , const ERL_NIF_TERM argv [])
963
+ setopt4 (ErlNifEnv * env , int argc , const ERL_NIF_TERM argv [])
975
964
{
965
+ CXPLAT_FRE_ASSERT (4 == argc );
976
966
ERL_NIF_TERM ctx = argv [0 ];
977
967
ERL_NIF_TERM eopt = argv [1 ];
978
968
ERL_NIF_TERM evalue = argv [2 ];
@@ -992,13 +982,13 @@ setopt4(ErlNifEnv *env, __unused_parm__ int argc, const ERL_NIF_TERM argv[])
992
982
}
993
983
else if (enif_get_resource (env , ctx , ctx_stream_t , & q_ctx ))
994
984
{
995
- if (!get_stream_handle (q_ctx ))
985
+ if (!LOCAL_REFCNT ( get_stream_handle (q_ctx ) ))
996
986
{
997
987
goto Exit ;
998
988
}
999
989
res = set_stream_opt (
1000
990
env , (QuicerStreamCTX * )q_ctx , eopt , evalue , elevel );
1001
- put_stream_handle (q_ctx );
991
+ LOCAL_REFCNT ( put_stream_handle (q_ctx ) );
1002
992
}
1003
993
else if (enif_get_resource (env , ctx , ctx_connection_t , & q_ctx ))
1004
994
{
@@ -1344,7 +1334,7 @@ get_stream_opt(ErlNifEnv *env,
1344
1334
{
1345
1335
res = get_level_param (env ,
1346
1336
s_ctx -> Stream ,
1347
- s_ctx -> c_ctx -> config_resource -> Configuration ,
1337
+ s_ctx -> c_ctx -> config_ctx -> Configuration ,
1348
1338
optname ,
1349
1339
elevel );
1350
1340
goto Exit ;
@@ -1458,7 +1448,7 @@ set_stream_opt(ErlNifEnv *env,
1458
1448
{
1459
1449
res = set_level_param (env ,
1460
1450
s_ctx -> Stream ,
1461
- s_ctx -> c_ctx -> config_resource -> Configuration ,
1451
+ s_ctx -> c_ctx -> config_ctx -> Configuration ,
1462
1452
optname ,
1463
1453
optval ,
1464
1454
elevel );
@@ -1531,13 +1521,13 @@ get_connection_opt(ErlNifEnv *env,
1531
1521
1532
1522
if (!IS_SAME_TERM (ATOM_FALSE , elevel ))
1533
1523
{
1534
- if (!c_ctx -> config_resource )
1524
+ if (!c_ctx -> config_ctx )
1535
1525
{
1536
1526
goto Exit ;
1537
1527
}
1538
1528
res = get_level_param (env ,
1539
1529
c_ctx -> Connection ,
1540
- c_ctx -> config_resource -> Configuration ,
1530
+ c_ctx -> config_ctx -> Configuration ,
1541
1531
optname ,
1542
1532
elevel );
1543
1533
goto Exit ;
@@ -1724,13 +1714,13 @@ set_connection_opt(ErlNifEnv *env,
1724
1714
1725
1715
if (!IS_SAME_TERM (ATOM_FALSE , elevel ))
1726
1716
{
1727
- if (!c_ctx -> config_resource )
1717
+ if (!c_ctx -> config_ctx )
1728
1718
{
1729
1719
goto Exit ;
1730
1720
}
1731
1721
res = set_level_param (env ,
1732
1722
c_ctx -> Connection ,
1733
- c_ctx -> config_resource -> Configuration ,
1723
+ c_ctx -> config_ctx -> Configuration ,
1734
1724
optname ,
1735
1725
optval ,
1736
1726
elevel );
@@ -2062,13 +2052,13 @@ get_listener_opt(ErlNifEnv *env,
2062
2052
{
2063
2053
return ERROR_TUPLE_2 (ATOM_CLOSED );
2064
2054
}
2065
- enif_keep_resource (l_ctx );
2055
+ get_listener_handle (l_ctx );
2066
2056
2067
2057
if (!IS_SAME_TERM (ATOM_FALSE , elevel ))
2068
2058
{
2069
2059
res = get_level_param (env ,
2070
2060
l_ctx -> Listener ,
2071
- l_ctx -> config_resource -> Configuration ,
2061
+ l_ctx -> config_ctx -> Configuration ,
2072
2062
optname ,
2073
2063
elevel );
2074
2064
goto Exit ;
@@ -2123,7 +2113,7 @@ get_listener_opt(ErlNifEnv *env,
2123
2113
res = ERROR_TUPLE_2 (ATOM_STATUS (status ));
2124
2114
}
2125
2115
Exit :
2126
- enif_release_resource (l_ctx );
2116
+ put_listener_handle (l_ctx );
2127
2117
return res ;
2128
2118
}
2129
2119
@@ -2157,7 +2147,7 @@ set_listener_opt(ErlNifEnv *env,
2157
2147
{
2158
2148
res = set_level_param (env ,
2159
2149
l_ctx -> Listener ,
2160
- l_ctx -> config_resource -> Configuration ,
2150
+ l_ctx -> config_ctx -> Configuration ,
2161
2151
optname ,
2162
2152
optval ,
2163
2153
elevel );
@@ -2644,7 +2634,6 @@ parse_registration(ErlNifEnv *env,
2644
2634
return FALSE;
2645
2635
}
2646
2636
}
2647
-
2648
2637
return TRUE;
2649
2638
}
2650
2639
0 commit comments