Skip to content

Commit c6e52d7

Browse files
committed
fix: read might return -1
1 parent 6cb7aa7 commit c6e52d7

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/esl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ void esl::run(void) {
247247
// receive from socket
248248
size_t bytesrx = dev_stream->read(&recv_buffer[0], ESL_PREFIX_SIZE + MAX_MTU);
249249

250-
if (bytesrx > (int)ESL_PREFIX_SIZE) {
250+
if ((ssize_t)bytesrx == -1) {
251+
continue;
252+
} else if (bytesrx > (int)ESL_PREFIX_SIZE) {
251253
if (memcmp(recv_buffer, recv_mac_id, 6) == 0) {
252254
struct esl_prefix *prefix = (struct esl_prefix *)&recv_buffer[0];
253255
int no = get_port_no(prefix->ctrl_state & ESL__CTRL_STATE__PORT_MASK);

0 commit comments

Comments
 (0)