mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #20915 from fabian18/pr/gcoap_forward_proxy_timeout
gcoap/forward_proxy: handle timeout case
This commit is contained in:
commit
87c825dd82
@ -276,6 +276,9 @@ static void _forward_resp_handler(const gcoap_request_memo_t *memo,
|
|||||||
/* No harm done in removing a timer that's not active */
|
/* No harm done in removing a timer that's not active */
|
||||||
ztimer_remove(ZTIMER_MSEC, &cep->empty_ack_timer);
|
ztimer_remove(ZTIMER_MSEC, &cep->empty_ack_timer);
|
||||||
buf_len = coap_get_total_len(pdu);
|
buf_len = coap_get_total_len(pdu);
|
||||||
|
assert(memo->state == GCOAP_MEMO_RESP ||
|
||||||
|
memo->state == GCOAP_MEMO_RESP_TRUNC ||
|
||||||
|
memo->state == GCOAP_MEMO_TIMEOUT);
|
||||||
if (memo->state == GCOAP_MEMO_RESP) {
|
if (memo->state == GCOAP_MEMO_RESP) {
|
||||||
uint8_t req_etag_len = _cep_get_req_etag_len(cep);
|
uint8_t req_etag_len = _cep_get_req_etag_len(cep);
|
||||||
|
|
||||||
@ -304,6 +307,7 @@ static void _forward_resp_handler(const gcoap_request_memo_t *memo,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
_set_response_type(pdu, _cep_get_response_type(cep));
|
||||||
/* we do not need to check if valid came from upstream as this is already automatically
|
/* we do not need to check if valid came from upstream as this is already automatically
|
||||||
* converted by the client-side to the cached response */
|
* converted by the client-side to the cached response */
|
||||||
/* else forward the response packet as-is to the client */
|
/* else forward the response packet as-is to the client */
|
||||||
@ -315,8 +319,13 @@ static void _forward_resp_handler(const gcoap_request_memo_t *memo,
|
|||||||
assert(buf_len >= (sizeof(*pdu->hdr) + 4U));
|
assert(buf_len >= (sizeof(*pdu->hdr) + 4U));
|
||||||
gcoap_resp_init(pdu, (uint8_t *)pdu->hdr, buf_len, COAP_CODE_INTERNAL_SERVER_ERROR);
|
gcoap_resp_init(pdu, (uint8_t *)pdu->hdr, buf_len, COAP_CODE_INTERNAL_SERVER_ERROR);
|
||||||
coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
|
coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
|
||||||
|
_set_response_type(pdu, _cep_get_response_type(cep));
|
||||||
|
}
|
||||||
|
else if (memo->state == GCOAP_MEMO_TIMEOUT) {
|
||||||
|
/* send RST */
|
||||||
|
gcoap_resp_init(pdu, (uint8_t *)pdu->hdr, buf_len, COAP_CODE_EMPTY);
|
||||||
|
coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
|
||||||
}
|
}
|
||||||
_set_response_type(pdu, _cep_get_response_type(cep));
|
|
||||||
/* don't use buf_len here, in case the above `gcoap_resp_init`s changed `pdu` */
|
/* don't use buf_len here, in case the above `gcoap_resp_init`s changed `pdu` */
|
||||||
_dispatch_msg(pdu->hdr, coap_get_total_len(pdu), &cep->ep, &cep->proxy_ep);
|
_dispatch_msg(pdu->hdr, coap_get_total_len(pdu), &cep->ep, &cep->proxy_ep);
|
||||||
_free_client_ep(cep);
|
_free_client_ep(cep);
|
||||||
|
@ -1045,7 +1045,9 @@ static void _expire_request(gcoap_request_memo_t *memo)
|
|||||||
/* Pass response to handler */
|
/* Pass response to handler */
|
||||||
if (memo->resp_handler) {
|
if (memo->resp_handler) {
|
||||||
coap_pkt_t req;
|
coap_pkt_t req;
|
||||||
|
memset(&req, 0, sizeof(req));
|
||||||
|
/* 0 means there is an observe option value */
|
||||||
|
coap_clear_observe(&req);
|
||||||
req.hdr = gcoap_request_memo_get_hdr(memo);
|
req.hdr = gcoap_request_memo_get_hdr(memo);
|
||||||
memo->resp_handler(memo, &req, NULL);
|
memo->resp_handler(memo, &req, NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user