Skip to content

Commit 9a6bc21

Browse files
committed
Improve robustness when unplugging device
1 parent 76fdf87 commit 9a6bc21

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

java-does-usb/jextract/linux/gen_linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ $JEXTRACT --source --output ../../src/main/java \
77
--header-class-name errno \
88
--target-package net.codecrete.usb.linux.gen.errno \
99
--include-constant EPIPE \
10-
--include-constant EBADF \
1110
--include-constant EAGAIN \
1211
--include-constant EINVAL \
12+
--include-constant ENODEV \
1313
/usr/include/errno.h
1414

1515
# string.h

java-does-usb/src/main/java/net/codecrete/usb/linux/LinuxAsyncTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ private void reapURBs(int fd, MemorySegment urbPointerHolder, MemorySegment errn
159159
var err = Linux.getErrno(errnoState);
160160
if (err == errno.EAGAIN())
161161
return; // no more pending URBs
162-
if (err == errno.EBADF())
162+
if (err == errno.ENODEV())
163163
return; // ignore, device might have been closed
164164
throwException(err, "internal error (reap URB)");
165165
}

java-does-usb/src/main/java/net/codecrete/usb/linux/gen/errno/errno.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ public class errno {
1515
public static final OfAddress C_POINTER = Constants$root.C_POINTER$LAYOUT;
1616
/**
1717
* {@snippet :
18-
* #define EBADF 9
18+
* #define EAGAIN 11
1919
* }
2020
*/
21-
public static int EBADF() {
22-
return (int)9L;
21+
public static int EAGAIN() {
22+
return (int)11L;
2323
}
2424
/**
2525
* {@snippet :
26-
* #define EAGAIN 11
26+
* #define ENODEV 19
2727
* }
2828
*/
29-
public static int EAGAIN() {
30-
return (int)11L;
29+
public static int ENODEV() {
30+
return (int)19L;
3131
}
3232
/**
3333
* {@snippet :

0 commit comments

Comments
 (0)