aboutsummaryrefslogtreecommitdiff
path: root/rpc_misc.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2017-03-02 20:34:19 -0500
committerRob Austein <sra@hactrn.net>2017-03-02 20:34:19 -0500
commit91bb0444d8830569bfc09900d599c9ae39953f01 (patch)
tree3d4030a905aa3c6865b7fad0943f813a17fc4087 /rpc_misc.c
parentc2f499e0a301d4ad0f92d58f436d01087ceae1bb (diff)
parenta33470b2f899a94b50304a73721ba6d0d6d447b4 (diff)
Merge branch 'pymux' into hw_ecdsa_p256
Diffstat (limited to 'rpc_misc.c')
-rw-r--r--rpc_misc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/rpc_misc.c b/rpc_misc.c
index d6fc71d..cf5e4a0 100644
--- a/rpc_misc.c
+++ b/rpc_misc.c
@@ -103,24 +103,32 @@ static client_slot_t client_handle[HAL_STATIC_CLIENT_STATE_BLOCKS];
static inline client_slot_t *alloc_slot(void)
{
+ client_slot_t *slot = NULL;
+ hal_critical_section_start();
+
#if HAL_STATIC_CLIENT_STATE_BLOCKS > 0
- for (int i = 0; i < sizeof(client_handle)/sizeof(*client_handle); i++)
+ for (int i = 0; slot == NULL && i < sizeof(client_handle)/sizeof(*client_handle); i++)
if (client_handle[i].logged_in == HAL_USER_NONE)
- return &client_handle[i];
+ slot = &client_handle[i];
#endif
- return NULL;
+ hal_critical_section_end();
+ return slot;
}
static inline client_slot_t *find_handle(const hal_client_handle_t handle)
{
+ client_slot_t *slot = NULL;
+ hal_critical_section_start();
+
#if HAL_STATIC_CLIENT_STATE_BLOCKS > 0
- for (int i = 0; i < sizeof(client_handle)/sizeof(*client_handle); i++)
+ for (int i = 0; slot == NULL && i < sizeof(client_handle)/sizeof(*client_handle); i++)
if (client_handle[i].logged_in != HAL_USER_NONE && client_handle[i].handle.handle == handle.handle)
- return &client_handle[i];
+ slot = &client_handle[i];
#endif
- return NULL;
+ hal_critical_section_end();
+ return slot;
}
static hal_error_t login(const hal_client_handle_t client,