Commit Graph

272 Commits

Author SHA1 Message Date
Norbert Federa
36b8f54c5e Fixed a few compiler warnings 2017-07-10 17:52:05 +02:00
Armin Novak
b0289e3ed8 Fixed cast warnings. 2017-04-10 10:39:01 +02:00
Armin Novak
bba910bd85 Fixed RPATH settings for OS X 2017-04-06 08:08:07 +02:00
Armin Novak
09d43a66f4 Fixed tests and dead store warnings. 2017-03-28 16:49:56 +02:00
Armin Novak
b2c29158be Scanbuild warning, argument checks and leak fixes.
* Added Stream_GetRemainingCapacity to check remaining stream size
  before writes.
* Fixed shadow server memory leak.
* Fixed lots of scanbuild warnings
* Added missing argument checks in many functions
* Added missing static function declarations
2017-03-02 18:13:43 +01:00
Ilya Shipitsin
879f1c3944 removed redundant condition:
[winpr/libwinpr/synch/semaphore.c:131] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
[winpr/libwinpr/synch/semaphore.c:132] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
[winpr/libwinpr/synch/semaphore.c:133] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
[winpr/libwinpr/synch/semaphore.c:134] -> [winpr/libwinpr/synch/semaphore.c:136]: (warning) Either the condition 'if(semaphore)' is redundant or there is possible null pointer dereference: semaphore.
2017-01-28 12:36:08 +05:00
Norbert Federa
f71b6b46e8 fix string format specifiers
- fixed invalid, missing or additional arguments
- removed all type casts from arguments
- added missing (void*) typecasts for %p arguments
- use inttypes defines where appropriate
2016-12-16 13:48:43 +01:00
Norbert Federa
c6e6b44143 countless WLog/printf format specifier fixes 2016-11-25 17:06:25 +01:00
Bernhard Miklautz
e54c504eaa winpr/wait: add missing parameters
Add the missing parameters introduced with PR #3381
2016-10-06 15:40:11 +02:00
Armin Novak
50c509eee2 Fixed barrier test. 2016-10-06 13:43:10 +02:00
Armin Novak
1454400236 Fixed windows defines for *LIST* 2016-10-06 13:43:10 +02:00
Armin Novak
64c5d78b3f Fixed clang warnings. 2016-10-06 13:43:09 +02:00
ed.velez
ed697fa4ad fix_for_xcode8_clock_gettime 2016-09-22 15:42:43 -05:00
Norbert Federa
27c439675f winpr: fix win32 linking issues
Depending on the windows target version (_WIN32_WINNT), the used
SDK and the build configuration the linker will see multiple
libraries exporting the same symbols.
To prevent ugly hacks (e.g. modifying cmake's default system
libraries or fragile library linking order chains) we prefix
these functions with "winpr_" and create corresponding defines
to keep the current api names.
2016-06-16 11:47:33 +02:00
Norbert Federa
f2c825bb76 winpr: fix some tests
TestNtCreateFile, TestPipeCreateNamedPipeOverlapped
- These tests are currently only expected to succeed on _WIN32
- Also reflect the reverse meaning of this fact in the return values

TestSynchWaitableTimer, TestSynchWaitableTimerAPC:
- These tests are currently expected to fail on __APPLE__
- Also reflect the reverse meaning of this fact in the return values

This logic makes sure that we don't forget to fix the tests if the
corresponding WinPR implementations are fixed.

TestLibrary:
- TestLibraryA and TestLibraryB must always get built as shared libraries
2016-06-07 17:20:56 +02:00
Norbert Federa
f969e60a53 winpr/synch: fix barrier deadlock in release build
Let the compiler know that we're comparing a volatile value.
Otherwise the compiler might nuke the comparison operation
and produce code that will spin endlessly.
2016-06-07 13:06:50 +02:00
Norbert Federa
a35a1e3d9b winpr/synch: fix InitializeWaitableTimer result
InitializeWaitableTimer must not reported success if the operating
sytem does not provide the required functionality.
2016-06-06 23:06:12 +02:00
Norbert Federa
131ffaa89b winpr/synch: improve barrier test
The SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY flag caused this test
to run extremely long if the system has very few processors.
Although this is expected (thread starvation) this will cause a
intolerably long execution time for automated tests.
Changed the number of threads to be calculated dyamically based
on the number of processors.
Also do proper cleanup to prevent memory leaks.
2016-06-06 15:41:05 +02:00
Bernhard Miklautz
bd71b3685b Merge pull request #3388 from nfedera/fix-winpr-pool-synch
winpr: several pool and synch fixes
2016-06-06 13:54:39 +02:00
Bernhard Miklautz
11ecda2ef3 Merge pull request #3386 from nfedera/fix-winpr-barrier
winpr/synch: rewrite barrier implementation & test
2016-06-06 13:44:48 +02:00
Norbert Federa
e35049c20e winpr/synch: fix timerqueue segfault
The current experimental/incomplete WinPR timer queue implementation
has several race conditions.
This commit fixes a segfault caused by not unklinking freed timers
from the timer queue timers list.
2016-06-06 13:24:04 +02:00
Norbert Federa
c16bee759f winpr: several pool and synch fixes
pool:
- the winpr implementation fallback was not used on older windows editions
- drop useless and conflicting TP_CALLBACK_ENVIRON_V3
- fix race conditions by using use proper one-time initialization
- on win32 WinPR tried to load several pool/callback_environment functions
  from kernel32.dll but since these are defined as inline functions in the
  windows headers, no windows edition has ever exported them in any dll.
- removed callback_environment.c and added corresponding static inline
  function to pool.h
- fix segfault in TestPoolWork: CloseThreadpoolWork() must not be called
  if there is a cleanup group associated with the work object since calling
  CloseThreadpoolCleanupGroupMember() already releases the work object

sync:
- The windows headers incorrectly define InitializeCriticalEx support if
  _WIN32_WINNT >= 0x0403 instead of >= 0x0600 (Vista)
- created a compatible define to deal with this issue
2016-06-04 17:09:48 +02:00
Norbert Federa
2dba082587 winpr/synch/barrier: fix return value and test
- According to the msdn docs DeleteSynchronizationBarrier always returns TRUE
- Added additional error checks to the barrier test
2016-06-04 13:40:01 +02:00
Norbert Federa
85f44262de winpr/synch: add spinning support to barrier
Implemented the SYNCHRONIZATION_BARRIER_FLAGS_BLOCK_ONLY and
SYNCHRONIZATION_BARRIER_FLAGS_SPIN_ONLY flags.
2016-06-04 00:55:27 +02:00
Norbert Federa
341eed138f winpr/synch: rewrite barrier implementation & test
The synchronization barrier test as well as the actual WinPR
implementation were completely broken.
2016-06-03 18:56:36 +02:00
Norbert Federa
e718fb324b fix race conditions, tests and some invalid return values
Since the current winpr implementation for overlapped operations is
incomplete and buggy, all affected functions will now fail if they are
called with a set FILE_FLAG_OVERLAPPED flag or a non-null pointer to
a OVERLAPPED structure.

winpr/nt:
- use proper one-time initialization on win32
- fix TestNtCreateFile
- fix broken/incomplete _RtlAnsiStringToUnicodeString
- unimplemented functions return appropriate error codes

winpr/pipe:
- improved TestPipeCreateNamedPipe
- rewrite the completely broken TestPipeCreateNamedPipeOverlapped test

rdtk:
- improve test and don't blindly return success

winpr/synch:
- fix race condition in TestSynchTimerQueue

winpr/ssspi:
- fix TestEnumerateSecurityPackages printf output
- fix TestQuerySecurityPackageInfo printf output

winpr/environment:
- fix GetEnvironmentStrings printf output

winpr/comm:
- unimplemented functions return appropriate error codes

winpr/io:
- unimplemented functions return appropriate error codes

winpr/thread:
- implement SwitchToThread() via sched_yield()
2016-06-01 16:26:26 +02:00
Norbert Federa
aded51f38f winpr/synch: fix tests
TestSynchTimerQueue:
- fixed race condition

TestSynchWaitableTimerAPC:
- Use WaitForSingleObjectEx since the thread must be in an alterable state

TestSynch is now expected to succeed on WIN32
2016-05-24 22:33:27 +02:00
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
Bernhard Miklautz
5d030534db winpr/event: fix file descriptor leak
SetEventFileDescriptor overrides the internal file descriptor of the
event but didn't close it. Now if the descriptor is closed if it isn't
marked as attached.
2016-05-23 13:04:44 +02:00
Marc-André Moreau
d4c809c4ae winpr: fix definitions of synchronization barrier and interlocked functions 2016-05-11 13:12:44 -04:00
Marc-André Moreau
bfca674f2d Merge branch 'master' of github.com:FreeRDP/FreeRDP 2016-02-05 11:39:45 -05:00
Armin Novak
40519f0912 Fixed initialization warning. 2016-02-03 12:45:31 +01:00
Marc-André Moreau
2f5d159448 winpr: fix WinXP backwards compatibility 2015-11-25 13:46:10 -05:00
Marc-André Moreau
70b037145e libwinpr-synch: fix broken FD_ISSET check caused by hidden type cast from int to char 2015-09-18 11:38:27 -04:00
Martin Haimberger
479157b69c winpr: WaitFor*Ojbect/s set lastError now 2015-07-30 02:52:11 -07:00
Bernhard Miklautz
4250f3f030 winpr/event: remove critical section
The critical section isn't required and not used anymore since
commit 8a2220a3d9.
2015-07-24 13:29:48 +02:00
Bernhard Miklautz
68e8569110 winpr/synch: remove the dependency on winsock.h
winsock.h pulls in a lot of defines and dependencies that are not
required and partially unwanted in winpr's core (for parts that are not
related to network). In order to get rid of this dependency and have an
independent defines for extended winpr functions the WINPR_FD_* defines
are used internally (and for exposed functions). Where required, like in
WSAEventSelect, the FD_* is mapped to WINPR_FD_*.
2015-07-14 11:39:41 +02:00
Armin Novak
776f15e135 Fixed inverted bAttached setting.
If bAttached is TRUE, the resources of the event are not
cleaned up on CloseHandle.
2015-07-03 12:42:04 +02:00
Armin Novak
c21de0dae6 Fixed pr comments. 2015-07-03 11:13:48 +02:00
Armin Novak
d18b0fbeb4 Handle API updated. 2015-07-03 09:52:52 +02:00
Armin Novak
6243a9374b Added write event support to handle functions.
Allows the WinPR HANDLE functions WaitForSingleObject and
WaitForMultipleObjects to signal in case of write events.
This is used by CreateFileDescriptor and SetEventFileDescriptor,
which got an API change accomodating for this new feature.
2015-07-03 09:29:18 +02:00
Armin Novak
b81aaa9cc2 Fixed mutex trylock in MutexCloseHandle. 2015-06-25 12:24:28 +02:00
David FORT
16d36e3083 A malloc() pass on WinPR
This patch treats remaining non-checked mallocs. And changes to calloc in places
where it makes sense
2015-06-22 19:10:00 +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
MartinHaimberger
9a4f645f78 Merge pull request #2582 from nfedera/fix-2015-04-28-01
Fix unchecked CreateEvent calls and misc fixes
2015-05-04 10:14:27 +02:00
Bernhard Miklautz
dd2e7f393d Merge pull request #2584 from baruchsiach/fix-eventfd-2
Fix build with newer uclibc versions
2015-04-30 14:20:33 +02:00