From c427e9bbd69953161b074d58065aa85f6c88ebed Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 8 Sep 2016 17:04:03 +0300 Subject: [PATCH] net: Context accept cb needs to return failure code If the connection establishment has an error, the accept callback needs to be able to return that error to user space so that the application can know about it. This is especially important in TCP where application needs to start to listen again if reset is sent during connection establishment. Change-Id: I55f36e4f101c7237c1288f09baf6e602b33da2b3 Signed-off-by: Jukka Rissanen --- include/net/yaip/net_context.h | 7 +++++-- tests/net/context/src/main.c | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/net/yaip/net_context.h b/include/net/yaip/net_context.h index e4b4dfb500b..61d7ce47334 100644 --- a/include/net/yaip/net_context.h +++ b/include/net/yaip/net_context.h @@ -470,17 +470,20 @@ int net_context_connect(struct net_context *context, * @brief Accept callback * * @details The accept callback is called after a successful - * connection is being established while we are waiting a connection - * attempt. The callback is called in fiber context. + * connection is being established or if there was an error + * while we were waiting for a connection attempt. + * The callback is called in fiber context. * * @param context The context to use. * @param addr The peer address. * @param addrlen Length of the peer address. + * @param status The status code, 0 on success, < 0 otherwise * @param user_data The user data given in net_context_accept() call. */ typedef void (*net_context_accept_cb_t)(struct net_context *new_context, struct sockaddr *addr, socklen_t addrlen, + int status, void *user_data); /** diff --git a/tests/net/context/src/main.c b/tests/net/context/src/main.c index b389282bad4..50206755ce1 100644 --- a/tests/net/context/src/main.c +++ b/tests/net/context/src/main.c @@ -437,6 +437,7 @@ static bool net_ctx_connect_v4(void) static void accept_cb(struct net_context *context, struct sockaddr *addr, socklen_t addrlen, + int status, void *user_data) { sa_family_t family = POINTER_TO_INT(user_data);