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
In example: Error and note #2739
Comments
Function Further in the text, the function returns the sign that the queue is completely full. That is, if the queue is full, we can start a new reading?? |
|
If I correctly understood the author’s idea, he assumed a request->response sequence with a quantity limit. The request has been processed, put into the submission queue, and we are ready to accept a new request. We shouldn't accept a new request if we can't save the result to the queue. |
|
if the queue is full we should not read the next request until there is room for a response, this will allow TCP/IP's natural application-level flow control to work properly |
Read carefully. I gave an example above. Start. queue size=0
Because in your (original) example we start a new read request when the send queue is full. This defeats the purpose of limiting the send queue. |
This is right. Good idea. |
@heretic13, I can confirm that there is a bug in this line:
This leads to a situation where we initiate another async_write while there is an ongoing one.
|
Version of Beast
At Boost 1_83.
I have some comments about this example.
https://www.boost.org/doc/libs/1_83_0/libs/beast/example/advanced/server/advanced_server.cpp
In function
void queue_write(http::message_generator response)
You do push_back first.
You then ensure that no work is done by checking size()==1 for the vector.
Abstracting from the container type, the empty() operation takes the same amount of time as size() or faster. It is more profitable to first check the vector for empty() and store the result in a variable. Then do push_back(). Then, depending on the value of the variable, execute do_write();
In function
bool do_write()
After checking !response_queue_.empty(), you retrieve the element from the vector and start the asynchronous operation.
If you look at the body of the queue_write() function, you can see that it controls the absence of an asynchronous operation by comparing the queue size with 1 (after adding an element).
Which is incorrect.
Example:
Start. queue size=0
starting an asynchronous operation. queue size=0
starting an asynchronous operation. queue size=0
We did not wait for the previous asynchronous operation to complete and started a new one.
The text was updated successfully, but these errors were encountered: