Skip to content

Commit

Permalink
Merge pull request libgit2#2121 from bk2204/ewouldblock
Browse files Browse the repository at this point in the history
Check for EWOULDBLOCK as well as EAGAIN on write.
  • Loading branch information
Vicent Marti committed Feb 18, 2014
2 parents dbd2ca3 + 0197d41 commit e0ebaaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int p_write(git_file fd, const void *buf, size_t cnt)
r = write(fd, b, cnt);
#endif
if (r < 0) {
if (errno == EINTR || errno == EAGAIN)
if (errno == EINTR || GIT_ISBLOCKED(errno))
continue;
return -1;
}
Expand Down
9 changes: 9 additions & 0 deletions src/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
#define O_CLOEXEC 0
#endif

/* Determine whether an errno value indicates that a read or write failed
* because the descriptor is blocked.
*/
#if defined(EWOULDBLOCK)
#define GIT_ISBLOCKED(e) ((e) == EAGAIN || (e) == EWOULDBLOCK)
#else
#define GIT_ISBLOCKED(e) ((e) == EAGAIN)
#endif

typedef int git_file;

/**
Expand Down

0 comments on commit e0ebaaa

Please sign in to comment.