summaryrefslogtreecommitdiff
path: root/file_io
Commit message (Collapse)AuthorAgeFilesLines
* Revert r1808456 (Win32: Don't seek to the end when opening files withEvgeny Kotkov2023-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.Ivan Zhakov2022-11-2034-393/+393
| | | | 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.Ivan Zhakov2022-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.Ivan Zhakov2022-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
* On 'win32-pollset-wakeup-no-file-socket-emulation' branch:Ivan Zhakov2022-01-201-37/+5
| | | | | | | | | | | | | | | | 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. * file_io/win32/readwrite.c (): Do not include apr_arch_networkio.h. (read_with_timeout): Remove APR_FILETYPE_SOCKET support code. * include/arch/win32/apr_arch_file_io.h (apr_filetype_e): Remove APR_FILETYPE_SOCKET enum value. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/win32-pollset-wakeup-no-file-socket-emulation@1897254 13f79535-47bb-0310-9956-ffa450edef68
* On 'win32-pollset-wakeup-no-file-socket-emulation' branch:Ivan Zhakov2022-01-201-178/+0
| | | | | | | | | Windows: Use term `socket_pipe` instead for `file_socket_pipe` for internal poll wakeup socket API. Move implementation to network_io/win32/socket_pipe.c from file_io/win32/pipe.c. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/win32-pollset-wakeup-no-file-socket-emulation@1897246 13f79535-47bb-0310-9956-ffa450edef68
* On 'win32-pollset-wakeup-no-file-socket-emulation' branch:Ivan Zhakov2022-01-201-8/+4
| | | | | | | | | | | | | Set socket nonblocking mode for socket using apr_socket_timeout_set(). Patch by: ylavic * file_io/win32/pipe.c (create_socket_pipe): Remove code to set SOCKET to nonblocking mode. (apr_file_socket_pipe_create): Set IN socket to nonblocking mode. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/win32-pollset-wakeup-no-file-socket-emulation@1897245 13f79535-47bb-0310-9956-ffa450edef68
* On 'win32-pollset-wakeup-no-file-socket-emulation' branch:Ivan Zhakov2022-01-191-43/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Windows: For the pollset wakeup, use apr_socket_t directly instead of using a socket disguised as an apr_file_t. * file_io/win32/pipe.c (): Include apr_arch_networkio.h. (socket_pipe_cleanup, apr_file_socket_pipe_create, apr_file_socket_pipe_close): Update to use apr_socket_t instead of apr_file_t. * include/arch/unix/apr_arch_poll_private.h (WAKEUP_USES_PIPE): New #define to specify mechanism used for pollset wakeup. (apr_pollset_t, apr_pollcb_t): Add wakeup_socket if not WAKEUP_USES_PIPE. (apr_poll_create_wakeup_socket, apr_poll_close_wakeup_socket, apr_poll_drain_wakeup_socket): Declare if not WAKEUP_USES_PIPE. * include/arch/win32/apr_arch_file_io.h (apr_file_socket_pipe_create, apr_file_socket_pipe_close): Update to use apr_socket_t instead of apr_file_t. * poll/unix/poll.c (impl_pollset_add): Remove hack that allows apr_file_t even if APR_FILES_AS_SOCKETS == 0. (impl_pollset_poll, impl_pollcb_poll): Use wakeup_pipe or wakeup_socket depending of WAKEUP_USES_PIPE. * poll/unix/pollcb.c (pollcb_cleanup, apr_pollcb_create_ex, apr_pollcb_wakeup): Use wakeup_pipe or wakeup_socket depending of WAKEUP_USES_PIPE. * poll/unix/pollset.c (pollset_cleanup, apr_pollset_create_ex, apr_pollset_wakeup): Use wakeup_pipe or wakeup_socket depending of WAKEUP_USES_PIPE. * poll/unix/select.c (impl_pollset_add): Remove hack that allows apr_file_t even if APR_FILES_AS_SOCKETS == 0. (impl_pollset_poll): Use wakeup_pipe or wakeup_socket depending of WAKEUP_USES_PIPE. * poll/unix/wakeup.c (apr_poll_create_wakeup_pipe): Rename to apr_poll_create_wakeup_socket() on Windows and use apr_socket_t instead of apr_file_t. (apr_poll_close_wakeup_pipe): Rename to apr_poll_close_wakeup_socket() on Windows and use apr_socket_t instead of apr_file_t. (apr_poll_drain_wakeup_socket): New. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/win32-pollset-wakeup-no-file-socket-emulation@1897208 13f79535-47bb-0310-9956-ffa450edef68
* Win32: Minor optimization of apr_stat() and apr_file_info_get().Ivan Zhakov2022-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.cIvan Zhakov2022-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:Ivan Zhakov2022-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.Ivan Zhakov2022-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 extendedIvan Zhakov2022-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.Ivan Zhakov2022-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.Ivan Zhakov2022-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.Ivan Zhakov2022-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 codeMladen Turk2021-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 anyhowMladen Turk2021-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 headersMladen Turk2021-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 filesysMladen Turk2021-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 codeMladen Turk2021-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 addedMladen Turk2021-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 booleansMladen Turk2021-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 identifierMladen Turk2021-11-191-8/+10
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895179 13f79535-47bb-0310-9956-ffa450edef68
* Fix typoMladen Turk2021-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 changeMladen Turk2021-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.Yann Ylavic2021-11-192-40/+72
| | | | | | | | | | | | | | | | | | If pipe writers (wakeup) put a single byte until consume it's consumed by the reader (drain), an atomic cas for the writers (still) and an atomic (re)set for the reader is enough (not need to cas on the reader side). This requires that the reader never blocks on read though (e.g. spurious return from poll), so (re)make the read side on the pipe non-blocking (finally). Since synchronous non-blocking read is not a thing for Windows' Readfile(), add a ->socket flag this arch's to 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 ↵Yann Ylavic2021-09-193-0/+3
| | | | | | | | | | | | | | | 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.Yann Ylavic2021-09-103-11/+6
| | | | | | | | | | | 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
* Follow up to r1790200: fall back to fsync() if F_FULLFSYNC is not supportedBranko Čibej2020-11-121-3/+9
| | | | | | | | | by the file descriptor, filesystem or underlying device. See, e.g.: https://github.com/vim/vim/pull/4025 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883340 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/unix/readwrite.c (apr_file_write, apr_file_writev): FixJoe Orton2020-06-011-6/+10
| | | | | | | | Coverity warnings from ignored lseek() return value in ->buffered handling. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1878343 13f79535-47bb-0310-9956-ffa450edef68
* apr_file_mktemp: clear APR_FOPEN_NOCLEANUP if not requested.Yann Ylavic2020-05-291-1/+4
| | | | | | | | | | | | | | | apr_os_file_put() adds no cleanup so it forces APR_FOPEN_NOCLEANUP, but when apr_file_mktemp() adds the cleanup implicitely (unless the user specifies APR_FOPEN_NOCLEANUP explicitely), it needs to clear APR_FOPEN_NOCLEANUP for the resulting file. Note: Without this fix, a file created with apr_file_mktemp() and later passed to apr_file_setaside(), or within a file bucket passed to apr_bucket_setaside(), will leak both the fd and inode because the cleanup gets dropped (e.g. httpd's BZ 64452). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1878279 13f79535-47bb-0310-9956-ffa450edef68
* Be more forceful in identifying EBADPATHWilliam A. Rowe Jr2020-01-161-2/+4
| | | | | | Even when the path is first identified as a wildcard path. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1872893 13f79535-47bb-0310-9956-ffa450edef68
* ucs2 is a legacy name, the correct encoding namesWilliam A. Rowe Jr2019-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: https://svn.apache.org/repos/asf/apr/apr/trunk@1869127 13f79535-47bb-0310-9956-ffa450edef68
* Revert r1862435, r1862071 per veto from ivanJoe Orton2019-08-283-26/+10
| | | | | | | msgid: <CABw-3YcK0qbeYWDOwE684XtBj3rCT2CuVOBWWqda4gMtRyRJEw@mail.gmail.com> git-svn-id: https://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 andJoe Orton2019-07-022-2/+2
| | | | | | | | | | | | | | 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: https://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 callersJoe Orton2019-06-253-8/+24
| | | | | | | | | | | | | | | | | 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: https://svn.apache.org/repos/asf/apr/apr/trunk@1862071 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/unix/filedup.c (file_dup): Add assert() for possible values Joe Orton2019-06-251-0/+4
| | | | | | | of which_dup to help static analysers. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1862068 13f79535-47bb-0310-9956-ffa450edef68
* Fix typoChristophe Jaillet2019-06-131-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1861263 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/dir.cIvan Zhakov2019-06-071-2/+0
| | | | | | | (apr_read_dir): Remove duplicate local variable declaration. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860750 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/dir.cIvan Zhakov2019-06-071-10/+1
| | | | | | | (apr_read_dir): Remove Windows Vista compatibility code. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860749 13f79535-47bb-0310-9956-ffa450edef68
* * include/arch/win32/apr_arch_file_io.hIvan Zhakov2019-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: https://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() whenIvan Zhakov2019-06-071-1/+11
| | | | | | wanted is more than APR_FINFO_MIN. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860747 13f79535-47bb-0310-9956-ffa450edef68
* Windows platform: Remove ANSI codepath from apr_dir_*().Ivan Zhakov2019-06-071-192/+85
| | | | git-svn-id: https://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 resetIvan Zhakov2019-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: https://svn.apache.org/repos/asf/apr/apr/trunk@1860110 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/open.cIvan Zhakov2019-05-271-1/+2
| | | | | | (read_with_timeout): Reduce local variable scope. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860109 13f79535-47bb-0310-9956-ffa450edef68
* Optimize overlapped I/O for files and pipes on Windows.Ivan Zhakov2019-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: https://svn.apache.org/repos/asf/apr/apr/trunk@1860108 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/readwrite.cIvan Zhakov2019-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: https://svn.apache.org/repos/asf/apr/apr/trunk@1860107 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/open.cIvan Zhakov2019-05-271-5/+2
| | | | | | (make_sparse_file): Use apr_wait_for_single_object() helper. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860106 13f79535-47bb-0310-9956-ffa450edef68
* * file_io/win32/readwrite.cIvan Zhakov2019-05-271-18/+5
| | | | | | (read_with_timeout, apr_file_write): Use apr_wait_for_single_object() helper. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1860105 13f79535-47bb-0310-9956-ffa450edef68