Skip to content

Commit

Permalink
Improvement of fcntl() non blocking setting
Browse files Browse the repository at this point in the history
  • Loading branch information
tymoteuszblochmobica committed Jun 8, 2021
1 parent 3a05db8 commit 1abb2c7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions platform/source/mbed_retarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ extern "C" int fcntl(int fildes, int cmd, ...)
switch (cmd) {
case F_GETFL: {
int flags = 0;
if (fhc->is_blocking()) {
if (!fhc->is_blocking()) {
flags |= O_NONBLOCK;
}
return flags;
Expand All @@ -1191,10 +1191,13 @@ extern "C" int fcntl(int fildes, int cmd, ...)
va_start(ap, cmd);
int flags = va_arg(ap, int);
va_end(ap);
int ret = fhc->set_blocking(flags & O_NONBLOCK);
if (ret < 0) {
errno = -ret;
return -1;
if (flags & O_NONBLOCK)
{
int ret = fhc->set_blocking(false);
if (ret < 0) {
errno = -ret;
return -1;
}
}
return 0;
}
Expand Down

0 comments on commit 1abb2c7

Please sign in to comment.