making lseek explicitly adjust file offset.

This commit is contained in:
Manoj Ampalam 2016-05-30 00:53:33 -07:00
parent 946ed7d297
commit ff96264aae
3 changed files with 13 additions and 12 deletions

View File

@ -1664,9 +1664,6 @@
#define BROKEN_SYS_TERMIO_H #define BROKEN_SYS_TERMIO_H
#define strerror strerror_win32
#define strerror strerror_win32
// PRAGMA SYS PORT // PRAGMA SYS PORT
#define WITH_OPENSSL 1 #define WITH_OPENSSL 1

View File

@ -223,7 +223,7 @@ createFile_flags_setup(int flags, int mode, struct createFile_flags* cf_flags) {
if (c_s_flags & O_EXCL) if (c_s_flags & O_EXCL)
cf_flags->dwCreationDisposition = CREATE_NEW; cf_flags->dwCreationDisposition = CREATE_NEW;
else else
cf_flags->dwCreationDisposition = OPEN_ALWAYS; cf_flags->dwCreationDisposition = CREATE_ALWAYS;
} }
if (c_s_flags & O_APPEND) if (c_s_flags & O_APPEND)
@ -301,7 +301,7 @@ VOID CALLBACK ReadCompletionRoutine(
/* initiate an async read */ /* initiate an async read */
/* TODO: make this a void func, store error in context */ /* TODO: make this a void func, store error in context */
int int
fileio_ReadFileEx(struct w32_io* pio) { fileio_ReadFileEx(struct w32_io* pio, unsigned int bytes_requested) {
debug2("ReadFileEx io:%p", pio); debug2("ReadFileEx io:%p", pio);
if (pio->read_details.buf == NULL) { if (pio->read_details.buf == NULL) {
@ -311,9 +311,13 @@ fileio_ReadFileEx(struct w32_io* pio) {
debug2("ReadFileEx - ERROR: %d, io:%p", errno, pio); debug2("ReadFileEx - ERROR: %d, io:%p", errno, pio);
return -1; return -1;
} }
pio->read_details.buf_size = READ_BUFFER_SIZE;
} }
if (FILETYPE(pio) == FILE_TYPE_DISK)
pio->read_details.buf_size = min(bytes_requested, READ_BUFFER_SIZE);
else
pio->read_details.buf_size = READ_BUFFER_SIZE;
if (ReadFileEx(WINHANDLE(pio), pio->read_details.buf, pio->read_details.buf_size, if (ReadFileEx(WINHANDLE(pio), pio->read_details.buf, pio->read_details.buf_size,
&pio->read_overlapped, &ReadCompletionRoutine)) &pio->read_overlapped, &ReadCompletionRoutine))
pio->read_details.pending = TRUE; pio->read_details.pending = TRUE;
@ -353,7 +357,7 @@ fileio_read(struct w32_io* pio, void *dst, unsigned int max) {
return -1; return -1;
} }
else { else {
if (-1 == fileio_ReadFileEx(pio)) { if (-1 == fileio_ReadFileEx(pio, max)) {
if ((FILETYPE(pio) == FILE_TYPE_PIPE) if ((FILETYPE(pio) == FILE_TYPE_PIPE)
&& (errno == ERROR_BROKEN_PIPE)) { && (errno == ERROR_BROKEN_PIPE)) {
/* write end of the pipe closed */ /* write end of the pipe closed */
@ -560,8 +564,8 @@ fileio_lseek(struct w32_io* pio, long offset, int origin) {
return -1; return -1;
} }
//NO-OP as we automatically move file pointer in async io callbacks for files pio->read_overlapped.Offset = offset;
//assert current postion in overlapped struct pio->write_overlapped.Offset = offset;
return 0; return 0;
} }
@ -625,7 +629,7 @@ fileio_on_select(struct w32_io* pio, BOOL rd) {
} }
} }
else { else {
if (fileio_ReadFileEx(pio) != 0) { if (fileio_ReadFileEx(pio, INT_MAX) != 0) {
pio->read_details.error = errno; pio->read_details.error = errno;
errno = 0; errno = 0;
return; return;

View File

@ -1320,7 +1320,7 @@ process_rmdir(u_int32_t id)
static void static void
process_realpath(u_int32_t id) process_realpath(u_int32_t id)
{ {
char resolvedname[PATH_MAX]; char resolvedname[PATH_MAX+ 1];
char *path; char *path;
int r; int r;
//#ifdef WIN32_FIXME //#ifdef WIN32_FIXME