summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* On '1.8.x-r1897895' branch: Backport r1897895 from trunk.1.8.x-r1897895Ivan Zhakov2022-02-1512-293/+338
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x-r1897895@1898104 13f79535-47bb-0310-9956-ffa450edef68
* Branch to backport r1897895 to 1.8.x branch.Ivan Zhakov2022-02-150-0/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x-r1897895@1898103 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1898076 from trunk:Joe Orton2022-02-155-8/+20
| | | | | | | | | | | | | | | | | | | | | | Fix various harmless cases of undefined behaviour, and add a Travis job testing under UBSan. * poll/unix/poll.c (apr_poll): For the on-stack array allocation use num+1 since allocating a 0-length array is undefined behaviour. * tables/apr_skiplist.c (get_b_rand): Use unsigned integers to avoid signed integer overflow in the left shift. (skiplist_qpush): Avoid calling memcpy(,NULL,0). * random/unix/apr_random.c (apr_random_add_entropy): Avoid calling memcpy(,NULL,0). * test/teststr.c (overflow_strfsize): Avoid signed integer overflow. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1898099 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1897207: apr_thread_current_create() compilation.Yann Ylavic2022-02-085-2/+7
| | | | | | | | | | | | Fix compilation of apr_thread_current_create() for OS/2 and Windows. Set *current to NULL on failure. Merge r1897879 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897880 13f79535-47bb-0310-9956-ffa450edef68
* poll: Provide APR_POLLEXCL for exclusive wake up on systems that support it.Yann Ylavic2022-01-272-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | epoll has EPOLLEXCLUSIVE, start with that. poll: Follow up to r1897521: struct epoll_event's events field is unsigned int. EPOLLEXCLUSIVE is 1u << 28 so it doesn't fit in an int16_t, use unsigned for the native epoll events type. poll: Follow up to r1897521: Clarify what APR_POLLEXCL means. This is to avoid the thundering herd issue when multiple threads/processes poll on the same descriptor (usually listening/to-be-accept()ed descriptors). Merge r1897521, r1897548, r1897549 from trunk. Submitted by: ylavic Reviewed by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897550 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1897207: Provide apr_thread_current_after_fork().Yann Ylavic2022-01-2510-1/+54
| | | | | | | | | | | | | | | thread_local variables are not (always?) reset on fork(), so APR (and the user) needs a way to set the current_thread to NULL. Use apr_thread_current_after_fork() in apr_proc_fork()'s child process. Merge r1897470 from trunk. Submitted by: ylavic Reviewed by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897471 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1897207: Make APR_HAS_THREAD_LOCAL a boolean..Yann Ylavic2022-01-256-24/+28
| | | | | | | | | | | .. rather than a defined(). Merge r1897447 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897448 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1897207: Don't NULLify current_thread on exit.Yann Ylavic2022-01-255-33/+5
| | | | | | | | | | | It's not needed, when the thread exits it's not accessible anyway. Merge r1897445 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897446 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1897179: abort_fn on apr_allocator_create() failure.Yann Ylavic2022-01-245-10/+20
| | | | | | | | Merge r1897419 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897420 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Use compiler's TLS to track the current apr_thread_t's pointer.Yann Ylavic2022-01-196-55/+434
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All modern compilers provide a Thread Local Storage keyword that allows to store per-thread data efficiently (C++11 's thread_local, C11's _Thread_local, gcc/clang's __thread or MSVC's __declspec(thread)). Use that to have an apr_thread_t pointer associated with each thread created by apr_thread_create() or any native thread (like the process' initial thread) that registered itself with the new apr_thread_current_create() function. This mechanism allows to implement apr_thread_current() quite efficiently, if available, otherwise the function returns NULL. If available APR_HAS_THREAD_LOCAL is #define'd to 1 and the APR_THREAD_LOCAL macro is the keyword usable to register TLS variables natively. Both APR_HAS_THREAD_LOCAL and APR_THREAD_LOCAL are #undef'ined if the compiler does not provide the mechanism. This allows to test for the functionality at compile time. When APR_HAS_THREAD_LOCAL, the user can load his/her own TLS data with: apr_thread_data_get(&my_data, my_key, apr_thread_current()); and store them with: apr_thread_data_set(my_data, my_key, my_data_cleanup, apr_thread_current()); which can be nice to avoid the proliferation of native TLS keys. Merge r1897207 from trunk: Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897223 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Allocate the apr_thread_t struct on the thread's pool.Yann Ylavic2022-01-195-84/+86
| | | | | | | | | | | | | | | | | | | | | | | | | apr_thread_create() was allocating the created apr_thread_t on the given pool, which caused e.g. short-living threads to leak memory on that pool without a way to clear it (while some threads are still running). Change this by allocating the apr_thread_t on the thread's pool itself, which is safe in the implementations of all archs because none uses the apr_thread_t after the thread exits, and it's safe for the users provided they don't use the apr_thread_t for detached threads or for attached threads after the call to apr_thread_join(). These are hardly new requirements though. apr_thread: Follow up to r1897197: Safer apr_thread_join(). Make sure apr_thread_join() behaves correctly w.r.t. the returned value and pool destroy for all archs. Merge r1897197, r1897198 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897221 13f79535-47bb-0310-9956-ffa450edef68
* apr_thread: Follow up to r1884078: Unmanaged pools for attached threads too.Yann Ylavic2022-01-196-265/+158
| | | | | | | | | | | | | | | | | | | | | | | | | | | r1884078 fixed lifetime issues with detached threads by using unmanaged pool destroyed by the thread itself on exit, with no binding to the parent pool. This commit makes use of unmanaged pools for attached threads too, they needed their own allocator anyway due to apr_thread_detach() being callable anytime later. apr__pool_unmanage() was a hack to detach a subpool from its parent, but if a subpool needs its own allocator for this to work correctly there is no point in creating a subpool for threads (no memory reuse on destroy for short living threads for instance). Since an attached thread has its own lifetime now, apr_thread_join() must be called to free its resources/pool, though it's no different than before when destroying the parent pool was UB if the thread was still running (i.e. not joined yet). Let's acknoledge that threads want no binding with the pool passed to them at creation time, besides the abort_fn which they can steal :) Merge r1897179 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897220 13f79535-47bb-0310-9956-ffa450edef68
* apr_cstr: Follow up to r1897102: Yet better apr_cstr_casecmp[n]().Yann Ylavic2022-01-161-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | This ones have a shorter prologue and epilogue (-O2 still). Dump of assembler code for function apr_cstr_casecmp: 0x0000000000049fd0 <+0>: xor %edx,%edx 0x0000000000049fd2 <+2>: lea 0x3d567(%rip),%r8 # 0x87540 <ucharmap> 0x0000000000049fd9 <+9>: nopl 0x0(%rax) 0x0000000000049fe0 <+16>: movzbl (%rsi,%rdx,1),%eax 0x0000000000049fe4 <+20>: movzbl (%r8,%rax,1),%ecx 0x0000000000049fe9 <+25>: movzbl (%rdi,%rdx,1),%eax 0x0000000000049fed <+29>: add $0x1,%rdx 0x0000000000049ff1 <+33>: movzbl (%r8,%rax,1),%eax 0x0000000000049ff6 <+38>: sub %ecx,%eax 0x0000000000049ff8 <+40>: jne 0x49ffe <apr_cstr_casecmp+46> 0x0000000000049ffa <+42>: test %ecx,%ecx 0x0000000000049ffc <+44>: jne 0x49fe0 <apr_cstr_casecmp+16> 0x0000000000049ffe <+46>: ret End of assembler dump. Merge r1897121 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897122 13f79535-47bb-0310-9956-ffa450edef68
* apr_cstr: Improve apr_cstr_casecmp() and apr_cstr_casecmpn() performances.Yann Ylavic2022-01-151-26/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new versions [1] compile to a shorter/faster assembly than the previous ones [2], no functionnal change. [1] apr_cstr_casecmp() after this commit: Dump of assembler code for function apr_cstr_casecmp: 0x0000000000049fc0 <+0>: movzbl (%rdi),%eax 0x0000000000049fc3 <+3>: movzbl (%rsi),%edx 0x0000000000049fc6 <+6>: lea 0x3d573(%rip),%r8 # 0x87540 <ucharmap> 0x0000000000049fcd <+13>: movzbl (%r8,%rax,1),%eax 0x0000000000049fd2 <+18>: movzbl (%r8,%rdx,1),%ecx 0x0000000000049fd7 <+23>: cmp %ecx,%eax 0x0000000000049fd9 <+25>: jne 0x49ffe <apr_cstr_casecmp+62> 0x0000000000049fdb <+27>: xor %edx,%edx 0x0000000000049fdd <+29>: jmp 0x49ffa <apr_cstr_casecmp+58> 0x0000000000049fdf <+31>: nop 0x0000000000049fe0 <+32>: add $0x1,%rdx 0x0000000000049fe4 <+36>: movzbl (%rdi,%rdx,1),%eax 0x0000000000049fe8 <+40>: movzbl (%rsi,%rdx,1),%ecx 0x0000000000049fec <+44>: movzbl (%r8,%rax,1),%eax 0x0000000000049ff1 <+49>: movzbl (%r8,%rcx,1),%ecx 0x0000000000049ff6 <+54>: cmp %ecx,%eax 0x0000000000049ff8 <+56>: jne 0x49ffe <apr_cstr_casecmp+62> 0x0000000000049ffa <+58>: test %eax,%eax 0x0000000000049ffc <+60>: jne 0x49fe0 <apr_cstr_casecmp+32> 0x0000000000049ffe <+62>: sub %ecx,%eax 0x000000000004a000 <+64>: ret End of assembler dump. [2] apr_cstr_casecmp() before this commit: Dump of assembler code for function apr_cstr_casecmp: 0x000000000004a000 <+0>: movzbl (%rdi),%eax 0x000000000004a003 <+3>: movzbl (%rsi),%edx 0x000000000004a006 <+6>: lea 0x3d533(%rip),%r8 # 0x87540 <ucharmap> 0x000000000004a00d <+13>: mov %rdi,%r9 0x000000000004a010 <+16>: mov %rax,%rcx 0x000000000004a013 <+19>: movswl (%r8,%rdx,2),%edx 0x000000000004a018 <+24>: movswl (%r8,%rax,2),%eax 0x000000000004a01d <+29>: sub %edx,%eax 0x000000000004a01f <+31>: jne 0x4a052 <apr_cstr_casecmp+82> 0x000000000004a021 <+33>: mov $0x1,%edx 0x000000000004a026 <+38>: test %ecx,%ecx 0x000000000004a028 <+40>: je 0x4a052 <apr_cstr_casecmp+82> 0x000000000004a02a <+42>: nopw 0x0(%rax,%rax,1) 0x000000000004a030 <+48>: movzbl (%r9,%rdx,1),%eax 0x000000000004a035 <+53>: movzbl (%rsi,%rdx,1),%ecx 0x000000000004a039 <+57>: add $0x1,%rdx 0x000000000004a03d <+61>: mov %rax,%rdi 0x000000000004a040 <+64>: movswl (%r8,%rcx,2),%ecx 0x000000000004a045 <+69>: movswl (%r8,%rax,2),%eax 0x000000000004a04a <+74>: sub %ecx,%eax 0x000000000004a04c <+76>: jne 0x4a052 <apr_cstr_casecmp+82> 0x000000000004a04e <+78>: test %edi,%edi 0x000000000004a050 <+80>: jne 0x4a030 <apr_cstr_casecmp+48> 0x000000000004a052 <+82>: ret End of assembler dump. Merge r1897102 from trunk. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897103 13f79535-47bb-0310-9956-ffa450edef68
* Indicate 1.8.0-dev on the new backport dev branchWilliam A. Rowe Jr2022-01-143-58/+14
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897024 13f79535-47bb-0310-9956-ffa450edef68
* Branch 1.8.x due to ABI-breaking commitsWilliam A. Rowe Jr2022-01-140-0/+0
| | | | | | | | | | Begin 1.8.x development from here, with no need to roll anything back from this branch. The 1.7.x branch will need breaking backports all rolled back. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.8.x@1897021 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1893202 from trunk:Yann Ylavic2022-01-133-5/+21
| | | | | | | | | | | test: fix memory leaks of the test framework at exit. To please memory leak analysers.. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1897005 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1896971, r1896990, r1896992 from trunk:Yann Ylavic2022-01-131-4/+35
| | | | | | | | | | | Add Asan builds to travis. Disable odbc tests with ASan for now, dlclose() leaks memory somehow. Move misplaced comment. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896996 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1896722, r1896782 from trunk:Joe Orton2022-01-121-2/+12
| | | | | | | | | | Add GCC 10 build to Travis config. Since bionic is the default, switch one -Werror build to xenial. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896966 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1896803 from trunk:Yann Ylavic2022-01-121-9/+9
| | | | | | | | | | | | | testatomic: Fix gcc-11 warnings. Not sure why it wants the "a" local variable to point to something since we only use its pointer, but that's how it is.. While at it let's initialize "b" too. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896962 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1896811 from trunk:Yann Ylavic2022-01-121-0/+7
| | | | | | | | | | | apr_atomic_set64: Follow up to r1868129. Like for apr_atomic_read64() in r1868502, use direct memory write on x86_x64. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896960 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1896956 from trunk:Yann Ylavic2022-01-121-3/+4
| | | | | | | | | | | apr_sockaddr_ip_getbuf: Follow up to r1883728. Return APR_ENOSPC if returned buf is truncated for an AF_UNIX. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896958 13f79535-47bb-0310-9956-ffa450edef68
* Revert VPATH build breakage introduced in r1890192William A. Rowe Jr2022-01-121-2/+2
| | | | | | | | | | | | | | Avoids the scenario; gcc tools/gen_test_char.c -o tools/gen_test_char gcc: error: tools/gen_test_char.c: No such file or directory gcc: fatal error: no input files Substitute the source tree path to this file rather that the target tree. Backports: r1896933 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896934 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1895178 from trunk:Yann Ylavic2022-01-071-1/+1
| | | | | | | | | Fix typo Submitted by: mturk git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896808 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1896535, r1896747 from trunk:Yann Ylavic2022-01-061-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | apr_ring: Don't break strict-aliasing rules in APR_RING_SPLICE_{HEAD,TAIL}(). GCC-11 complains (see [1]) about apr_brigade_split_ex() seemingly issuing an out of bounds access, the cause being that APR_RING_SPLICE_{HEAD,TAIL}() is dereferencing an APR_RING_SENTINEL() and the cast there in not very aliasing friendly (see [2] for a great explanation by Martin Sebor). The APR (and user code) should never dereference APR_RING_SENTINEL(), it's fine as a pointer only (i.e. for comparing pointers). So this commit modifies the APR_RING_SPLICE_{HEAD,TAIL}() and APR_RING_{CONCAT,PREPEND}() macros to use the passed in APR_RING_HEAD's prev/next pointers directly instead of passing the APR_RING_SENTINEL() to APR_RING_SPLICE_{BEFORE,AFTER}(). Semantically, this also clarifies that APR_RING_{SPLICE,INSERT}_{BEFORE,AFTER}() should be called for an APR_RING_ENTRY while APR_RING_SPLICE_{HEAD,TAIL}() and APR_RING_{CONCAT,PREPEND}() are to be called with an APR_RING_HEAD. [1] In file included from ./include/apr_mmap.h:28, from ./include/apr_buckets.h:32, from buckets/apr_brigade.c:22: buckets/apr_brigade.c: In function ‘apr_brigade_split’: ./include/apr_ring.h:177:43: error: array subscript ‘struct apr_bucket[0]’ is partly outside array bounds of ‘unsigned char[32]’ [-Werror=array-bounds] 177 | #define APR_RING_NEXT(ep, link) (ep)->link.next | ~~~~~~~~~~^~~~~ ./include/apr_ring.h:247:38: note: in expansion of macro ‘APR_RING_NEXT’ 247 | APR_RING_NEXT((epN), link) = APR_RING_NEXT((lep), link); \ | ^~~~~~~~~~~~~ ./include/apr_ring.h:287:9: note: in expansion of macro ‘APR_RING_SPLICE_AFTER’ 287 | APR_RING_SPLICE_AFTER(APR_RING_SENTINEL((hp), elem, link), \ | ^~~~~~~~~~~~~~~~~~~~~ buckets/apr_brigade.c:118:9: note: in expansion of macro ‘APR_RING_SPLICE_HEAD’ 118 | APR_RING_SPLICE_HEAD(&a->list, e, f, apr_bucket, link); | ^~~~~~~~~~~~~~~~~~~~ buckets/apr_brigade.c:90:9: note: referencing an object of size 32 allocated by ‘apr_palloc’ 90 | b = apr_palloc(p, sizeof(*b)); | ^~~~~~~~~~~~~~~~~~~~~~~~~ [2] https://bugzilla.redhat.com/show_bug.cgi?id=1957353#c2 (Note that the original comment from Martin Sebor talks about the struct "_direntry" and the global variable "anchor" which relate to some httpd code using an APR_RING in a similar way than apr_bucket_brigade does. So below I allowed myself to edit the original comment to replace "_direntry" by "apr_bucket" and "anchor" by "list" (the apr_bucket_brigade's member used as the head of the ring) to make the link with the above commit message) " The message is a bit cryptic but it says that the code accesses an object (list) of some anonymous type as it was struct apr_bucket. That's invalid because objects can only be accessed by lvalues of compatible types (or char). The APR_RING_ENTRY macro is defined like so: #define APR_RING_ENTRY(elem) \ struct { \ struct elem * volatile next; \ struct elem * volatile prev; \ } so given the definition: APR_RING_ENTRY(apr_bucket) list; list can only be accessed by lvalues of its (anonymous) type but the APR_RING_SENTINEL() macro defined like so: #define APR_RING_SENTINEL(hp, elem, link) \ (struct elem *)((char *)(&(hp)->next) - APR_OFFSETOF(struct elem, link)) casts the address of list's next member minus some constant to a pointer to struct apr_bucket and that pointer is then used to access the prev pointer. The anonymous struct and struct apr_bucket are unrelated and cannot be used each other's members even if the corresponding members have the same type and are at the same offset within the bounds of the object. " apr_ring: Follow up to r1896535: Use APR_RING_{FIRST,LAST} macros. hp->{next,prev} are APR_RING_{FIRST,LAST}(hp), so use them to make APR_RING_SPLICE_{HEAD,TAIL}() read better. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896748 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1877444 from trunk:Yann Ylavic2022-01-051-1/+1
| | | | | | | | | testatomic: Silence -Wmissing-prototypes warning. Submitted by: brane git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896728 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1891310 from trunk:Joe Orton2022-01-051-3/+3
| | | | | | | | | | * test/proc_child.c (main): Avoid gcc -Wunused-result warning with write() return value. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896718 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1892374 from trunk:Joe Orton2022-01-051-0/+35
| | | | | | | | | Add minimal Travis CI configuration (no notifications currently). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896713 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1895106, r1895111, r1895175, r1895181, r1895465 from trunk:Yann Ylavic2021-12-2914-96/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix drain wakeup pipe issue when multiple threads call apr_pollset_wakeup/apr_pollcb_wakeup for the same pollset filling up drain pipe. Use atomics so that wakeup call is noop if some other thread allready done this Follow up to r1895106: now we want blocking reads on unix too so revert r1894914. Follow up to r1895106: Use less expensive atomics for wakeup. 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(). Use enum instead multiple booleans Fix remaining change when apr_filetype_e was added Submitted by: mturk, ylavic, ylavic, mturk, mturk git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896510 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1868129, r1868502 from trunk:Yann Ylavic2021-12-163-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | apr_atomic_read64(): Fix non-atomic read on 32-bit Windows. * atomic/win32/apr_atomic64.c (apr_atomic_read64): Use InterlockedCompareExchange64() instead of direct memory read. * test/testatomic.c (test_atomics_threaded_setread64): New test. (test_func_set64): Helepr for test_atomics_threaded_setread64 test. * CHANGES: Add changelog entry. * atomic/win32/apr_atomic64.c (apr_atomic_read64): Use direct memory read when compiled for x86_x64, since 64-bit reads are atomic in 64-bit Windows [1]. Suggested by: Yann Ylavic [1] https://docs.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access Submitted by: ivan Reviewed by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896068 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1894621, r1894719, r1894622 from trunk:Yann Ylavic2021-12-164-36/+192
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | apr_atomic: Use __atomic builtins when available. Unlike Intel's atomic builtins (__sync_*), the more recent __atomic builtins provide atomic load and store for weakly ordered architectures like ARM32 or powerpc[64], so use them when available (gcc 4.6.3+). Follow up to r1894621: restore apr_atomic_init::apr__atomic_generic64_init(). Even if apr__atomic_generic64_init() is currently a noop when !APR_HAS_THREADS, it may change later without apr_atomic_init() noticing (thanks Rüdiger). apr_atomic: Fix load/store for weak memory ordering architectures. Volatile access prevents compiler reordering of load/store but it's not enough for weakly ordered archs like ARM32 and PowerPC[64]. While __atomic builtins provide load and store, __sync builtins don't so let's use an atomic add of zero for the former and atomic exchange for the latter. The assembly code for PowerPC was not correct either, fix apr_atomic_read32() and apr_atomic_set32() and add the necessary memory barriers for the others. PR 50586. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1896067 13f79535-47bb-0310-9956-ffa450edef68
* Follow RTC then.Yann Ylavic2021-11-251-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1895343 13f79535-47bb-0310-9956-ffa450edef68
* APR_PERMS_SET made it to 1.5.x long ago..Yann Ylavic2021-11-251-4/+0
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1895342 13f79535-47bb-0310-9956-ffa450edef68
* Trivial fix. void functio has no return valueMladen Turk2021-11-211-1/+1
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1895238 13f79535-47bb-0310-9956-ffa450edef68
* Although trivial fix, follo the RTC policyMladen Turk2021-11-211-0/+3
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1895237 13f79535-47bb-0310-9956-ffa450edef68
* Revert r1894918 (untested).Yann Ylavic2021-11-161-4/+0
| | | | | | | | See https://lists.apache.org/thread/dmlm6z38fpd9l7xccqkw9pzchv4rzvxv git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1895085 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1894917 from trunk:Yann Ylavic2021-11-101-0/+4
| | | | | | | | Follow up to r1894914: non-blocking wakeup pipe reads on Windows too. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1894918 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1894914 from trunk:Yann Ylavic2021-11-101-2/+3
| | | | | | | | | | | | | | | poll: Fix possible blocking when draining the wakeup pipe. apr_poll_drain_wakeup_pipe() can block if exactly 512 bytes (or multiple thereof) are available on the drained pipe, fix this by setting read end of the pipe nonblocking (the write end is still blocking). Submitted by: Mihaly Szjatinya <mihaly.szjatinya nxlog.org> Reviewed by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1894916 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1894167 from trunk:Joe Orton2021-10-122-2/+19
| | | | | | | | | | | | | | | | Since runtime SCTP detection is dependent on kernel configuration, add flags to make SCTP support reliable: * build/apr_network.m4 (APR_CHECK_SCTP): Add --disable-sctp flag to forcibly disable SCTP support, and --enable-sctp to fail configure if is SCTP support is requested but not available. Submitted by: Lubos Uhliarik <luhliari redhat.com>, jorton Github: closes #28 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1894170 13f79535-47bb-0310-9956-ffa450edef68
* Partially merge r1893204, r1893445 from trunk:Yann Ylavic2021-09-193-8/+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. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1893446 13f79535-47bb-0310-9956-ffa450edef68
* Fix handle leak in the Win32 apr_uid_current implementation.William A. Rowe Jr2021-09-162-8/+22
| | | | | | | | | Backports: r1860057 Submitted by: ivan Reviewed by: wrowe git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1893388 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1893198 from trunk:Yann Ylavic2021-09-122-6/+3
| | | | | | | | | | | | poll: don't #include sys/poll.h if poll.h is available. With musl libc, this fixes: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1893277 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1892618 from trunk:Yann Ylavic2021-09-091-2/+2
| | | | | | | | | | | | apr_tables: fix petential left shift of 31 on an int. apr_tables.c:832:10: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'. Submitted by: ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1893197 13f79535-47bb-0310-9956-ffa450edef68
* Update config.guess and config.sub fromRainer Jung2021-08-312-826/+998
| | | | | | | | | https://git.savannah.gnu.org/cgit/config.git. Backport of r1892754 from trunk. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1892755 13f79535-47bb-0310-9956-ffa450edef68
* SECURITY: CVE-2021-35940 (cve.mitre.org)Joe Orton2021-08-161-0/+5
| | | | | | | | | | | | | | | Restore fix for CVE-2017-12613 which was missing in 1.7.x branch, though was addressed in 1.6.x in 1.6.3 and later via r1807976. The fix was merged back to 1.7.x in r1891198. Since this was a regression in 1.7.0, a new CVE name has been assigned to track this, CVE-2021-35940. Thanks to Iveta Cesalova <icesalov redhat.com> for reporting this issue. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1892358 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1891204 from trunk:Joe Orton2021-07-052-0/+11
| | | | | | | | | | | | * locks/unix/thread_mutex.c, include/arch/unix/apr_arch_thread_mutex.h: Completely drop the code required imitate the mutex via a condition variable if HAVE_PTHREAD_MUTEX_TIMEDLOCK is defined. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1891269 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1889604, r1807975 from trunk:Joe Orton2021-07-023-2/+11
| | | | | | | | | | | | | | * random/unix/sha2.c (apr__SHA256_Final, apr__SHA256_End): Fix parameter buffer lengths to match declaration, avoiding GCC 11 warning. (no functional change) Bounds-check human-readable date fields (credit: Stefan Sperling) Submitted by: jorton, niq Reviewed by: jorton git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1891198 13f79535-47bb-0310-9956-ffa450edef68
* Merge r1878340, r1878343, r1878354, r1878365, r1878342 from trunk:Joe Orton2021-07-025-10/+30
| | | | | | | | | | | | | | | | | | | | | | | * memory/unix/apr_pools.c (apr_pvsprintf): Fix a clang warning, the 'active' variable is never read/used before being set again to pool->active on line 1436. * file_io/unix/readwrite.c (apr_file_write, apr_file_writev): Fix Coverity warnings from ignored lseek() return value in ->buffered handling. * test/teststr.c: Add trivial testcases for apr_pstrcat (though this does not reproduce any problems from the bug). Revert non-test part of r1878354, the Coverity warning was a false -ve and there was no functional change nor bug. * locks/unix/proc_mutex.c (apr_proc_mutex_defname): Fix clang warning, remove unused local variable. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1891196 13f79535-47bb-0310-9956-ffa450edef68
* Backport r1861050, r1805309, r1861045, r1861046, r1861049, r1861053, ↵Michael Osipov2021-05-264-21/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r1861054, r1861061 from trunk: * misc/win32/misc.c (apr_get_oslevel): Fix condition to actually return APR_EGENERAL on unsupported OS. === apr_socket_listen(): Allow larger backlog queue lengths on Windows 8+. 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> === * misc/win32/misc.c (apr_get_oslevel): Check return code from GetVersionEx(). === * misc/win32/misc.c (apr_get_oslevel): Do not use static variables to protect from potential race condition. === * misc/win32/misc.c (apr_get_oslevel): Use GetVersionExW() with OSVERSIONINFOEXW to version information with service pack info. === * include/arch/win32/apr_arch_misc.h (enum apr_oslevel_e): Add APR_WIN_8_1. * misc/win32/misc.c (apr_get_oslevel): Determine whether we are running on Windows 8 or on Windows 8.1+. === Fix problem that apr_get_oslevel() was returning APR_WIN_XP on Windows 10. * include/arch/win32/apr_arch_misc.h (enum apr_oslevel_e): Add APR_WIN_10. * misc/win32/misc.c (apr_get_oslevel): Return APR_WIN_10 when dwMajorVersion is greater than 6. === * include/arch/win32/apr_arch_misc.h (enum apr_oslevel_e): Add APR_WIN_7_SP1. * misc/win32/misc.c (apr_get_oslevel): Determine whether we are running on Windows 7 or on Windows 7 SP1. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1890230 13f79535-47bb-0310-9956-ffa450edef68
* Backport r1890191 from trunk:Michael Osipov2021-05-251-1/+1
| | | | | | | | | | Use portable make variables The usage of '$<' with BSD make results in an empty variable, therefore compilation fails. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1890192 13f79535-47bb-0310-9956-ffa450edef68