Skip to content

Commit 1abb2c7

Browse files
Improvement of fcntl() non blocking setting
1 parent 3a05db8 commit 1abb2c7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

platform/source/mbed_retarget.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ extern "C" int fcntl(int fildes, int cmd, ...)
11811181
switch (cmd) {
11821182
case F_GETFL: {
11831183
int flags = 0;
1184-
if (fhc->is_blocking()) {
1184+
if (!fhc->is_blocking()) {
11851185
flags |= O_NONBLOCK;
11861186
}
11871187
return flags;
@@ -1191,10 +1191,13 @@ extern "C" int fcntl(int fildes, int cmd, ...)
11911191
va_start(ap, cmd);
11921192
int flags = va_arg(ap, int);
11931193
va_end(ap);
1194-
int ret = fhc->set_blocking(flags & O_NONBLOCK);
1195-
if (ret < 0) {
1196-
errno = -ret;
1197-
return -1;
1194+
if (flags & O_NONBLOCK)
1195+
{
1196+
int ret = fhc->set_blocking(false);
1197+
if (ret < 0) {
1198+
errno = -ret;
1199+
return -1;
1200+
}
11981201
}
11991202
return 0;
12001203
}

0 commit comments

Comments
 (0)