SocketHandlers own the poller and add themself into it only when the socket is created
We want to call socket() with the parameters provided by getaddrinfo, so we can’t addd the fd into the poller immediately. We need to wait the connection attempt, and then the SocketHandler can call add_socket_handler itself, if the connection succeeds, or is in progress.
This commit is contained in:
@@ -47,7 +47,8 @@ static std::set<std::string> kickable_errors{
|
||||
"malformed-error"
|
||||
};
|
||||
|
||||
XmppComponent::XmppComponent(const std::string& hostname, const std::string& secret):
|
||||
XmppComponent::XmppComponent(std::shared_ptr<Poller> poller, const std::string& hostname, const std::string& secret):
|
||||
SocketHandler(poller),
|
||||
ever_auth(false),
|
||||
last_auth(false),
|
||||
served_hostname(hostname),
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
class XmppComponent: public SocketHandler
|
||||
{
|
||||
public:
|
||||
explicit XmppComponent(const std::string& hostname, const std::string& secret);
|
||||
explicit XmppComponent(std::shared_ptr<Poller> poller, const std::string& hostname, const std::string& secret);
|
||||
~XmppComponent();
|
||||
|
||||
void on_connection_failed(const std::string& reason) override final;
|
||||
|
||||
Reference in New Issue
Block a user