Skip to content

Commit

Permalink
[fix] connect() filter caused a crash as used with a onState callback
Browse files Browse the repository at this point in the history
  • Loading branch information
pajama-coder committed Jun 21, 2024
1 parent e2cb55c commit d36b333
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/filters/connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ void Connect::process(Event *evt) {
}

try {
m_outbound->open();
if (bind) {
m_outbound->bind(bind->str());
} else if (options.protocol == Outbound::Protocol::NETLINK) {
Expand Down
6 changes: 4 additions & 2 deletions src/outbound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ auto Outbound::address() -> pjs::Str* {
return m_address;
}

void Outbound::open() {
state(Outbound::State::open);
}

void Outbound::close(StreamEnd *eos) {
InputContext ic;
retain();
Expand Down Expand Up @@ -260,7 +264,6 @@ OutboundTCP::OutboundTCP(EventTarget::Input *output, const Outbound::Options &op
, SocketTCP(false, Outbound::m_options)
, m_resolver(Net::context())
{
state(Outbound::State::open);
}

OutboundTCP::~OutboundTCP() {
Expand Down Expand Up @@ -514,7 +517,6 @@ OutboundUDP::OutboundUDP(EventTarget::Input *output, const Outbound::Options &op
, SocketUDP(false, Outbound::m_options)
, m_resolver(Net::context())
{
state(Outbound::State::open);
}

OutboundUDP::~OutboundUDP() {
Expand Down
1 change: 1 addition & 0 deletions src/outbound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class Outbound :
virtual auto get_traffic_in() ->size_t = 0;
virtual auto get_traffic_out() ->size_t = 0;

void open();
void close(StreamEnd *eos);

protected:
Expand Down

0 comments on commit d36b333

Please sign in to comment.