File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ LOG_MODULE_DECLARE(net_coap, CONFIG_COAP_LOG_LEVEL);
20
20
#define BLOCK1_OPTION_SIZE 4
21
21
#define PAYLOAD_MARKER_SIZE 1
22
22
23
+ static K_MUTEX_DEFINE (coap_client_mutex );
23
24
static struct coap_client * clients [CONFIG_COAP_CLIENT_MAX_INSTANCES ];
24
25
static int num_clients ;
25
26
static K_SEM_DEFINE (coap_client_recv_sem , 0 , 1 ) ;
@@ -1006,7 +1007,9 @@ int coap_client_init(struct coap_client *client, const char *info)
1006
1007
return - EINVAL ;
1007
1008
}
1008
1009
1010
+ k_mutex_lock (& coap_client_mutex , K_FOREVER );
1009
1011
if (num_clients >= CONFIG_COAP_CLIENT_MAX_INSTANCES ) {
1012
+ k_mutex_unlock (& coap_client_mutex );
1010
1013
return - ENOSPC ;
1011
1014
}
1012
1015
@@ -1015,6 +1018,7 @@ int coap_client_init(struct coap_client *client, const char *info)
1015
1018
clients [num_clients ] = client ;
1016
1019
num_clients ++ ;
1017
1020
1021
+ k_mutex_unlock (& coap_client_mutex );
1018
1022
return 0 ;
1019
1023
}
1020
1024
You can’t perform that action at this time.
0 commit comments