Skip to content

Commit 82c19c7

Browse files
committed
fix(agent): ensure proper closure of TCP and UDP listeners on disable
1 parent 2f7a2d1 commit 82c19c7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

agent/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ func main() {
168168
fmt.Println("[OK]")
169169

170170
fmt.Println("TLS certificates loaded successfully!")
171-
fmt.Println("NOTE: You may need to restart integrations with TLS enabled for changes to take effect.")
172171
time.Sleep(5 * time.Second)
173172

174173
case "check-tls-certs":

agent/modules/syslog.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ func (m *SyslogModule) enableUDP() {
258258
func (m *SyslogModule) disableTCP() {
259259
if m.TCPListener.IsEnabled && m.TCPListener.Port != "" {
260260
utils.Logger.Info("Server %s closed in port: %s protocol: TCP", m.DataType, m.TCPListener.Port)
261+
262+
if m.TCPListener.Listener != nil {
263+
if err := m.TCPListener.Listener.Close(); err != nil {
264+
utils.Logger.ErrorF("error closing TCP listener: %v", err)
265+
}
266+
}
267+
261268
m.TCPListener.Cancel()
262269
m.TCPListener.IsEnabled = false
263270
}
@@ -266,6 +273,13 @@ func (m *SyslogModule) disableTCP() {
266273
func (m *SyslogModule) disableUDP() {
267274
if m.UDPListener.IsEnabled && m.UDPListener.Port != "" {
268275
utils.Logger.Info("Server %s closed in port: %s protocol: UDP", m.DataType, m.UDPListener.Port)
276+
277+
if m.UDPListener.Listener != nil {
278+
if err := m.UDPListener.Listener.Close(); err != nil {
279+
utils.Logger.ErrorF("error closing UDP listener: %v", err)
280+
}
281+
}
282+
269283
m.UDPListener.Cancel()
270284
m.UDPListener.IsEnabled = false
271285
}

0 commit comments

Comments
 (0)