gnrc conn: enqueue packets if noone's waiting#4327
gnrc conn: enqueue packets if noone's waiting#4327OlegHahm wants to merge 5 commits intoRIOT-OS:masterfrom
Conversation
|
There must be another way of doing this without changing gnrc_udp. Because this is somewhat beside the point of conn, IMHO. |
|
The only way to keep gnrc_udp completely untouched would require to run conn or POSIX in its own thread which would be worse. I'm also unhappy with this dependency but without this patch sockets won't work properly. On 23 November 2015 09:17:02 CET, Martine Lenders [email protected] wrote:
|
There was a problem hiding this comment.
Can one include GNRC_CONN and GNRC_UDP without GNRC_CONN_UDP?
|
Then we need a similar solution for conn_ip |
|
This seems like a hack. @OlegHahm Could you elaborate on the problem? |
sys/net/gnrc/conn/gnrc_conn.c
Outdated
There was a problem hiding this comment.
Wouldn't this also dequeue packets destined for other ports since you use only one universal cib?
There was a problem hiding this comment.
Yes, but an (unbound) POSIX recvfrom() doesn't specify a port to receive on. However, this rises two questions:
1.) do we want this queue only in combination with POSIX sockets?
2.) what to do with bound sockets here?
If a library uses POSIX sockets (like ccn-lite or tinydtls) and calls sendto(...);
do_some_computation();
recvfrom(...);expecting to receive the response to the sendto-call even if |
545d805 to
1723874
Compare
|
@cgundogan, what about the proposed solution in OlegHahm@65506e5 ? |
|
@OlegHahm thanks, I get it. This points to something that should be solved at the core IPC: decouple message endpoints from threads. That way conn_* could have it's own message queue and register that when *_bind()ing. I've got code lying around for that, but that will probably need time to get in, as it's at the heart of core/. If this PR fixes posix sockets for now, I'd say, lets get it in. |
|
I thought about it, too. This doesn't necessarily have to be a replacement for msg but can also be an alternative (maybe a good idea for a first step anyway). I'm thinking of something like lwIPs mboxes. |
|
I agree that this is a workaround for now, but we would need a more generic (no pun intended) concept to solve this. However, if you agree to take this workaround for now, I would implement the missing RAW IP part and we can merge this. |
|
@OlegHahm I am fine with your proposed enqueuing strategy. However: In case of multiple threads that use |
|
@cgundogan, probably you're right, but I guess this can already happen without this patch, if there's an RAW IP and a UDP socket opened. I think we need to find a better solution in the long run anyway. |
|
As long as this woraround is somehow marked as such in the code I join the others and ACK it |
|
Okay, will do. |
|
Are you okay with these comments? Should I squash? |
sys/net/gnrc/conn/gnrc_conn.c
Outdated
There was a problem hiding this comment.
arbitrary (non-commit comment)
|
Hm, still don't know how to garbage collect enqueued datagrams? |
|
on closing of socket? |
|
Might be way too late. One may open a socket just for sending period packets without ever calling receive. I think the best way is to switch to a different data structure, e.g. a lifo, and call a timer based garbage collector. |
|
Thanks to the discussion with @cgundogan in #4320 I came to the conclusion that this is actually not required if you do the implicit binding during the |
Currently gnrc in combination with POSIX sockets will discard packets if
recvfrom()is not called before.Another part for fixing #4320.