net: zoap: Add timeout while requesting packets
Add timeout for packet and buffer requests. If there are no buffers available gracefully drop the request. Change-Id: I56fe2b606556149c83751aadc1c5eee7828a84a8 Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
parent
86a72e1ed4
commit
38503f8c76
1 changed files with 7 additions and 5 deletions
|
@ -20,6 +20,8 @@
|
|||
#include <net/zoap.h>
|
||||
#include <net/zoap_link_format.h>
|
||||
|
||||
#define PKT_WAIT_TIME K_SECONDS(1)
|
||||
|
||||
static int format_uri(const char * const *path, struct net_buf *buf)
|
||||
{
|
||||
static const char prefix[] = "</";
|
||||
|
@ -232,12 +234,12 @@ static int send_error_response(struct zoap_resource *resource,
|
|||
|
||||
context = net_pkt_context(request->pkt);
|
||||
|
||||
pkt = net_pkt_get_tx(context, K_FOREVER);
|
||||
pkt = net_pkt_get_tx(context, PKT_WAIT_TIME);
|
||||
if (!pkt) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, PKT_WAIT_TIME);
|
||||
if (!frag) {
|
||||
net_pkt_unref(pkt);
|
||||
return -ENOMEM;
|
||||
|
@ -297,12 +299,12 @@ int _zoap_well_known_core_get(struct zoap_resource *resource,
|
|||
|
||||
context = net_pkt_context(request->pkt);
|
||||
|
||||
pkt = net_pkt_get_tx(context, K_FOREVER);
|
||||
pkt = net_pkt_get_tx(context, PKT_WAIT_TIME);
|
||||
if (!pkt) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
frag = net_pkt_get_data(context, K_FOREVER);
|
||||
frag = net_pkt_get_data(context, PKT_WAIT_TIME);
|
||||
if (!frag) {
|
||||
net_pkt_unref(pkt);
|
||||
return -ENOMEM;
|
||||
|
@ -349,7 +351,7 @@ int _zoap_well_known_core_get(struct zoap_resource *resource,
|
|||
*str = 0xFF;
|
||||
response.start = str + 1;
|
||||
} else {
|
||||
temp = net_pkt_get_data(context, K_FOREVER);
|
||||
temp = net_pkt_get_data(context, PKT_WAIT_TIME);
|
||||
if (!temp) {
|
||||
net_pkt_unref(pkt);
|
||||
return -ENOMEM;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue