This is an automated email from Gerrit.

"Timur Golubovich <timur.golubov...@syntacore.com>" just uploaded a new patch 
set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8321

-- gerrit

commit 242667023e821ae1ca08c8360c090313736aaa02
Author: Timur Golubovich <timur.golubov...@syntacore.com>
Date:   Fri Jun 7 16:42:16 2024 +0300

    Fixed situation when fails assert.
    
    Changes affect the function remote_bitbang_fill_buf.
    When read_socket returns 0, socket reached EOF and there is
    no data to read. But if request was blocking, the caller
    expected some data. Such situations should be treated as ERROR.
    
    Change-Id: If76795e5756fd5317897b13389d6bcdaa64eb097
    Signed-off-by: Timur Golubovich <timur.golubov...@syntacore.com>

diff --git a/src/jtag/drivers/remote_bitbang.c 
b/src/jtag/drivers/remote_bitbang.c
index 53d2151fdc..ff89ec5506 100644
--- a/src/jtag/drivers/remote_bitbang.c
+++ b/src/jtag/drivers/remote_bitbang.c
@@ -114,12 +114,18 @@ static int remote_bitbang_fill_buf(enum block_bool block)
                                contiguous_available_space);
                if (first && block == BLOCK)
                        socket_nonblock(remote_bitbang_fd);
-               first = false;
                if (count > 0) {
                        remote_bitbang_recv_buf_end += count;
                        if (remote_bitbang_recv_buf_end == 
sizeof(remote_bitbang_recv_buf))
                                remote_bitbang_recv_buf_end = 0;
                } else if (count == 0) {
+                       /* When read_socket returns 0, socket reached EOF and 
there is
+                        * no data to read. But if request was blocking, the 
caller
+                        * expected some data. Such situations should be 
treated as ERROR. */
+                       if (first && block == BLOCK) {
+                               LOG_ERROR("remote_bitbang: socket EOF");
+                               return ERROR_FAIL;
+                       }
                        return ERROR_OK;
                } else if (count < 0) {
 #ifdef _WIN32
@@ -133,6 +139,7 @@ static int remote_bitbang_fill_buf(enum block_bool block)
                                return ERROR_FAIL;
                        }
                }
+               first = false;
        }
 
        return ERROR_OK;

-- 

Reply via email to