From 29fc59e535aebd49e26a3296356914e4c6abfb82 Mon Sep 17 00:00:00 2001 From: Flavio Santes Date: Wed, 17 Aug 2016 14:33:19 -0500 Subject: samples/net: Remove call to unref routine when net_send returns >= 0 According to last comments posted in ZEP-632, the unref routine must be called only when net_send reports an error. Jira: ZEP-632 Change-Id: I11553edf2c7d686c3e58617c2e05b6f18962955e Signed-off-by: Flavio Santes --- samples/net/dns_client/src/netz.c | 3 +-- samples/net/mbedtls_sslclient/src/tcp.c | 1 - samples/net/nats_clients/publisher/src/netz.c | 3 +-- samples/net/paho_mqtt_clients/publisher/src/netz.c | 3 +-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/samples/net/dns_client/src/netz.c b/samples/net/dns_client/src/netz.c index b57932b22..b555fa85e 100644 --- a/samples/net/dns_client/src/netz.c +++ b/samples/net/dns_client/src/netz.c @@ -151,7 +151,6 @@ static int tcp_tx(struct net_context *ctx, uint8_t *buf, size_t size, rc = net_send(nbuf); if (rc >= 0) { - ip_buf_unref(nbuf); return 0; } switch (rc) { @@ -168,7 +167,7 @@ static int tcp_tx(struct net_context *ctx, uint8_t *buf, size_t size, } } while (1); - return 0; + return -EIO; } static int tcp_rx(struct net_context *ctx, uint8_t *buf, size_t *read_bytes, diff --git a/samples/net/mbedtls_sslclient/src/tcp.c b/samples/net/mbedtls_sslclient/src/tcp.c index b5314ef53..4aeaf418d 100644 --- a/samples/net/mbedtls_sslclient/src/tcp.c +++ b/samples/net/mbedtls_sslclient/src/tcp.c @@ -68,7 +68,6 @@ int tcp_tx(void *context, const unsigned char *buf, size_t size) rc = net_send(nbuf); fiber_sleep(TCP_RETRY_TIMEOUT); if (rc >= 0) { - ip_buf_unref(nbuf); return size; } switch (rc) { diff --git a/samples/net/nats_clients/publisher/src/netz.c b/samples/net/nats_clients/publisher/src/netz.c index aa9df1eb6..ea15dcd90 100644 --- a/samples/net/nats_clients/publisher/src/netz.c +++ b/samples/net/nats_clients/publisher/src/netz.c @@ -152,7 +152,6 @@ static int tcp_tx(struct net_context *ctx, uint8_t *buf, size_t size, rc = net_send(nbuf); if (rc >= 0) { - ip_buf_unref(nbuf); return 0; } switch (rc) { @@ -169,7 +168,7 @@ static int tcp_tx(struct net_context *ctx, uint8_t *buf, size_t size, } } while (1); - return 0; + return -EIO; } static int tcp_rx(struct net_context *ctx, uint8_t *buf, size_t *read_bytes, diff --git a/samples/net/paho_mqtt_clients/publisher/src/netz.c b/samples/net/paho_mqtt_clients/publisher/src/netz.c index 8d59276a1..6b916b338 100644 --- a/samples/net/paho_mqtt_clients/publisher/src/netz.c +++ b/samples/net/paho_mqtt_clients/publisher/src/netz.c @@ -152,7 +152,6 @@ static int tcp_tx(struct net_context *ctx, uint8_t *buf, size_t size, rc = net_send(nbuf); if (rc >= 0) { - ip_buf_unref(nbuf); return 0; } switch (rc) { @@ -169,7 +168,7 @@ static int tcp_tx(struct net_context *ctx, uint8_t *buf, size_t size, } } while (1); - return 0; + return -EIO; } static int tcp_rx(struct net_context *ctx, uint8_t *buf, size_t *read_bytes, -- cgit v1.2.3