Skip to content

Commit ac37b81

Browse files
committed
websocket: fix double disconnect handler for incomer
1 parent 9a56a68 commit ac37b81

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

topology/probes/ovsdb/ovs_of.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ func makeFilter(rule *Rule) string {
310310
// Execute exposes an interface to command launch on the OS
311311
type Execute interface {
312312
ExecCommand(string, ...string) ([]byte, error)
313-
ExecCommandPipe(context.Context, string, ...string) (io.Reader, interface{ Wait() error }, error)
313+
ExecCommandPipe(context.Context, string, ...string) (io.Reader, interface {
314+
Wait() error
315+
}, error)
314316
}
315317

316318
// RealExecute is the actual implementation given below. It can be overridden for tests.
@@ -326,7 +328,9 @@ func (r RealExecute) ExecCommand(com string, args ...string) ([]byte, error) {
326328
}
327329

328330
// ExecCommandPipe executes a command on a host and gives back a pipe to control it.
329-
func (r RealExecute) ExecCommandPipe(ctx context.Context, com string, args ...string) (io.Reader, interface{ Wait() error }, error) {
331+
func (r RealExecute) ExecCommandPipe(ctx context.Context, com string, args ...string) (io.Reader, interface {
332+
Wait() error
333+
}, error) {
330334
/* #nosec */
331335
command := exec.CommandContext(ctx, com, args...)
332336
out, err := command.StdoutPipe()

topology/probes/ovsdb/ovs_of_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ func (r ExecuteForTest) ExecCommand(com string, args ...string) ([]byte, error)
193193
return []byte(result), nil
194194
}
195195

196-
func (r ExecuteForTest) ExecCommandPipe(ctx context.Context, com string, args ...string) (io.Reader, interface{ Wait() error }, error) {
196+
func (r ExecuteForTest) ExecCommandPipe(ctx context.Context, com string, args ...string) (io.Reader, interface {
197+
Wait() error
198+
}, error) {
197199
return strings.NewReader(r.Flow), r, nil
198200
}
199201

websocket/client.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,6 @@ func (c *Client) Connect() error {
536536
l.OnConnected(c)
537537
}
538538

539-
// in case of a handler disconnect the client directly
540-
if !c.IsConnected() {
541-
return errors.New("Aborting connection to the server")
542-
}
543-
544539
return nil
545540
}
546541

@@ -549,7 +544,10 @@ func (c *Client) Start() {
549544
go func() {
550545
for c.running.Load() == true {
551546
if err := c.Connect(); err == nil {
552-
c.Run()
547+
// in case of a handler disconnect the client directly
548+
if c.IsConnected() {
549+
c.Run()
550+
}
553551
} else {
554552
logging.GetLogger().Error(err)
555553
}

websocket/message.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ func (s *StructServer) OnConnected(c Speaker) {
494494

495495
// OnDisconnected removes the Speaker from the incomer pool.
496496
func (s *StructServer) OnDisconnected(c Speaker) {
497-
s.Server.incomerPool.RemoveClient(c)
498497
}
499498

500499
// NewStructServer returns a new StructServer

0 commit comments

Comments
 (0)