Skip to content

Commit 35eee84

Browse files
committed
Address comments on #278
1 parent a8b8f9d commit 35eee84

7 files changed

Lines changed: 19 additions & 20 deletions

File tree

src/wh_client.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ int wh_Client_Init(whClientContext* c, const whClientConfig* config)
8383

8484
#ifdef WOLFHSM_CFG_ENABLE_TIMEOUT
8585
if (config->respTimeoutConfig != NULL) {
86-
rc = wh_Timeout_Init(c->respTimeout, config->respTimeoutConfig);
87-
if (rc != 0) {
86+
rc = wh_Timeout_Init(&c->respTimeout, config->respTimeoutConfig);
87+
if (rc != WH_ERROR_OK) {
8888
return rc;
8989
}
9090
}
@@ -208,16 +208,19 @@ int wh_Client_RecvResponse(whClientContext *c,
208208
return rc;
209209
}
210210

211-
int wh_Client_RecvResponseTimeout(whClientContext *c,
211+
int wh_Client_RecvResponseBlockingWithTimeout(whClientContext *c,
212212
uint16_t *out_group, uint16_t *out_action,
213-
uint16_t *out_size, void* data, whTimeoutCtx *timeout)
213+
uint16_t *out_size, void* data)
214214
{
215215
int ret;
216+
whTimeoutCtx* timeout;
216217

217-
if ((c == NULL) || (timeout == NULL)) {
218+
if (c == NULL) {
218219
return WH_ERROR_BADARGS;
219220
}
220221

222+
timeout = &c->respTimeout;
223+
221224
ret = wh_Timeout_Start(timeout);
222225
if (ret != WH_ERROR_OK) {
223226
return ret;

src/wh_client_crypto.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ static int _recvCryptoResponse(whClientContext* ctx,
170170
int ret;
171171

172172
#ifdef WOLFHSM_CFG_ENABLE_TIMEOUT
173-
ret = wh_Client_RecvResponseTimeout(ctx, group, action, size, data,
174-
ctx->respTimeout);
173+
ret = wh_Client_RecvResponseBlockingWithTimeout(ctx, group, action, size, data);
175174
#else
176175
do {
177176
ret = wh_Client_RecvResponse(ctx, group, action, size, data);

src/wh_timeout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2025 wolfSSL Inc.
2+
* Copyright (C) 2026 wolfSSL Inc.
33
*
44
* This file is part of wolfHSM.
55
*

test/wh_test_timeout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 wolfSSL Inc.
2+
* Copyright (C) 2026 wolfSSL Inc.
33
*
44
* This file is part of wolfHSM.
55
*

test/wh_test_timeout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 wolfSSL Inc.
2+
* Copyright (C) 2026 wolfSSL Inc.
33
*
44
* This file is part of wolfHSM.
55
*

wolfhsm/wh_client.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct whClientContext_t {
123123
whClientCancelCb cancelCb;
124124
#endif
125125
#ifdef WOLFHSM_CFG_ENABLE_TIMEOUT
126-
whTimeoutCtx respTimeout[1];
126+
whTimeoutCtx respTimeout;
127127
#endif
128128
#ifdef WOLFHSM_CFG_DMA
129129
whClientDmaContext dma;
@@ -200,24 +200,21 @@ int wh_Client_SendRequest(whClientContext* c, uint16_t group, uint16_t action,
200200
int wh_Client_RecvResponse(whClientContext* c, uint16_t* out_group,
201201
uint16_t* out_action, uint16_t* out_size,
202202
void* data);
203-
#ifdef WOLFHSM_CFG_ENABLE_TIMEOUT
204203
/**
205-
* Receives a response from the server with a timeout window.
204+
* Receives a response from the server with a timeout window. The timeout
205+
* duration is specified by the respTimeout field in the client context.
206206
*
207207
* @param c The client context.
208208
* @param out_group Pointer to store the received group value.
209209
* @param out_action Pointer to store the received action value.
210210
* @param out_size Pointer to store the received size value.
211211
* @param data Pointer to store the received data.
212-
* @param timeout The timeout context to use.
213212
* @return 0 if successful, WH_ERROR_TIMEOUT on expiration, or a negative value
214213
* if an error occurred.
215214
*/
216-
int wh_Client_RecvResponseTimeout(whClientContext* c, uint16_t* out_group,
217-
uint16_t* out_action, uint16_t* out_size,
218-
void* data, whTimeoutCtx* timeout);
219-
#endif /* WOLFHSM_CFG_ENABLE_TIMEOUT */
220-
215+
int wh_Client_RecvResponseBlockingWithTimeout(whClientContext* c, uint16_t* out_group,
216+
uint16_t* out_action, uint16_t* out_size,
217+
void* data);
221218

222219
/** Comm component functions */
223220

wolfhsm/wh_timeout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2025 wolfSSL Inc.
2+
* Copyright (C) 2026 wolfSSL Inc.
33
*
44
* This file is part of wolfHSM.
55
*

0 commit comments

Comments
 (0)