[libbluray-devel] file_posix: ignore EINTR
hpi1
git at videolan.org
Fri Mar 6 08:59:15 CET 2015
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Mar 6 09:57:32 2015 +0200| [49014b79a7feb5adf7748b6556467c340a741f72] | committer: hpi1
file_posix: ignore EINTR
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=49014b79a7feb5adf7748b6556467c340a741f72
---
src/file/file_posix.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/file/file_posix.c b/src/file/file_posix.c
index 7257c9d..374d200 100644
--- a/src/file/file_posix.c
+++ b/src/file/file_posix.c
@@ -26,6 +26,7 @@
#include "util/macro.h"
#include "util/logging.h"
+#include <errno.h>
#include <inttypes.h>
#include <stdio.h> // remove()
#include <stdlib.h>
@@ -81,8 +82,11 @@ static int64_t file_read_linux(BD_FILE_H *file, uint8_t *buf, int64_t size)
for (got = 0; got < (ssize_t)size; got += result) {
result = read((int)(intptr_t)file->internal, buf + got, size - got);
if (result < 0) {
- BD_DEBUG(DBG_FILE, "read() failed (%p)\n", (void*)file);
- break;
+ if (errno != EINTR) {
+ BD_DEBUG(DBG_FILE, "read() failed (%p)\n", (void*)file);
+ break;
+ }
+ result = 0;
} else if (result == 0) {
// hit EOF.
break;
@@ -103,8 +107,11 @@ static int64_t file_write_linux(BD_FILE_H *file, const uint8_t *buf, int64_t siz
for (written = 0; written < (ssize_t)size; written += result) {
result = write((int)(intptr_t)file->internal, buf + written, size - written);
if (result < 0) {
- BD_DEBUG(DBG_FILE, "write() failed (%p)\n", (void*)file);
- break;
+ if (errno != EINTR) {
+ BD_DEBUG(DBG_FILE, "write() failed (%p)\n", (void*)file);
+ break;
+ }
+ result = 0;
}
}
return (int64_t)written;
@@ -152,7 +159,7 @@ static BD_FILE_H *file_open_linux(const char* filename, const char *cmode)
file->internal = (void*)(intptr_t)fd;
- BD_DEBUG(DBG_FILE, "Opened LINUX file %s... (%p)\n", filename, (void*)file);
+ BD_DEBUG(DBG_FILE, "Opened LINUX file %s (%p)\n", filename, (void*)file);
return file;
}
More information about the libbluray-devel
mailing list