You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I test my broker that uses mqtt_cpp, I noticed that accepting process of server_tls, server_ws, and server_tls_ws behaves unexpectedly.
The function do_accept() is called after asynchronous underlying processes (handshake, websocket upgrade, etc) are finished.
If underlying processes are stuck, then the next do_accept() isn't called until timeout(#295 ) happens.
Solution
The next do_accept() should be called in the TCP accept handler.
Then asynchronous underlying processes can run concurrently each sockets.
Required change
Remove std::unique_ptr<socket_t> socket_ member variables. It is avoiding concurrent process.
Instead of that, create socket_t object locally each do_accept() call. This is common accepting pattern. It requires std::shared_ptr<socket_t> for the local variable socket.
Problem
When I test my broker that uses mqtt_cpp, I noticed that accepting process of
server_tls
,server_ws
, andserver_tls_ws
behaves unexpectedly.The function
do_accept()
is called after asynchronous underlying processes (handshake, websocket upgrade, etc) are finished.If underlying processes are stuck, then the next
do_accept()
isn't called until timeout(#295 ) happens.Solution
The next
do_accept()
should be called in the TCP accept handler.Then asynchronous underlying processes can run concurrently each sockets.
Required change
Remove
std::unique_ptr<socket_t> socket_
member variables. It is avoiding concurrent process.mqtt_cpp/include/mqtt/server.hpp
Line 359 in 5802d04
Instead of that, create socket_t object locally each
do_accept()
call. This is common accepting pattern. It requiresstd::shared_ptr<socket_t>
for the local variable socket.mqtt_cpp/include/mqtt/server.hpp
Line 311 in 5802d04
The text was updated successfully, but these errors were encountered: