From d8dd91d7bfdadbd86e44705b2f5146ed579e6c92 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Fri, 21 Apr 2017 14:15:34 +0300 Subject: [PATCH] net: context: Connect callback was set too late We need to set the connect_cb for the context before sending SYN packet. This is required if we have a loopback connection in which case everything is happening more or less synchronously and the connect_cb would not be called in this case because its value would still be null. For remote network connections this patch makes no difference. Change-Id: Id7f837cd9e81cd79c4666c98cae84f6cb1a77af0 Signed-off-by: Jukka Rissanen --- subsys/net/ip/net_context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index 5c8c0fd9733..47b63656c20 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -1153,12 +1153,13 @@ int net_context_connect(struct net_context *context, return ret; } + context->connect_cb = cb; + context->user_data = user_data; + net_context_set_state(context, NET_CONTEXT_CONNECTING); send_syn(context, addr); - context->connect_cb = cb; - context->user_data = user_data; /* in tcp_synack_received() we give back this semaphore */ if (timeout != 0 && k_sem_take(&context->tcp->connect_wait, timeout)) {