Skip to content

Conversation

brummer-simon
Copy link
Member

@brummer-simon brummer-simon commented Apr 26, 2017

GNRC TCP improvement:

Currently the GNRC TCP API functions assign a message queue to a calling thread to store messages for TCP operation. This assignment is problematic in cases where the caller uses a message queue outside to the TCP context.

To solve this issue, I replaced the message queue with an mbox stored in the TCB.

@smlng smlng self-requested a review April 26, 2017 08:04
@smlng smlng added this to the Release 2017.07 milestone Apr 26, 2017
@smlng smlng added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking labels Apr 26, 2017
@brummer-simon brummer-simon force-pushed the gnrc_tcp-replace_msg_queue branch from 799a33d to c1e23e2 Compare April 26, 2017 13:16
@@ -75,8 +76,8 @@ typedef struct _transmission_control_block {
xtimer_t tim_tout; /**< Timer struct for timeouts */
msg_t msg_tout; /**< Message, sent on timeouts */
gnrc_pktsnip_t *pkt_retransmit; /**< Pointer to packet in "retransmit queue" */
kernel_pid_t owner; /**< PID of this connection handling thread */
msg_t msg_queue[GNRC_TCP_TCB_MSG_QUEUE_SIZE]; /**< TCB message queue */
msg_t mbox_raw[GNRC_TCP_TCB_MSG_QUEUE_SIZE]; /**< TCB message queue */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update comment and MACRO to match usage of mbox, its no message queue (in that sense) anymore 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in the evening

{
msg_t msg;
msg.type = ((cb_arg_t *) arg)->msg_type;
mbox_try_put(((cb_arg_t *) arg)->mbox_ptr, &msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this safe? This will access tcb->mbox without a mutex locked, or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming that its safe, whats the point of having a synchronization utility that can't be used concurrently?

Copy link
Member Author

@brummer-simon brummer-simon May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And those functions are only called on timer expiry. The setup and teardown of the timers are enclosed in a mutex protected sections.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhm, right - but somehow I feel you should pass the whole tcb to this function, and check its state before putting the message. For instance, I'm unsure (you are the expert) what happens if the connection was reset or aborted in the meantime; that is: before the timer fires and this callback is processed?

Copy link
Member Author

@brummer-simon brummer-simon May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that does this is placing a message in a mbox (actually it would be a nice function for xtimer ;) ). Upon message retrieval the TCB state is checked before an action is taken. It should be safe but I check for your concerns later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't dig any deeper into this, just some quick thoughts - likely I'm wrong, but that's why I'm asking you 😄

Copy link
Member Author

@brummer-simon brummer-simon May 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into this. Its better to double check than overlook a hidden race condition ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay checked the usage of the callback function, it seems safe to me. On timer expiration the connection should be terminated in most cases anyway so the current state is mostly irrelevant. It seems fine to me :)

@brummer-simon brummer-simon force-pushed the gnrc_tcp-replace_msg_queue branch 2 times, most recently from 363f82f to 516a964 Compare May 8, 2017 17:19
@smlng smlng added CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 12, 2017
@smlng
Copy link
Member

smlng commented May 17, 2017

please squash

@brummer-simon brummer-simon force-pushed the gnrc_tcp-replace_msg_queue branch from 516a964 to 42e15ed Compare May 17, 2017 11:03
@brummer-simon
Copy link
Member Author

Done

@smlng smlng added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 17, 2017
@smlng smlng merged commit f0ae5d2 into RIOT-OS:master May 17, 2017
@brummer-simon brummer-simon deleted the gnrc_tcp-replace_msg_queue branch May 17, 2017 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants