Conversation
|
Ping? |
69eaf02 to
aa938c4
Compare
|
Rebased for today's Hack'n'ACK. |
|
@PeterKietzmann can we maybe get this merged today, then we can delete conn soon-ish ;-). |
aa938c4 to
c398518
Compare
|
Rebased to current master |
|
Okay, I can't fix the issues Jenkins reports right now. Will do later. |
|
Rebased and adapted to master. |
|
If we merge this before the release, we can remove |
|
Can we finally merge this tonight? |
| /* change to emb6 thread context */ | ||
| if (evproc_putEvent(E_EVPROC_TAIL, EVENT_TYPE_CONN_SEND, &send_cmd) == E_SUCCESS) { | ||
| /* block thread until data was send */ | ||
| mutex_lock(&send_cmd.block); |
There was a problem hiding this comment.
mutex was already locked 4 lines above, need to lock again here?
There was a problem hiding this comment.
is this because in _output_callback its unlocked if successful?
There was a problem hiding this comment.
but why unlock in _output_callback and lock here again, couldn't you just omit the unlock in _output_callback.
There was a problem hiding this comment.
Yes, this is basically a hacked way of waiting for the data to be sent (see comment above this line) ;-)
pkg/emb6/include/sock_types.h
Outdated
|
|
||
| /** | ||
| * @defgroup | ||
| * @ingroup |
| res = -ETIMEDOUT; | ||
| break; | ||
| case _MSG_TYPE_RCV: | ||
| mutex_lock(&sock->mutex); |
There was a problem hiding this comment.
it is necessary to lock here already, if possible (and safe) move lock below one line above memcpy?
There was a problem hiding this comment.
sock->recv_info in the line below needs protection. It is set in _input_callback() which is set in the emb6 thread's context.
|
Addressed comments |
| mutex_lock(&sock->mutex); | ||
| mbox_init(&sock->mbox, sock->mbox_queue, SOCK_MBOX_SIZE); | ||
| atomic_flag_clear(&sock->receivers); | ||
| if ((res = _reg(&sock->sock, sock, _input_callback, local, remote)) < 0) { |
There was a problem hiding this comment.
_reg either returns 0 on success or < 0 on error. Thus you can shorten the function:
if ((res = _reg(...))) {
sock->sock.input_callback = NULL;
}
mutex_unlock(&sock->mutex);
return res;
There was a problem hiding this comment.
I think this makes the code harder to understand.
There was a problem hiding this comment.
How about:
res = _reg(...);
if (res) {
/* there was an error */
sock->sock.input_callback = NULL;
}
mutex_unlock(&sock->mutex);
return res;
There was a problem hiding this comment.
Disregarding the comment the still read "if there is a result, set input_callback to zero". Doing a boolean operation here makes this a lot clearer, IMHO (without requiring a comment).
There was a problem hiding this comment.
Please rephrase, I honestly don't understand what you mean.
There was a problem hiding this comment.
I think we talked past each other (thought you were talking about the < 0)... I wasn't aware anymore about the code below. Will fix.
| } | ||
| atomic_fetch_add(&sock->receivers, 1); | ||
| if (_mbox_get(&sock->mbox, &msg, blocking) == 0) { | ||
| return -EAGAIN; |
There was a problem hiding this comment.
is it possible to get here with the timer still active? in that case it must be removed.
There was a problem hiding this comment.
You mean the timeout timer? That's only active when timeout > 0. _mbox_get() returns 0 in non-blocking mode (timeout == 0). Will add a comment.
tests/emb6/udp.c
Outdated
| #ifdef MODULE_CONN_UDP | ||
| static char conn_inbuf[CONN_INBUF_SIZE]; | ||
| #ifdef MODULE_EMB6_SOCK_UDP | ||
| static char sock_inbuf[CONN_INBUF_SIZE]; |
|
Addressed comments. |
|
Fixed issues reported by Murdock (needed to rebase for that). |
|
Fixed/explained away errors reported by |
|
Any chance to get this merged today as well? |
|
(just want to make removal of |
| } | ||
| } | ||
| if (remote != NULL) { | ||
| udp_socket_connect(c, (uip_ipaddr_t *)&remote->addr, remote->port); |
There was a problem hiding this comment.
could fail, too? returns 1 on success and -1 on error see https://github.com/hso-esk/emb6/blob/c73091fd12d04ce91d9dfcac2a94196f3e7cb162/emb6/inc/sock/udp-socket.h#L140
There was a problem hiding this comment.
Because it only returns -1 if c or c->udp_conn is NULL, which can't happen at this point.
There was a problem hiding this comment.
mhm, I think that is exactly what happens below in L243 where _reg is called with &tmp and tmp->udp_conn is never set, hence NULL or something random.
There was a problem hiding this comment.
ah sorry remote == NULL, may bad
| if ((sock->sock.input_callback != NULL) && | ||
| (sock->sock.udp_conn->lport != 0)) { | ||
| mutex_lock(&sock->mutex); | ||
| memset(&ep->addr, 0, sizeof(ipv6_addr_t)); |
There was a problem hiding this comment.
why is address just set to all 0s and not copied from sock as in gnrc_sock_udp, for example?
There was a problem hiding this comment.
Because the local end point in emb6 doesn't have an address (since there are no interfaces).
| return -ENOTCONN; | ||
| } | ||
| /* cppcheck-suppress nullPointerRedundantCheck | ||
| * remote == NULL implies that sock != NULL (see assert at start of functon) |
| } | ||
| send_cmd.remote = remote; | ||
| } | ||
| if ((remote == NULL) && (sock->sock.udp_conn->rport == 0)) { |
There was a problem hiding this comment.
this could be
else if (sock->sock.udp_conn->rport == 0) {
return -ENOTCONN;
}
cause above you check remote != NULL hence if that is not the case, it must be remote == NULL
| * without checking (sock != NULL) first => this check afterwards isn't | ||
| * redundant */ | ||
| if (sock == NULL) { | ||
| int res; |
There was a problem hiding this comment.
Because it's the result of the send command, not the result of _reg() (and I don't want to dig into emb6's code now to make sure I don't have to zero it again bevore puttilng send_cmd in its event queue ;-))
kaspar030
left a comment
There was a problem hiding this comment.
minor changes, please squash after fixing!
tests/emb6/udp.c
Outdated
| port = (uint16_t)atoi((char *)args); | ||
| if ((res = conn_udp_create(&server_conn, &server_addr, | ||
| sizeof(server_addr), AF_INET6, port)) < 0) { | ||
| uint16_t port = (uint16_t)atoi((char *)args); |
tests/emb6/udp.c
Outdated
| } | ||
| /* parse port */ | ||
| port = (uint16_t)atoi(port_str); | ||
| dst.port = (uint16_t)atoi(port_str); |
|
Addressed comments and squashed |
|
Murdock's happy. :-) |
|
@smlng are you okay too? |
|
@miri64 shall we not also remove conn from the /contrib dir? |
Basically just an adapted carbon copy of
emb6_conn_udp. Testable withtests/emb6. Not in the mood to write more indepth test like for the more stable stacks ;-).