Skip to content

gnrc_tcp: improvement: Replace tcbs msg queue with mbox#6969

Merged
smlng merged 1 commit intoRIOT-OS:masterfrom
brummer-simon:gnrc_tcp-replace_msg_queue
May 17, 2017
Merged

gnrc_tcp: improvement: Replace tcbs msg queue with mbox#6969
smlng merged 1 commit intoRIOT-OS:masterfrom
brummer-simon:gnrc_tcp-replace_msg_queue

Conversation

@brummer-simon
Copy link
Copy Markdown
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
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 :)

@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
Copy Markdown
Member

smlng commented May 17, 2017

please squash

@brummer-simon
Copy link
Copy Markdown
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