[riot-notifications] [RIOT-OS/RIOT] sock/async: add function to retrieve session object of current DTLS event (#15755)

János Brodbeck notifications at github.com
Wed Jan 13 12:14:22 CET 2021


@janosbrodbeck commented on this pull request.



> @@ -87,6 +87,7 @@ static int _read(struct dtls_context_t *ctx, session_t *session, uint8_t *buf,
     sock->buffer.session = session;
 #ifdef SOCK_HAS_ASYNC
     if (sock->async_cb != NULL) {
+        memcpy(&sock->async_cb_session, session, sizeof(session_t));

The problem I had with a pointer was that I cannot set the pointer to NULL after the callback call.
```
sock->async_cb_session = session;
sock->async_cb(sock, SOCK_ASYNC_MSG_RECV, sock->async_cb_arg);
sock->async_cb_session = NULL;
```
The session is already NULL again when I call `sock_dtls_get_event_session` within the DTLS handler. 

No, `sock_dtls_get_event_session` should have no use case outside of the handler. It's not even guaranteed that you get a proper information out of it outside the handler.
  

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15755#discussion_r556443648
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210113/a76813b6/attachment.htm>


More information about the notifications mailing list