summaryrefslogtreecommitdiff
path: root/file_io/win32
Commit message (Collapse)AuthorAgeFilesLines
* Revert r1808456 (Win32: Don't seek to the end when opening files withkotkov2023-04-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | APR_FOPEN_APPEND). While this change fixed an issue where Windows and Unix reported different offsets after opening files for append, it also caused a regression: for files opened with APR_FOPEN_APPEND | APR_FOPEN_BUFFERED, flushing their contents would cause the contents to be written at offset 0, rather than appended. This happens because flushes and regular writes use different code paths. And while regular writes guarantee that an append will happen to the end of the file, a buffer flush uses a regular WriteFile(), assuming the file pointer has been properly set before. To fix both issues, we'd probably need to rework this part and make all writes use the same approach. But for now let's revert this change to fix the regression, that was also reported in [1]. I'll add a regression test for this problem separately. [1] https://lists.apache.org/thread/56gnyc3tc0orjh5mfsqo9gpq1br59b01 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1909088 13f79535-47bb-0310-9956-ffa450edef68
* Remove trailing whitespaces in *.c.ivan2022-11-2010-201/+201
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1905414 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/pipe.c: Use unsigned char instead of char for random buffer.ivan2022-07-091-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902600 13f79535-47bb-0310-9956-ffa450edef68
* win32: Remove unused ANSI compatibility code.ivan2022-06-171-9/+0
| | | | | | | | | | | * file_io/win32/filestat.c (more_finfo): Remove code to handle MORE_OF_FSPEC. * include/arch/win32/apr_arch_file_io.h (MORE_OF_FSPEC): Remove. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902014 13f79535-47bb-0310-9956-ffa450edef68
* Merge 'win32-pollset-wakeup-no-file-socket-emulation' branch to trunk.ivan2022-02-092-246/+5
| | | | | | | | | | Rework win32 poll wakeup implementation: - Explicitly use apr_socket_t instead of apr_file_t for wakeup `pipe` - Remove code in win32 apr_file_t implementation that emulates working with sockets as files. Sockets on Windows are not kernel objects and should be used only via Winsock API. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1897895 13f79535-47bb-0310-9956-ffa450edef68
* Win32: Minor optimization of apr_stat() and apr_file_info_get().ivan2022-01-051-2/+4
| | | | | | | | | * file_io/win32/filestat.c (reparse_point_is_link, apr_stat): Use FindFirstFileExW(FindExInfoBasic) instead of FindFirstFileW(). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896724 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/filestat.civan2022-01-051-2/+1
| | | | | | | | (reparse_point_is_link): Cast to more correct type. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896721 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/filestat.c:ivan2022-01-051-1/+0
| | | | | | | | (apr_stat): Remove unused union member. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896720 13f79535-47bb-0310-9956-ffa450edef68
* Remove Windows 95 compatibility code.ivan2022-01-053-78/+36
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896719 13f79535-47bb-0310-9956-ffa450edef68
* Fix a regression in apr_stat() for root path on Windows caused by the extendedivan2022-01-051-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | symlink detection added in r1855949 (PR47630) [1]. See [2] for the detailed problem report and discussion. The code before this patch performs FindFirstFile() whenever APR_FINFO_LINK is passed. This is problematic for at least two reasons: 1) Any attempt to detect if the root is a symlink now fails because FindFirstFile() cannot be called for the root directory 2) Any check that includes the APR_FINFO_LINK flag now calls FindFirstFile(), which essentially is a "readdir". Previously, ordinary files could have been processed with a much cheaper call to GetFileAttributesEx(). In other words, there is a significant performance penalty for stat(... | APR_FINFO_LINK) in a common case. Fix this by postponing a call to FindFirstFile() until we actually need the file tag information to resolve the reparse point. [1] https://bz.apache.org/bugzilla/show_bug.cgi?id=47630 [2] https://lists.apache.org/thread/18x2jb81nf6zrjsnwf1k2wwooprkp0p5 * file_io/win32/filestat.c (apr_stat): Call FindFirstFile() only when asking for the true name with APR_FINFO_NAME. Adjust the related check. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896717 13f79535-47bb-0310-9956-ffa450edef68
* Follow-up to r1896625: Add typecast.ivan2022-01-021-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896626 13f79535-47bb-0310-9956-ffa450edef68
* Refactor code for further code improvements.ivan2022-01-021-1/+51
| | | | | | | | * file_io/win32/filestat.c (apr_file_info_get): Inline fillin_fileinfo() to apr_file_info_get(). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896625 13f79535-47bb-0310-9956-ffa450edef68
* Optimize apr_file_mtime_set() on Windows.ivan2022-01-021-11/+2
| | | | | | | | | * file_io/win32/filestat.c (apr_file_mtime_set): Pass NULL as ATIME and CTIME when calling SetFileTime() to prevent changing ATIME and CTIME instead of retrieving these times using GetFileTime(). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896623 13f79535-47bb-0310-9956-ffa450edef68
* TAB police ... get rid of missmatch of TAB and spaces through the codemturk2021-12-025-200/+200
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895516 13f79535-47bb-0310-9956-ffa450edef68
* Get rid of check for old versions that cannot be run anyhowmturk2021-12-022-9/+4
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895512 13f79535-47bb-0310-9956-ffa450edef68
* Stage 3 in cleaning win95 code ... cleanup headersmturk2021-12-021-10/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895511 13f79535-47bb-0310-9956-ffa450edef68
* Stage 2 in cleaning win95 code ... cleanup filesysmturk2021-12-024-497/+208
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895510 13f79535-47bb-0310-9956-ffa450edef68
* Stage 3 in dismantling _WIN32_WCE ... cleanup codemturk2021-12-024-37/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895508 13f79535-47bb-0310-9956-ffa450edef68
* Fix remaining change when apr_filetype_e was addedmturk2021-12-011-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895465 13f79535-47bb-0310-9956-ffa450edef68
* Use enum instead multiple booleansmturk2021-11-192-16/+13
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895181 13f79535-47bb-0310-9956-ffa450edef68
* Use random bytes like with named pipes as socket pipe identifiermturk2021-11-191-8/+10
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895179 13f79535-47bb-0310-9956-ffa450edef68
* Fix typomturk2021-11-191-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895178 13f79535-47bb-0310-9956-ffa450edef68
* Sync WIN32 local function names with 1.7.x branch -- no functional changemturk2021-11-191-4/+4
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895177 13f79535-47bb-0310-9956-ffa450edef68
* Follow up to r1895106: Use less expensive atomics for wakeup.ylavic2021-11-192-40/+72
| | | | | | | | | | | | | | | | | | If pipe writers (wakeup) put a single byte until it's consumed by the reader (drain), it's enough to use an atomic cas for the writers (still) and an atomic (re)set for the reader (no more cas here). This requires that the reader never blocks on read though (e.g. spurious return from poll), so make the read side on the pipe non-blocking again/finally. Since synchronous non-blocking read is not a thing for Windows' Readfile(), add a ->socket flag to this arch's apr_file_t (like the existing ->pipe one) which file_socket_pipe_create() will set to make apr_file_read/write() handle non-blocking (nor overlapped) socket pipes with WSARecv/Send(). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895175 13f79535-47bb-0310-9956-ffa450edef68
* Follow up to r1893204: restore apr_file_setaside() semantics, fix ↵ylavic2021-09-191-0/+1
| | | | | | | | | | | | | | | file_bucket_setaside(). apr_file_setasidea() needs to invalidate the old file descriptor per semantics: * @remark After calling this function, old_file may not be used So to avoid the setaside issue with splitted file buckets, file_bucket_setaside() will now apr_file_dup() instead of apr_file_setaside() when the bucket is shared (i.e. refcount > 1). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1893445 13f79535-47bb-0310-9956-ffa450edef68
* apr_file_setaside: don't blindly kill the old cleanup and file descriptor.ylavic2021-09-101-4/+2
| | | | | | | | | | | There is no cleanup with APR_FOPEN_NOCLEANUP, so apr_pool_cleanup_kill() can go in the !(old_file->flags & APR_FOPEN_NOCLEANUP) block. The file descriptor can't be invalidated either, the file may be split in multiple buckets and setting aside one shouldn't invalidate the others. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1893204 13f79535-47bb-0310-9956-ffa450edef68
* Be more forceful in identifying EBADPATHwrowe2020-01-161-2/+4
| | | | | | Even when the path is first identified as a wildcard path. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1872893 13f79535-47bb-0310-9956-ffa450edef68
* ucs2 is a legacy name, the correct encoding nameswrowe2019-10-291-3/+3
| | | | | | | | | | | | | | | | are now utf-8, utf-16, and utf-32, so we rename; apr_conv_utf8_to_ucs2 -> apr_conv_utf8_to_utf16 apr_conv_ucs2_to_utf8 -> apr_conv_utf16_to_utf8 This patch notices an error message printing of an internal password, which will no longer be echoed to the error stream. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1869127 13f79535-47bb-0310-9956-ffa450edef68
* Revert r1862435, r1862071 per veto from ivanjorton2019-08-281-8/+2
| | | | | | | msgid: <CABw-3YcK0qbeYWDOwE684XtBj3rCT2CuVOBWWqda4gMtRyRJEw@mail.gmail.com> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1866019 13f79535-47bb-0310-9956-ffa450edef68
* * include/apr_file_info.h: Clarify pool handling for apr_dir_read andjorton2019-07-021-1/+1
| | | | | | | | | | | | | | apr_dir_pread. * file_io/win32/dir.c, file_io/os2/dir.c (apr_dir_read): Duplicate the returned filename so the call has no side-effects on apr_finfo_t structures passed to previous invocations of the function. * test/testdir.c (test_read_side_effects): Add test case for side-effects of apr_dir_read. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1862435 13f79535-47bb-0310-9956-ffa450edef68
* Add apr_dir_pread(), a variant of apr_dir_read() which allows callersjorton2019-06-251-1/+7
| | | | | | | | | | | | | | | | | to read a directory with constant memory consumption: * include/apr_file_info.h: Add warning on memory consumption for apr_dir_read; declare apr_dir_pread. * file_io/unix/dir.c (apr_dir_pread): Rename from apr_dir_read and take pool argument. (apr_dir_read): Reimplement using it. * file_io/win32/dir.c, file_io/os2/dir.c: Likewise, but untested. * test/testdir.c (test_pread) [APR_POOL_DEBUG]: Add test case. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1862071 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/dir.civan2019-06-071-2/+0
| | | | | | | (apr_read_dir): Remove duplicate local variable declaration. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860750 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/dir.civan2019-06-071-10/+1
| | | | | | | (apr_read_dir): Remove Windows Vista compatibility code. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860749 13f79535-47bb-0310-9956-ffa450edef68
* * include/arch/win32/apr_arch_file_io.hivan2019-06-071-8/+8
| | | | | | | | | (apr_dir_t): Remove union needed for ANSI support. * file_io/win32/dir.c (apr_dir_open, apr_dir_read): Update code to the changes above. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860748 13f79535-47bb-0310-9956-ffa450edef68
* Windows platform: Fix access to uninitialized memory in apr_dir_read() whenivan2019-06-071-1/+11
| | | | | | wanted is more than APR_FINFO_MIN. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860747 13f79535-47bb-0310-9956-ffa450edef68
* Windows platform: Remove ANSI codepath from apr_dir_*().ivan2019-06-071-192/+85
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860745 13f79535-47bb-0310-9956-ffa450edef68
* Use manual reset events for OVERLAPPED I/O on Windows: I/O operations resetivan2019-05-272-5/+5
| | | | | | | | | | | | | | | | | | | | | provided event to non-signaled state automatically [1]. Using automatic reset events is not recommended: [[[ Functions such as ReadFile and WriteFile set this handle to the nonsignaled state before they begin an I/O operation. When the operation has completed, the handle is set to the signaled state. Functions such as GetOverlappedResult and the synchronization wait functions reset auto-reset events to the nonsignaled state. Therefore, you should use a manual reset event; if you use an auto-reset event, your application can stop responding if you wait for the operation to complete and then call GetOverlappedResult with the bWait parameter set to TRUE. ]]] [1] https://docs.microsoft.com/en-gb/windows/desktop/api/minwinbase/ns-minwinbase-_overlapped git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860110 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/open.civan2019-05-271-1/+2
| | | | | | (read_with_timeout): Reduce local variable scope. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860109 13f79535-47bb-0310-9956-ffa450edef68
* Optimize overlapped I/O for files and pipes on Windows.ivan2019-05-271-10/+30
| | | | | | | | | * file_io/win32/open.c (read_with_timeout, apr_file_write): Check that overlapped I/O operation already completed by macro HasOverlappedIoCompleted() before calling kernel via WaitForSingleObject(). git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860108 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/readwrite.civan2019-05-271-8/+6
| | | | | | | | | | | (read_with_timeout): We do not handle WAIT_ABANDONED here because they can be returned only when waiting for mutex [1], but not for events. [1] https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-waitforsingleobject#return-value git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860107 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/open.civan2019-05-271-5/+2
| | | | | | (make_sparse_file): Use apr_wait_for_single_object() helper. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860106 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/readwrite.civan2019-05-271-18/+5
| | | | | | (read_with_timeout, apr_file_write): Use apr_wait_for_single_object() helper. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860105 13f79535-47bb-0310-9956-ffa450edef68
* Follow-up to r1860045: Fix condition.ivan2019-05-261-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860050 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/filestat.civan2019-05-261-3/+2
| | | | | | (apr_file_attrs_set): Refactoring: do not assign BOOL to apr_status_t. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860046 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/filestat.civan2019-05-261-8/+15
| | | | | | | (apr_file_attrs_set): Don't do anything if we are not going to change attributes. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860045 13f79535-47bb-0310-9956-ffa450edef68
* win32: Remove ANSI codepath from apr_file_attrs_set().ivan2019-05-261-30/+6
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860044 13f79535-47bb-0310-9956-ffa450edef68
* win32: Correctly cancel write operation on timeout.ivan2019-05-261-19/+31
| | | | | | | | | | * file_io/win32/readwrite.c (apr_file_write): Get operation result after we cancelled I/O operation: operation may be finished after we got timeout, but before CancelIoEx() call. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860042 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/readwrite.civan2019-05-262-3/+3
| | | | | | | | (apr_file_write): Use CancelIoEx() instead of CancelIo() to protect from potential race condition. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860038 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/readwrite.civan2019-05-261-2/+1
| | | | | | | | (apr_file_write): Remove check for apr_os_level >= APR_WIN_98 before CancelIo() call. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1860035 13f79535-47bb-0310-9956-ffa450edef68
* Follow-up to r1859473: Fix stupid typo: use *OFFSET instead of OFFSET inivan2019-05-181-1/+1
| | | | | | apr_file_seek() on Windows. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1859476 13f79535-47bb-0310-9956-ffa450edef68