Skip to content

Commit aa11439

Browse files
Fcntl setting Non Blocking operations improvement
1 parent 7c17693 commit aa11439

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

platform/source/mbed_retarget.cpp

Lines changed: 7 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,12 @@ 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+
int ret = fhc->set_blocking(false);
1196+
if (ret < 0) {
1197+
errno = -ret;
1198+
return -1;
1199+
}
11981200
}
11991201
return 0;
12001202
}

0 commit comments

Comments
 (0)