Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog.d/24838_dnstap_tcp_socket_leak.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Fix TCP socket leak in `dnstap` source where sockets would accumulate in `CLOSE_WAIT` state
indefinitely. After sending a FrameStream `FINISH` frame in response to a client `STOP`, Vector
now explicitly closes the write side of the TCP connection as required by the FrameStream protocol,
preventing `CLOSE_WAIT` accumulation that previously exhausted the connection limit after extended
operation.

authors: jpds
14 changes: 14 additions & 0 deletions src/sources/util/framestream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ impl FrameStreamReader {
self.send_control_frame(Self::make_frame(ControlHeader::Finish, None));
}
self.state.control_state = ControlState::Stopped; //stream is now done
// Close the write side of the connection after STOP/FINISH.
// Per the FrameStream protocol, the server should initiate TCP close
// after sending FINISH. Without this, sockets accumulate in CLOSE_WAIT
// because the client may wait for the server to close first.
self.close_sink();
}
_ => error!("Got wrong control frame, expected STOP."),
}
Expand Down Expand Up @@ -366,6 +371,15 @@ impl FrameStreamReader {
error!("Encountered error '{:#?}' while sending control frame.", e);
}
}

fn close_sink(&mut self) {
if let Err(e) = block_on(self.response_sink.lock().unwrap().close()) {
error!(
"Encountered error '{:#?}' while closing connection after FINISH.",
e
);
}
}
}

pub trait FrameHandler {
Expand Down
Loading