Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jarvis Threading Model #67

Closed
PaulMansour opened this issue Jul 13, 2024 · 3 comments · Fixed by #68
Closed

Jarvis Threading Model #67

PaulMansour opened this issue Jul 13, 2024 · 3 comments · Fixed by #68

Comments

@PaulMansour
Copy link

Each HTTPHeader, HTTPBody, HTTPChunk and HTTPTrailer event is passed to HandleRequest in a new thread.

HandleRequest is wrapped in a :hold on the connection name.

I've recently discovered or rediscovered that :hold is not a fair mutex. So, if a few events on the same connection queue up on the :hold, I think they will not get access to the critical section in order.

This probably is not a big issue for un-chunked requests, as there are only two events that can happen (Header then Body), so there are never multiple threads waiting on the mutex (This could change if pipelining were implemented).

But I'm concerned about chunked messages. Is it not possible that chunks could queue up waiting for the mutex and then be serviced out of order?

@bpbecker
Copy link
Contributor

Hi Paul!

I've conferred with Bjørn about how HTTP chunks are processed and he's confident that the they will be handled in the order sent.

@PaulMansour
Copy link
Author

Is Bjørn confident that they are handled by Conga in the order sent (which I would hope) AND Jarvis (which is what I am concerned about)?

@bpbecker
Copy link
Contributor

Ah, I have a better understanding now. It seems your observation is accurate. :hold doesn't implement a FIFO model. For non-chunked requests, there shouldn't be an issue (unless we decide to support pipelining) as the only one HTTPBody event will occur after the HTTPHeader event. But with a chunked request., chunks could get processed out of order. I've got some ideas on how to address this... watch this space...

bpbecker added a commit that referenced this issue Jul 17, 2024
Addresses #67
Use tokens (⎕TPUT/⎕TGET) to implement FIFO queue for processing
@bpbecker bpbecker linked a pull request Jul 17, 2024 that will close this issue
bpbecker added a commit that referenced this issue Jul 18, 2024
* Ensure FIFO processing of HTTP events

Addresses #67 and #64 
Use tokens (⎕TPUT/⎕TGET) to implement FIFO queue for processing

* Remove debugging ⎕←

* Clean up tokens

Clean up on shutdown and when a connection is closed or times out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants