Commit Graph

36 Commits

Author SHA1 Message Date
Norbert Federa
386d290015 winpr/synch: fix mutex implementation
- Mutex is recursive on Windows; as a consequence we have to use
  the pthread PTHREAD_MUTEX_RECURSIVE type
- Adapt MutexCloseHandle accordingly
- ReleaseMutex returned TRUE even if pthread_mutex_unlock failed
- Fixed and improved the TestSynchMutex ctest
2016-05-24 15:10:57 +02:00
Marc-André Moreau
093aaa4dc0 Merge pull request #2636 from xhaakon/master
Fix crashes in shadow server
2015-06-22 09:15:37 -04:00
Norbert Federa
f503f4cf0b winpr/synch: fix ResetEvent & improve CTest
Unless there is an invalid parameter or internal error, ResetEvent
must return TRUE, even if the object is in nonsignaled state.

Also fixed and improved the CTest TestSynchEvent to test for the
expected/correct SetEvent and ResetEvent return values.
2015-06-17 14:13:28 +02:00
Jakub Adam
73888a57c2 Ensure threads have finished using a barrier before releasing it
MSDN documentation says it is ensured that all threads in the barrier
have finished using it before allowing the barrier to be released in
DeleteSynchronizationBarrier(). The winpr re-implementation wasn't
keeping to that requirement, which was causing occasional crashes
when shadow client tried to access already freed barrier structure.

The crash was occuring in winpr_Handle_cleanup() after finished
waiting on a barrier's event.
2015-05-22 13:36:15 +02:00
Norbert Federa
1eff1a345e free can handle NULL perfectly fine 2015-05-11 09:07:39 +02:00
Norbert Federa
25fc866a58 Fix unchecked CreateThread calls and misc fixes 2015-05-05 13:55:48 +02:00
Norbert Federa
ef1fd12b15 Fix unchecked CreateEvent calls and misc fixes
1)
Added missing checks for CreateEvent which also required the
following related changes:

- changed freerdp_context_new API to BOOL
- changed freerdp_peer_context_new API to BOOL
- changed pRdpClientNew callback to BOOL
- changed pContextNew callback to BOOL
- changed psPeerAccepted callback to BOOL
- changed psPeerContextNew callback to BOOL

2)
Fixed lots of missing alloc and error checks in the
changed code's neighbourhood.

3)
Check freerdp_client_codecs_prepare result to avoid segfaults
caused by using non-initialized codecs.

4)
Fixed deadlocks in x11 caused by missing xf_unlock_x11() calls
in some error handlers

5)
Some fixes in thread pool:
- DEFAULT_POOL assignment did not match TP_POOL definition
- don't free the pool pointer if it points to the static DEFAULT_POOL
- added error handling and cleanup in InitializeThreadpool
2015-04-29 18:18:39 +02:00
Bernhard Miklautz
850de59b55 winpr: add checks for *alloc
Add missing checks if memory allocation was successful. Also adapt
caller(s) when possible.
2015-04-08 11:34:37 +02:00
Marc-André Moreau
ccf144e10f libwinpr-synch: fix test build on Win32 2015-02-17 18:44:09 -05:00
Armin Novak
51cc567dc6 Fixed typo. 2014-11-16 23:52:22 +01:00
Armin Novak
a1761d8a7b Fixed memory leaks. 2014-11-16 23:10:33 +01:00
Armin Novak
c6ed95d1bf Fixed typo 2014-10-27 11:28:13 +01:00
Armin Novak
c5bb6125c1 Added additional tests for WaitForSingleObject and WaitForMultipleObjects. 2014-10-27 11:23:18 +01:00
Armin Novak
0131e576b7 Fixed Barrier test. First get the thread ID, then wait for the barrier to be reached. 2014-09-09 16:33:05 +02:00
Marc-André Moreau
edde16e9d5 libwinpr-synch: add initial synchronization barrier implementation 2014-08-08 17:34:30 -04:00
Norbert Federa
fae8f6fbf2 winpr/sync: Added InitOnceExecuteOnce plus CTest 2014-07-24 21:12:59 +02:00
Bernhard Miklautz
6a49bcfe40 winpr: always build "monolitic"
winpr is now always build as single library.
The build option MONOLITHIC_BUILD doesn't influence this behavior anymore.

The only exception is winpr-makecert-tool which is still build as extra
library.

This obsoletes complex_libraries for winpr.
2014-07-10 11:10:58 +02:00
Marc-André Moreau
ae368549ad freerdp: fix compilation on Windows 2014-05-22 14:42:05 -04:00
Marc-André Moreau
a202fe4057 freerdp: fix several type related warnings 2014-05-08 18:02:02 -04:00
Marc-André Moreau
c799db6855 libwinpr-synch: fix linker error 2014-02-05 13:09:25 -05:00
Marc-André Moreau
eb38b9f1e1 libwinpr-synch: add active/inactive linked list for timer queue 2014-01-27 10:37:38 -05:00
Marc-André Moreau
159f539ef2 libwinpr-synch: improve timer queue implementation 2014-01-26 21:56:07 -05:00
Marc-André Moreau
3616b19290 libwinpr-synch: make use of timespec for timer queue 2014-01-26 20:39:13 -05:00
Marc-André Moreau
2e45ad143f libwinpr-synch: improve timer queue implementation 2014-01-26 17:21:12 -05:00
Marc-André Moreau
656766ca2e libwinpr-synch: start implementing timer queue 2014-01-26 12:37:38 -05:00
Marc-André Moreau
d2405a25f8 libwinpr-synch: initial waitable timer asynchronous procedure callback support 2014-01-24 22:44:23 -05:00
Marc-André Moreau
9a4fb396da libwinpr-synch: add unit test for waitable timer asynchronous procedure calls 2014-01-24 18:08:06 -05:00
Marc-André Moreau
fab0cd2779 libwinpr-synch: stub timer queues 2014-01-24 17:48:55 -05:00
Armin Novak
fbc1acd70e Fixed includes and test function naming. 2013-11-15 11:43:01 +01:00
Armin Novak
5dbd94e2a3 Added unit tests for thread and mutex. 2013-11-15 11:38:59 +01:00
Armin Novak
efd2d833c2 Extended test, now also checks, if lock / unlock is working. 2013-11-15 08:38:59 +01:00
Marc-André Moreau
e8a8c1cf7f winpr: fix crashing tests 2013-09-19 14:17:00 -04:00
Marc-André Moreau
0c17eb1a23 winpr: fix unit tests on Windows 2013-09-19 13:50:00 -04:00
Marc-André Moreau
34f9985add freerdp: merge with master 2013-08-07 15:48:57 -04:00
Norbert Federa
2b25b4a520 libwinpr-sync: New complete critical section code
- 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).
2013-08-07 10:20:04 +02:00
Marc-André Moreau
4d2bc6ba46 libwinpr-synch: add unit tests, initial waitable timer support 2013-07-29 13:07:39 -04:00