Skip to content

Conversation

@tbursztyka
Copy link
Contributor

But reference it once more to make sure it will not disappear during
packet allocation.

That way, the lock is not going to be held during net_pkt allocation.

Fixes #14571

Signed-off-by: Tomasz Bursztyka [email protected]

But reference it once more to make sure it will not disappear during
packet allocation.

That way, the lock is not going to be held during net_pkt allocation.

Fixes zephyrproject-rtos#14571

Signed-off-by: Tomasz Bursztyka <[email protected]>
@tbursztyka
Copy link
Contributor Author

@dgloeck have a look

@tbursztyka
Copy link
Contributor Author

There are many places where prepare_segment is used without the context to be locked before, in tcp. Only one place using send_ack() was, for some reason. Sounds fragile.

struct net_pkt *pkt;

/* We reference it once again to make sure context is not going
* to disappear while allocating a packet
Copy link
Contributor

Choose a reason for hiding this comment

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

What would make it disappear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there any guaranty that net_context_unref() is not going to be called one time too many (or net_context_put) in the mean time? allocation might take a while depending on load. The application could close the socket (thus the context) for instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

The application could close the socket (thus the context) for instance.

Right. And as I mentioned in the next comment (in the main comment thread), this touches on other (proposed) changes, e.g. #9565 , which vice-versa try to remove ref/unref wrapping, about which I came to conclusion that it's superfluous. Is it right or not? I wish we had a clear rules and understanding where we need to lock/unlock, and where ref/unref. As certainly, a case addressed by this PR is not the only one.

@pfalcon pfalcon requested review from pfalcon and rlubos March 19, 2019 12:05
@pfalcon
Copy link
Contributor

pfalcon commented Mar 19, 2019

net/context: Unlock the context while allocating a net_pkt
That way, the lock is not going to be held during net_pkt allocation.

And - why is that important, what does it give? Please don't just stamp "Fixes #14571", describe the issue in the commit message.

Otherwise, this touches on #8008, #13667, #9565 , and I'm not sure if it goes in the same direction as those, against them, or largely orthogonal (I would hope and guess for the latter).

@pfalcon
Copy link
Contributor

pfalcon commented Mar 25, 2019

@dgloeck, @tbursztyka: I believe the situation with this patch is as follows: This patch is an alternative to a patch originally proposed by @dgloeck (reference to which I can't even find now). So, I would say that other reviewer wait for the discussion between you guys, whose patch better addresses this issue. Hope you can get to it soon, as the issue appears to be serious and worth fixing. Thanks.

@pfalcon
Copy link
Contributor

pfalcon commented Mar 25, 2019

@tbursztyka: Btw, this needs rebase to fix conflict.

@pfalcon
Copy link
Contributor

pfalcon commented Mar 25, 2019

This patch is an alternative to a patch originally proposed by @dgloeck (reference to which I can't even find now)

Ah, ok, @dgloeck didn't submit his patch as a PR, it's available at dgloeck@e61634c (based on comment #14571 (comment))

@tbursztyka
Copy link
Contributor Author

replaced by #14944

@tbursztyka tbursztyka closed this Mar 27, 2019
@tbursztyka tbursztyka deleted the tcp_context_fix branch April 1, 2019 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants