You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2022/01/17 21:34:54 UTC

[plc4x] branch develop updated: PLC4X-323 Second attempt to fix memory issues with socketcan transport.

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

ldywicki 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 5729404  PLC4X-323 Second attempt to fix memory issues with socketcan transport.
5729404 is described below

commit 5729404fc33ad1a8675ecd6675d3c59347ff6292
Author: Łukasz Dywicki <lu...@code-house.org>
AuthorDate: Mon Jan 17 21:51:36 2022 +0100

    PLC4X-323 Second attempt to fix memory issues with socketcan transport.
    
    Given that buffer is re-used earlier usage with reset() call was inacurate.
    It did change buffer state and blocking further use.
    Fix which rely on rewind moves writer index to beginning of buffer making new data override old one.
    Also as it is only position change it does not involve re-allocation of memory.
    
    Signed-off-by: Łukasz Dywicki <lu...@code-house.org>
---
 .../plc4x/java/transport/socketcan/netty/SocketCANChannel.java     | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java b/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java
index 8cddba0..722360c 100644
--- a/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java
+++ b/plc4j/transports/socketcan/src/main/java/org/apache/plc4x/java/transport/socketcan/netty/SocketCANChannel.java
@@ -116,12 +116,7 @@ public class SocketCANChannel extends OioByteStreamChannel {
                 while (!isInputShutdown()) {
                     handle.readUnsafe(byteBuffer);
                     buffer.writeBytes(byteBuffer);
-//                    CanFrame frame = handle.read();
-//                    System.out.println("Read frame " + frame);
-//                    frameBytes.writeBytes(frame.getBuffer());
-//                    String dump = ByteBufUtil.prettyHexDump(frameBytes);
-//                    System.out.println(frame + "\n" + dump);
-//                    buffer.writeBytes(frame.getBuffer());
+                    byteBuffer.rewind();
                 }
             } catch (Exception e) {
                 logger.warn("Could not read data", e);