net: lwm2m: Follow POSIX send() API
send() returns -1 upon error and sets errno appropriately. Let's not bother saving the return code and instead share errno back to the user. Signed-off-by: Michael Scott <mike@foundries.io>
This commit is contained in:
parent
fe9f85464c
commit
2ab50cb676
1 changed files with 5 additions and 10 deletions
|
@ -1024,8 +1024,6 @@ cleanup:
|
|||
|
||||
int lwm2m_send_message(struct lwm2m_message *msg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!msg || !msg->ctx) {
|
||||
LOG_ERR("LwM2M message is invalid.");
|
||||
return -EINVAL;
|
||||
|
@ -1037,13 +1035,12 @@ int lwm2m_send_message(struct lwm2m_message *msg)
|
|||
|
||||
msg->send_attempts++;
|
||||
|
||||
ret = send(msg->ctx->sock_fd, msg->cpkt.data, msg->cpkt.offset, 0);
|
||||
if (ret < 0) {
|
||||
if (send(msg->ctx->sock_fd, msg->cpkt.data, msg->cpkt.offset, 0) < 0) {
|
||||
if (msg->type == COAP_TYPE_CON) {
|
||||
coap_pending_clear(msg->pending);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (msg->type == COAP_TYPE_CON) {
|
||||
|
@ -1058,7 +1055,7 @@ int lwm2m_send_message(struct lwm2m_message *msg)
|
|||
lwm2m_reset_message(msg, true);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16_t lwm2m_get_rd_data(u8_t *client_data, u16_t size)
|
||||
|
@ -3560,7 +3557,6 @@ static void retransmit_request(struct k_work *work)
|
|||
struct lwm2m_ctx *client_ctx;
|
||||
struct lwm2m_message *msg;
|
||||
struct coap_pending *pending;
|
||||
int r;
|
||||
|
||||
client_ctx = CONTAINER_OF(work, struct lwm2m_ctx, retransmit_work);
|
||||
pending = coap_pending_next_to_expire(client_ctx->pendings,
|
||||
|
@ -3591,9 +3587,8 @@ static void retransmit_request(struct k_work *work)
|
|||
|
||||
LOG_DBG("Resending message: %p", msg);
|
||||
msg->send_attempts++;
|
||||
r = send(msg->ctx->sock_fd, msg->cpkt.data, msg->cpkt.offset, 0);
|
||||
if (r < 0) {
|
||||
LOG_ERR("Error sending lwm2m message: %d", r);
|
||||
if (send(msg->ctx->sock_fd, msg->cpkt.data, msg->cpkt.offset, 0) < 0) {
|
||||
LOG_ERR("Error sending lwm2m message: %d", -errno);
|
||||
/* don't error here, retry until timeout */
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue