Based on 8df96364f2
Backported by:
Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Bernhard Miklautz <bernhard.miklautz@thincast.com>
Martin Fleisz <martin.fleisz@thincast.com>
* since 3.1 file(GLOB FILEPATHS RELATIVE .. returns single
* / instead of // as previously - necessary adoptions for regex and
matches done. Should work with all cmake versions.
Use InitializeCriticalSectionAndSpinCount instead of IntializeCriticalSection.
Using spin counts for critical sections of short duration enables the calling
thread to avoid the wait operation in most situations which can dramatically
improve the overall performance on multiprocessor systems.
On Linux this change has no effect because the new winpr critical section
implementation does not use the SpinCount field under Linux because the NPTL
synchronization primitives are implemented using the extremely performant
futex system calls which have this magic already built in.
However, on Mac OS X this change improved the overall performance of the
multithreaded RemoteFX decoder by 25 percent.
I've used a SpinCount of 4000 which avoided 99 percent of the wait calls.
This value is also used by Microsoft's heap manager for its per-heap
critical sections.
Note: This change requires pull request #1397 to be merged.
(cherry picked from commit 3a58934eb2)
- Complete implementation including recursion support
- Added an intensive ctest (TestSynchCritical)
- Struct members are used exactly as Windows does it internally:
LockCount starts at -1, RecursionCount at 0
- Same performance optimizations as internally on Windows:
- Fast lock acquisition path using CAS -> SpinCount -> wait
- SpinCount automatically disabled on uniprocessor systems
- On Linux SpinCount is disabled because it provided no advantage over NPTL/futex in all tests
Support for CRITICAL_SECTION's DebugInfo is not yet included (but trivial to add).
(cherry picked from commit 2b25b4a520)
- Improved/completed(almost) winpr's critical section implementation
- Replaced WaitForSingleObject locking with critical sections
Note:
WaitForSingleObject should _never_ be used for granular low-contention
locks as it _always_ enters the kernel.
Just replacing WaitForSingleObject locking in Bufferpool with
EnterCriticalSection boosts the multithreaded rfx decoder
performance by almost 400% on win32.
(pull #1388 - cherry picked from commit 81ef251fc8)
# By Bernhard Miklautz (4) and others
# Via Marc-André Moreau
* 'master' of git://github.com/awakecoding/FreeRDP:
libfreerdp-core: fix unused variable
libfreerdp-codec: add bitmap encoder
cmdline: unix/windows return detected error
client/common: fixed command line parsing issue
channels/serial: bring it back to life
nla: invalidate sec handle after creation
tls: updated certificate mismatch message
- replaced char* by const char* in function prototypes
- MacFreeRDP: moved assignation of context function pointers
- freerdp: added more pointer and return value validations to prevent crashes
If sec pointer isn't invalidated after creation it is not possible
to check if the upper and lower pointers are valid.
This fixes a segfault in the server part if the client disconnects before
the authentication was finished.