summaryrefslogtreecommitdiff
path: root/network_io
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing whitespaces in *.c.ivan2022-11-2013-209/+209
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1905414 13f79535-47bb-0310-9956-ffa450edef68
* Remove a useless variable that is shadowing another already existing one.jailletc362022-11-181-1/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1905386 13f79535-47bb-0310-9956-ffa450edef68
* Following up on r1904715, rework the check to properly handle ankotkov2022-10-201-7/+2
| | | | | | | | | | overflow when apr_size_t is 32-bit long. * network_io/win32/sendrecv.c (apr_socket_sendv): As above. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1904734 13f79535-47bb-0310-9956-ffa450edef68
* Win32: Stop apr_socket_sendv() from splitting iovecs into multiple possiblekotkov2022-10-201-31/+21
| | | | | | | | | | | | | | | | | | WSABUFs and error out on theoretical cases that cannot be handled with a single WSASend(). WSASend() returns the NumberOfBytesSent as DWORD, so the previous code that splitted overflowing iovecs never worked, as the total number of sent bytes cannot be properly represented by the API. So let's maintain a 1:1 relationship between the iovecs and WSABUFs, and error out on all inputs that exceed MAXDWORD. * network_io/win32/sendrecv.c (apr_socket_sendv): Remove the code that splits iovecs into WSABUFs. Check the sizes of all iovecs and the total size. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1904715 13f79535-47bb-0310-9956-ffa450edef68
* Revert r1902312, r1904699 in preparation for a slightly different change.kotkov2022-10-201-62/+26
| | | | | | | | | | | | Shortlog: - r1902312: apr_socket_sendv: WIN32: Limit the number of WSABUFs allocated for a single call. - r1904699: apr_socket_sendv: WIN32: Follow up to r1902312: Avoid short writes. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1904714 13f79535-47bb-0310-9956-ffa450edef68
* apr_socket_sendv: WIN32: Follow up to r1902312: Avoid short writes.ylavic2022-10-191-30/+57
| | | | | | | | | | | | | | | | | | | | | | | | | We possibly (edge cases) can't send an entire iovec array in a single WSASend() call because structs WSABUF and iovec are ABI incompatible. To avoid breaking users that rely on full-write by apr_socket_sendv(), which supposedly is guaranteed by WSASend(), repeat the call until the given iovec array is exhausted. There is no way to provide both full-write and atomicity guarantees for apr_socket_sendv() on Windows, so we choose the former.. * include/apr_network_io.h: Document apr_socket_sendv() full-write/atomicity (non-)guarantees above the system ones. * network_io/win32/sendrecv.c(apr_socket_sendv): Change to a loop on WSASend() when needed, taking care of its API limits w.r.t. the given struct iovec. [Reverted by r1904714] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1904699 13f79535-47bb-0310-9956-ffa450edef68
* Replace tabs to spaces.ivan2022-07-081-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902583 13f79535-47bb-0310-9956-ffa450edef68
* apr_socket_sendv: unix: APR_INCOMPLETE_WRITE pre to post processing.ylavic2022-06-281-7/+10
| | | | | | | | | | | | Rather than precomputing requested_len before writev() and later comparing with what has been sent, we can walk the iovec after only to see if it's exhausted. This saves useless precomputation on error (e.g. nonblocking EAGAIN) and avoids a poteential invalid/overflowed requested_len should the iovec point to more than SIZE_MAX bytes. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902314 13f79535-47bb-0310-9956-ffa450edef68
* apr_socket_sendv: WIN32: Limit the number of WSABUFs allocated for a single ↵ylavic2022-06-281-12/+21
| | | | | | | | | | | | | | | call. * network_io/win32/sendrecv.c(): Define WSABUF_ON_HEAP to 500. * network_io/win32/sendrecv.c(apr_socket_sendv): Do not sendv more than WSABUF_ON_HEAP WSABUFs. [Reverted by r1904714] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902312 13f79535-47bb-0310-9956-ffa450edef68
* Merge 'win32-pollset-wakeup-no-file-socket-emulation' branch to trunk.ivan2022-02-091-0/+195
| | | | | | | | | | 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
* apr_sockaddr_ip_getbuf: Follow up to r1883728.ylavic2022-01-121-3/+4
| | | | | | | | Return APR_ENOSPC if returned buf is truncated for an AF_UNIX. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896956 13f79535-47bb-0310-9956-ffa450edef68
* Stage 3 in dismantling _WIN32_WCE ... cleanup codemturk2021-12-022-31/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1895508 13f79535-47bb-0310-9956-ffa450edef68
* Follow up to r1895106: Use less expensive atomics for wakeup.ylavic2021-11-191-1/+15
| | | | | | | | | | | | | | | | | | 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 r1883728: uncomment the change, and fix apr_cpystrn() args orrder.ylavic2020-11-231-2/+2
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883742 13f79535-47bb-0310-9956-ffa450edef68
* apr_sockaddr_ip_get[buf]: handle APR_UNIX family.ylavic2020-11-221-0/+8
| | | | | | | For unix sockets, return the path (sun_path). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1883728 13f79535-47bb-0310-9956-ffa450edef68
* Remove the APR_SENDFILE_DISCONNECT_SOCKET flag.ivan2019-09-201-34/+13
| | | | | | | | | | | | | | | | | | There are several problems with this flag: 1. The TCP socket may be subject to the TCP TIME_WAIT state. That means apr_sock_sendfile() could occupy worker thread for significant time (30 seconds) 2. With this flag specified, the socket descriptor is removed from the apr_socket_t and the caller caller is expected to maintain the descriptor and release it manually, which is particularly error-prone. See also: https://lists.apache.org/thread.html/a3c4a03961a4b5842e7f657a15fe777edf5949b768a2807619a104b1@%3Cdev.apr.apache.org%3E git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1867226 13f79535-47bb-0310-9956-ffa450edef68
* win32: Use TF_USE_KERNEL_APC for TransmitFile(). According to theivan2019-09-141-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | documentation [1] TF_USE_KERNEL_APC is the most performant option: [[[ Directs the driver to use kernel asynchronous procedure calls (APCs) instead of worker threads to process long TransmitFile requests. Long TransmitFile requests are defined as requests that require more than a single read from the file or a cache; the request therefore depends on the size of the file and the specified length of the send packet. Use of TF_USE_KERNEL_APC can deliver significant performance benefits. It is possible (though unlikely), however, that the thread in which context TransmitFile is initiated is being used for heavy computations; this situation may prevent APCs from launching. ]]] The downside is not applicable for our use case since calling thread is not busy and waiting for operation completion. [1] https://docs.microsoft.com/en-gb/windows/win32/api/mswsock/nf-mswsock-transmitfile git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1866934 13f79535-47bb-0310-9956-ffa450edef68
* win32: Do not use TransmitFile directly. According to documentationivan2019-09-141-7/+25
| | | | | | | | | | | | | | TransmitFile() should not be used directly and pointer to function should retrieved using WSAIoctl: https://docs.microsoft.com/en-gb/windows/win32/api/mswsock/nf-mswsock-transmitfile#remarks * network_io/win32/sendrecv.c (apr_socket_sendfile): Retrieve pointer to TransmitFile using WSAIoctl. * CMakeLists.txt (APR_SYSTEM_LIBS): Remove reference to mswsock.lib. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1866932 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/win32/sendrecv.civan2019-09-141-4/+0
| | | | | | | (apr_socket_sendfile): Remove Windows 95 compatibility code. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1866928 13f79535-47bb-0310-9956-ffa450edef68
* Windows: create non-inheritable sockets in one step instead of creating aivan2019-06-111-20/+28
| | | | | | | | | | | | | | | | socket and only then marking it as non-inheritable. This protects against a potential socket handle leak in case of certain race conditions. See also: https://support.microsoft.com/en-us/help/2398202/an-application-may-stop-responding-when-the-application-closes-a-socke * network_io/win32/sockets.c (apr_socket_create): Use the WSA_FLAG_NO_HANDLE_INHERITED when supported by the OS. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1861073 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/win32/sockets.c: Remove ANSI codepath.ivan2019-06-111-33/+11
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1861043 13f79535-47bb-0310-9956-ffa450edef68
* Small corrections to if_indextoname resolution on win32, compiles cleanwrowe2019-03-191-2/+2
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1855864 13f79535-47bb-0310-9956-ffa450edef68
* Replace the link-time pragma from r1839494 with APR_DECLARE_LATE_DLL_FUNC wrowe2019-03-191-1/+0
| | | | | | | | resolution of if_indextoname and if_nametoindex. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1855855 13f79535-47bb-0310-9956-ffa450edef68
* Fix breakage on _WIN32_WINNT>=0x0600 due to if_indextoname,wrowe2018-08-281-0/+5
| | | | | | | | | | | | it is wrapped in a very odd way on Windows, both the includes and required libraries. Using a pragma to create a link time resolution for the required lib is simplest. Submitted by: jeking3 https://github.com/apache/apr/pull/7/commits/1fb97b8bd0b02fe71945b03986f3c69fb4270b6b git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1839493 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/unix/sockaddr.c (apr_sockaddr_zone_set): Failjorton2017-11-291-1/+2
| | | | | | | | | | | for an address which is not link-local. * include/apr_network_io.h: Document the above. * test/testsock.c (test_zone): Test for that. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1816628 13f79535-47bb-0310-9956-ffa450edef68
* Support IPv6 link-local address scope/zone mapping.jorton2017-11-281-3/+97
| | | | | | | | | | | | | | | | | | | | * network_io/unix/sockaddr.c (apr_sockaddr_zone_set, apr_sockaddr_zone_get): New functions. (apr_sockaddr_ip_getbuf): Append %scope for link-local address. (apr_sockaddr_equal): Compare link-local address with different scopes as not equal. * include/apr_network_io.h: Add function declarations. * configure.in: Test for if_indextoname and if_nametoindex. * test/testsock.c (test_zone): New test case. * include/arch/win32/apr_private.h: Assume Windows supports if_nametoindex and if_indextoname. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1816527 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/unix/sockaddr.c (apr_parse_addr_port): Fix regression injorton2017-10-251-1/+1
| | | | | | | | | | | scope id parsing introduced in r1683521. * test/testipsub.c (test_parse_addr_port): New function. Submitted by: rjung, jorton git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1813286 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/unix/sockaddr.c (looks_like_ip): Fail for the emptyjorton2017-09-111-0/+4
| | | | | | | | | | string. * test/testipsub.c: Test that calling apr_ipsubnet_create with the empty string fails. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1808039 13f79535-47bb-0310-9956-ffa450edef68
* apr_socket_listen(): Allow larger backlog queue lengths on Windows 8+.ivan2017-08-171-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Starting with Windows 8, the socket listen() function accepts a special SOMAXCONN_HINT(N) argument that allows making the backlog queue length larger than the otherwise predefined limit of around 200: https://msdn.microsoft.com/en-us/library/windows/desktop/ms739168 https://blogs.msdn.microsoft.com/winsdk/2015/06/01/winsocks-listen-backlog-offers-more-flexibility-in-windows-8/ Having a larger listen backlog can be used for certain high performance applications that need to handle lots of incoming connections. One example would be the httpd server with it's "ListenBacklog" directive where setting it to a larger value currently allows serving more concurrent connections on Windows with mpm_winnt. * include/arch/win32/apr_arch_misc.h (enum apr_oslevel_e): Add APR_WIN_8. * misc/win32/misc.c (apr_get_oslevel): Determine whether we are running on Windows 7 or on Windows 8+. * network_io/win32/sockets.c (SOMAXCONN_HINT): Define this macro in case we are building against an older version of Windows SDK. (apr_socket_listen): Use SOMAXCONN_HINT() for the backlog queue length if it's supported by the Windows version we are running on. Patch by: Evgeny Kotkov <evgeny.kotkov {at} visualsvn.com> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1805309 13f79535-47bb-0310-9956-ffa450edef68
* apr_socket_sendfile:ylavic2017-03-281-76/+68
| | | | | | | | | | | | | | Be accurate (and consistent accross unixes) with the returned number of bytes written (note that it is possible for both bytes to be sent and an error to be returned, due to headers and trailers handling). Fix some returned errno vs apr_status_t in some error paths. Fix BSDs nonblocking/busy retry on EAGAIN when nothing is written. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1789257 13f79535-47bb-0310-9956-ffa450edef68
* apr_socket_sendfile: don't reset APR_TCP_NOPUSH if we didn't set it.ylavic2017-03-281-10/+24
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1789249 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/unix/sockopt.c (apr_socket_opt_set): Return APR_ENOTIMPLjorton2016-03-041-1/+1
| | | | | | | for APR_SO_FREEBIND on FreeBSD. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1733594 13f79535-47bb-0310-9956-ffa450edef68
* * include/apr_network_io.h (APR_SO_FREEBIND): Add option.jorton2016-03-031-0/+14
| | | | | | | | | | | | * network_io/unix/sockopt.c (apr_socket_opt_set): Implement APR_SO_FREEBIND on Linux with IP_FREEBIND * test/testsock.c (test_freebind): Add test case. Submitted by: Ashley GC, jkaluza, jorton git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1733451 13f79535-47bb-0310-9956-ffa450edef68
* fix comparison of sin6_addrsf2015-08-161-1/+1
| | | | | | | | | | | | One cannot assume that sin6_addr is located at the start of sa_data. For example, glibc puts sin6_flowinfo there. Fix by casting to the proper type first. Reported by Andre Naujoks <nautsch2 gmail com> via https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759534 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1696140 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/unix/sockaddr.c (apr_parse_addr_port): Simplify to usejorton2015-06-041-11/+3
| | | | | | | apr_pstrmemdup, no functional change. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1683521 13f79535-47bb-0310-9956-ffa450edef68
* Follow up to r1666341: fix missing apr_socket_create() and ↵ylavic2015-03-201-4/+10
| | | | | | apr_socket_accept() cases. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1667916 13f79535-47bb-0310-9956-ffa450edef68
* *) On z/OS, apr_sockaddr_info_get() with family == APR_UNSPEC was not covener2014-10-271-0/+10
| | | | | | | | | | returning IPv4 addresses if any IPv6 addresses were returned. [Eric Covener] git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1634615 13f79535-47bb-0310-9956-ffa450edef68
* Add apr_sockaddr_info_copy(), for making a deep copy of antrawick2014-04-131-0/+36
| | | | | | | | | | apr_sockaddr_t into a specified pool. Submitted by: Yann Ylavic <ylavic.dev gmail.com> Reviewed by: trawick git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1587045 13f79535-47bb-0310-9956-ffa450edef68
* Fix the inheritance of the non-blocking option across apr_socket_accept()trawick2013-12-171-1/+14
| | | | | | | | | | | | | | | | | | | | | | on FreeBSD 10 which was introduced with APR 1.5.0 through an unlikely mechanism: * FreeBSD 10 introduced accept4(). APR uses accept4() where it can find it. accept4() on Linux and FreeBSD 10 both have a SOCK_NONBLOCK flag, but on FreeBSD 10 the SOCK_NONBLOCK is the sole determiner of whether or not the connected socket is non-blocking. * clang is normally used on FreeBSD 10. * APR's configure-time check for inherited O_NONBLOCK didn't work with clang, so initially the lack of inheritance across accept4() wasn't a problem. * APR 1.5.0 allowed the configure-time check to work with clang, exposing the bad expectation about accept4() matching the accept() behavior. With FreeBSD accept4() (avail in 10+), O_NONBLOCK is not inherited (unlike Linux). Mimic the accept() behavior here in a way that may help other platforms as well. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1551659 13f79535-47bb-0310-9956-ffa450edef68
* Follow up to r1543033:trawick2013-11-181-5/+1
| | | | | | | | | Use the new code required for OS X/Darwin on the other platforms too. (IOW, we're willing to peek in the socket as long as APR_POLLIN is returned, regardless of other flags.) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1543056 13f79535-47bb-0310-9956-ffa450edef68
* OSX (Darwin) returns APR_POLLHUP|APR_POLLIN, so thejim2013-11-181-0/+5
| | | | | | | test for equality fails. Instead, just check for the bit. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1543033 13f79535-47bb-0310-9956-ffa450edef68
* add apr_sockaddr_is_wildcard() APItrawick2013-11-121-0/+29
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1541061 13f79535-47bb-0310-9956-ffa450edef68
* follow up to r1523384: if we disable non-blocking when a timeout is set, ↵trawick2013-09-161-0/+1
| | | | | | forget that non-blocking is enabled git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1523615 13f79535-47bb-0310-9956-ffa450edef68
* On Windows, a socket timeout isn't implemented withtrawick2013-09-151-1/+1
| | | | | | | | | non-blocking socket + poll. When a socket is non- blocking and a timeout is set, the non-blocking state must be disabled. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1523384 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/unix/multicast.c (do_mcast_opt): Fix regression injorton2013-05-301-2/+10
| | | | | | | handling IPv4 options introduced in r1309386. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1487796 13f79535-47bb-0310-9956-ffa450edef68
* Make sure apr_sockaddr_info_get() returns an error ifsf2013-05-031-1/+15
| | | | | | | | | | | - getaddrinfo() returned only useless entries - getaddrinfo() returned EAI_SYSTEM but errno == 0 - gethostbyname() returns no error but an empty address list Submitted by: Jan Kaluža <jkaluza redhat com>, Stefan Fritsch git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1478905 13f79535-47bb-0310-9956-ffa450edef68
* fix warning: parameter 'flags' set but not usedsf2013-03-231-3/+0
| | | | | | | (Linux sendfile has no flags, anyway) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1460179 13f79535-47bb-0310-9956-ffa450edef68
* Only fill in apr_sockaddr_vars_set if we have valid datasf2013-01-261-1/+8
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1438958 13f79535-47bb-0310-9956-ffa450edef68
* apr_socket_accept_filter: Return success when trying to again set the filtertrawick2012-11-071-2/+19
| | | | | | | | | | | | to the same value as before. Use apr_cpystrn(). PR: 37863 (warning message from Apache httpd during restart) git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1406690 13f79535-47bb-0310-9956-ffa450edef68
* * network_io/unix/sockaddr.c (apr_ipsubnet_test): Fix false positivejorton2012-11-051-2/+2
| | | | | | | | | | | when testing a v4 subnet against a v6 address. * test/testipsub.c (test_interesting_subnets): Add test. PR: 54047 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1405985 13f79535-47bb-0310-9956-ffa450edef68