You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/06/05 08:39:19 UTC

[plc4x] branch develop updated: fix(plc4go/eip): fix possible contention by using 1 buffered chan

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 85dcb43198 fix(plc4go/eip): fix possible contention by using 1 buffered chan
85dcb43198 is described below

commit 85dcb431983a6eeca7b3f05be4ea0a06c10f2ccb
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Jun 5 10:39:11 2023 +0200

    fix(plc4go/eip): fix possible contention by using 1 buffered chan
---
 plc4go/internal/eip/Connection.go | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/plc4go/internal/eip/Connection.go b/plc4go/internal/eip/Connection.go
index 2d854beea6..ece56dcff5 100644
--- a/plc4go/internal/eip/Connection.go
+++ b/plc4go/internal/eip/Connection.go
@@ -198,8 +198,8 @@ func (m *Connection) setupConnection(ctx context.Context, ch chan plc4go.PlcConn
 
 func (m *Connection) listServiceRequest(ctx context.Context, ch chan plc4go.PlcConnectionConnectResult) error {
 	m.log.Debug().Msg("Sending ListServices Request")
-	listServicesResultChan := make(chan readWriteModel.ListServicesResponse)
-	listServicesResultErrorChan := make(chan error)
+	listServicesResultChan := make(chan readWriteModel.ListServicesResponse, 1)
+	listServicesResultErrorChan := make(chan error, 1)
 	if err := m.messageCodec.SendRequest(ctx, readWriteModel.NewListServicesRequest(EmptySessionHandle, uint32(readWriteModel.CIPStatus_Success), []byte(DefaultSenderContext), uint32(0)), func(message spi.Message) bool {
 		eipPacket := message.(readWriteModel.EipPacket)
 		if eipPacket == nil {
@@ -242,8 +242,8 @@ func (m *Connection) listServiceRequest(ctx context.Context, ch chan plc4go.PlcC
 
 func (m *Connection) connectRegisterSession(ctx context.Context, ch chan plc4go.PlcConnectionConnectResult) error {
 	m.log.Debug().Msg("Sending EipConnectionRequest")
-	connectionResponseChan := make(chan readWriteModel.EipConnectionResponse)
-	connectionResponseErrorChan := make(chan error)
+	connectionResponseChan := make(chan readWriteModel.EipConnectionResponse, 1)
+	connectionResponseErrorChan := make(chan error, 1)
 	if err := m.messageCodec.SendRequest(ctx, readWriteModel.NewEipConnectionRequest(EmptySessionHandle, uint32(readWriteModel.CIPStatus_Success), []byte(DefaultSenderContext), uint32(0)), func(message spi.Message) bool {
 		eipPacket := message.(readWriteModel.EipPacket)
 		return eipPacket != nil
@@ -334,8 +334,8 @@ func (m *Connection) connectRegisterSession(ctx context.Context, ch chan plc4go.
 
 func (m *Connection) listAllAttributes(ctx context.Context, ch chan plc4go.PlcConnectionConnectResult) error {
 	m.log.Debug().Msg("Sending ListAllAttributes Request")
-	listAllAttributesResponseChan := make(chan readWriteModel.GetAttributeAllResponse)
-	listAllAttributesErrorChan := make(chan error)
+	listAllAttributesResponseChan := make(chan readWriteModel.GetAttributeAllResponse, 1)
+	listAllAttributesErrorChan := make(chan error, 1)
 	classSegment := readWriteModel.NewLogicalSegment(readWriteModel.NewClassID(uint8(0), uint8(2)))
 	instanceSegment := readWriteModel.NewLogicalSegment(readWriteModel.NewInstanceID(uint8(0), uint8(1)))
 	if err := m.messageCodec.SendRequest(ctx, readWriteModel.NewCipRRData(EmptyInterfaceHandle, 0,