Skip to content

Commit

Permalink
Also check EWOULDBLOCK as well as EAGAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jan 21, 2020
1 parent 25f2005 commit 5798d35
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions io.c
Expand Up @@ -316,7 +316,6 @@ rb_cloexec_open(const char *pathname, int flags, mode_t mode)
static const int retry_max_count = 10000;

int retry_count = 0;
int e;

#ifdef O_CLOEXEC
/* O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
Expand All @@ -325,15 +324,11 @@ rb_cloexec_open(const char *pathname, int flags, mode_t mode)
flags |= O_NOINHERIT;
#endif

while (1) {
ret = open(pathname, flags, mode);
e = errno;

if (ret != -1 || e != EAGAIN || retry_count >= retry_max_count) {
break;
}
while ((ret = open(pathname, flags, mode)) == -1) {
int e = errno;
if (e != EAGAIN && e != EWOULDBLOCK) break;
if (retry_count++ >= retry_max_count) break;

retry_count++;
sleep(retry_interval);
}

Expand Down

0 comments on commit 5798d35

Please sign in to comment.