Skip to content

Commit

Permalink
samples: net: echo-client: Handle net_buf out-of-mem gracefully
Browse files Browse the repository at this point in the history
Do not wait forever for network buffers when receiving data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Aug 14, 2018
1 parent 4078e46 commit b8b230f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions samples/net/echo_client/src/echo-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#define APP_BANNER "Run echo client"

#define BUF_TIMEOUT K_MSEC(100)

/* Generated by http://www.lipsum.com/
* 3 paragraphs, 176 words, 1230 bytes of Lorem Ipsum
*/
Expand Down Expand Up @@ -107,9 +109,10 @@ struct net_pkt *prepare_send_pkt(struct net_app_ctx *ctx,
{
struct net_pkt *send_pkt;

send_pkt = net_app_get_net_pkt(ctx, AF_UNSPEC, K_FOREVER);

NET_ASSERT(send_pkt);
send_pkt = net_app_get_net_pkt(ctx, AF_UNSPEC, BUF_TIMEOUT);
if (!send_pkt) {
return NULL;
}

*expecting_len = net_pkt_append(send_pkt, *expecting_len, lorem_ipsum,
K_FOREVER);
Expand Down

0 comments on commit b8b230f

Please sign in to comment.