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 <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2017-04-21 14:15:34 +03:00
commit d8dd91d7bf

View file

@ -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)) {