Skip to content

Commit dcbea25

Browse files
committed
src/modbus.c: _modbus_receive_msg(): we use a *backend* select(), not the standard one; do return from method if that implementation fails
Note that the primary "weird" use-case is about libusb backend; its _modbus_rtu_usb_select() ignores "rset" anyway, and talks to the libusb context. Signed-off-by: Jim Klimov <[email protected]>
1 parent 93d79d4 commit dcbea25

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/modbus.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type)
388388
if (ctx->s < 0) {
389389
if (ctx->debug) {
390390
/* we may not have an FD with e.g. libusb usage */
391-
fprintf(stderr, "Using a backend without a file descriptor, will not select() on it.\n");
391+
fprintf(stderr, "Using a backend without a file descriptor, will not natively select() on it.\n");
392392
}
393393
} else {
394394
FD_SET(ctx->s, &rset);
@@ -444,12 +444,7 @@ int _modbus_receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type)
444444
errno = saved_errno;
445445
#endif
446446
}
447-
if (ctx->s >= 0) {
448-
return -1;
449-
}
450-
// else: We have at most tried some default FD's but not
451-
// the (lacking) one for the backend, so fall through for
452-
// its recv method anyway (e.g. query libusb directly).
447+
return -1;
453448
}
454449

455450
rc = ctx->backend->recv(ctx, msg + msg_length, length_to_read);

0 commit comments

Comments
 (0)