[riot-notifications] [RIOT-OS/RIOT] tinydtls: add `sock_async` support for `sock_dtls` (#12907)

benpicco notifications at github.com
Wed May 27 16:43:07 CEST 2020


@benpicco commented on this pull request.



> @@ -376,6 +436,26 @@ static ssize_t _copy_buffer(sock_dtls_t *sock, void *data, size_t max_len)
     if (buflen > max_len) {
         return -ENOBUFS;
     }
+#if SOCK_HAS_ASYNC
+    if (sock->buf_ctx != NULL) {
+        memcpy(data, buf, sock->buflen);
+        _check_more_chunks(sock->udp_sock, (void **)&buf, &sock->buf_ctx,
+                           &remote->ep);
+        if (sock->async_cb && cib_avail(&sock->mbox.cib)) {

Why the check for `sock->mbox.cib`?

> +        else if (mbox_try_get(&sock->mbox, &msg) &&
+                 msg.type == DTLS_EVENT_CONNECTED) {
+            memcpy(&remote->dtls_session, msg.content.ptr, sizeof(session_t));
+            if (sock->async_cb) {
+                sock_async_flags_t flags = SOCK_ASYNC_CONN_RDY;
+
+                if (cib_avail(&sock->mbox.cib)) {
+                    if (sock->buf) {
+                        flags |= SOCK_ASYNC_MSG_RECV;
+                    }
+                    else {
+                        flags |= SOCK_ASYNC_CONN_RECV;
+                    }
+                }
+                sock->async_cb(sock, flags, sock->async_cb_arg);
+            }
+            return -SOCK_DTLS_HANDSHAKE;
+        }

So this block is waiting for the initial handshake to complete?

> +    sock_dtls_close(&_dtls_sock);
+    sock_udp_close(&_udp_sock);
+    _sending = false;

> So please focus your review on the `sock_async` integration first and then we can discuss the application.

At a first glance it looks good, but as always some more comments would be appreciated. 

-- 
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/12907#pullrequestreview-419278298
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200527/698608d2/attachment.htm>


More information about the notifications mailing list