Skip to content

Commit

Permalink
Fcntl setting Non Blocking operations improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
tymoteuszblochmobica committed Jun 8, 2021
1 parent 7c17693 commit aa11439
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 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,12 @@ 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 aa11439

Please sign in to comment.