Commit Graph

91 Commits

Author SHA1 Message Date
akallabeth
1dcc5a180a Fixed warnings 2022-04-28 11:24:51 +02:00
Armin Novak
e1b4b4aee0 Replaced WINPR_HANDLE_DEF with a struct type 2022-04-28 08:42:09 +02:00
Armin Novak
833a445e4e Refactor thread condition logic
* Add better return value checks
* Combine logic blocks in structs
* Add (easier to read) static functions for blocks
* Use condition variables only in combination with BOOL
2022-04-27 18:12:37 +02:00
akallabeth
752ac3b479
Fix #7793: Do not expose internal input API (#7794)
* Fixed GetFileInformationByHandle initializers

* Fix #7793: Do not expose internal input API

Slow-Path input uses UINT16 for scancodes on wire, but only the
lower byte is actually used. (the extended fields are sent in
keyboardFlags field)
Hide this implementation detail and adjust the API to use UINT8
for the code instead just like the corresponding Fast-Path PDU

* Added a warning for problematic slow path keyCodes
2022-04-13 09:34:05 +02:00
Mike Gabriel
d337ea9c16 winpr/{libwinpr/thread/thread.c,include/winpr/thread.h}: Keep DumpThreadHandles as a symbol even if WITH_DEBUG_THREADS is OFF. 2022-03-08 09:16:10 +01:00
Armin Novak
6ed50b4b1d Refactored WinPR includes 2022-03-03 11:26:48 +01:00
akallabeth
bd42b34776 Decreased NTLM debug log verbosity 2022-01-13 17:20:48 +01:00
Armin Novak
b05eb8d834 Fixed thread related changes:
* Fixed typo
* Fixed wrong #ifdef
2021-09-20 10:59:59 +02:00
akallabeth
cb5ccec212 Cleaned up some possible race conditions with threads
* ExitThread no longer NORETURN, this eases handling of threads.
* Fixed a (rare) race condition when starting a thread
* Made global thread_list optional (you lose the exit code from
  ExitThread)
2021-09-20 10:59:59 +02:00
akallabeth
8d82adb28a Fixed warnings 2021-06-17 10:35:22 +02:00
Armin Novak
d36d94766e Replaced assert with WINPR_ASSERT 2021-06-14 09:37:07 +02:00
David Fort
aeba30a505 winpr: correctly implement APC
This patch implements APC functions and fixes waitable timers with completions.
2021-04-07 08:15:16 +02:00
Kobi Mizrachi
8c3054851c winpr: thread: fix wrong log level in ThreadCloseHandle 2020-01-08 11:59:34 +01:00
Armin Novak
72ca88f49c Reformatted to new style 2019-11-07 10:53:54 +01:00
Armin Novak
b08505cbe0 Fixed return check in SwitchToThread
Patch on mailing list by Andrey Vasilkin
2019-01-18 13:02:30 +01:00
Armin Novak
46d6aa4e2b Fixed cast warnings for thread wrapper 2018-10-24 13:24:45 +02:00
Armin Novak
554e18780b USe const compare function pointer arguments 2018-10-18 09:06:55 +02:00
David Fort
917bc4b551 set some define consistency
This patch cleanup the defines to make then consistent.
2018-02-05 14:17:23 +01:00
Armin Novak
3baba6f9c0 Removed unused argument. 2017-11-15 15:56:24 +01: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
Armin Novak
edacd7c6b7 Thread using proper function pointer type. 2016-10-07 14:07:51 +02:00
Norbert Federa
458f606934 winpr/thread: fix SwitchToThread
On some operating systems sched_yield is a stub returning returning -1.
In that case use usleep which should at least trigger a context switch
if any thread is waiting.
2016-06-02 15:38:57 +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
Armin Novak
b6b0f57a88 Fixed compiler warning about cast. 2016-02-04 12:57:21 +01:00
Marc-André Moreau
611c194f80 Merge pull request #2801 from bmiklautz/fix/thread
winpr/thread: small cleanups
2015-07-28 08:47:06 -04:00
Bernhard Miklautz
c3ea07f3d9 winpr/thread: don't close invalid file descriptors
In case the file descriptor is -1 don't call close.
2015-07-24 14:57:47 +02:00
Bernhard Miklautz
81d422588e winrp/thread: don't call pthread_exit on return
As the pthread_exit man page states pthread_exit is called implicitly
when the start function returns.
2015-07-24 14:52:31 +02:00
Bernhard Miklautz
ca150f2255 winpr/thread: small cleanups
Also adds error checking of winpr_StartThread in winpr_StartThread.
2015-07-23 11:52:49 +02:00
Armin Novak
9af2e22d51 Fixed mutex unlocking and return checks. 2015-07-16 17:07:29 +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
d18b0fbeb4 Handle API updated. 2015-07-03 09:52:52 +02:00
Emmanuel Ledoux
de1a21eadd winpr-thread: added HP's copyright 2015-05-27 18:24:56 +02:00
Emmanuel Ledoux
206714a270 winpr-thread: thread_list's synchronization based on a pthread_cond_t 2015-05-27 18:15:17 +02:00
Emmanuel Ledoux
f74cd12df2 winpr-thread: a better error message and comments about thread_list 2015-05-26 18:15:57 +02:00
Emmanuel Ledoux
56f34582c7 winpr-thread: added an assertion to enforce that thread_list is correctly set 2015-05-26 17:55:27 +02:00
Emmanuel Ledoux
93127e0a7a winpr-thread: thread_list's synchronization based on an Event 2015-05-26 17:40:34 +02:00
Emmanuel Ledoux
6f5de27081 winpr-thread:
- added the unit test: TestThreadExitThread
  - fix: ensure thread_list to be up to date before to call ExitThread()
  - possibly resolved: Problems with serial redirection #2389
2015-05-22 18:28:10 +02:00
Marc-André Moreau
b9c1cddc2e Merge pull request #2583 from bceverly/OpenBSD-cleanup
Two minor source code changes to remove warnings
2015-05-21 10:17:54 -04:00
Bryan Everly
a3a3efe31e Fixed mistake with bitwise operator in previous two commits 2015-05-20 12:17:05 -04:00
Bryan Everly
80af54b169 Moved thread code to OpenBSD only 2015-05-20 10:52:24 -04:00
Hardening
f8120919af Add checks for some XXX_New and XXX_Add functions
Based on PR #2616
2015-05-18 11:28:00 +02:00
Norbert Federa
1eff1a345e free can handle NULL perfectly fine 2015-05-11 09:07:39 +02:00
Bryan Everly
9865854f3c Simplified random byte stream generation code to use SSL RAND_bytes() and also eliminated two more compiler warnings. 2015-05-05 12:33:44 -04:00
Armin Novak
b3ea02a777 Removed INVALID_HANDLE_VALUE from types not using it. 2015-03-31 15:18:45 +02:00
Armin Novak
afe8bd2a86 Fixed missing checks for invalid handle. 2015-03-31 15:18:45 +02:00
Bernhard Miklautz
1d7b3694a9 Integrate feedback from pull request (#2492)
* shell: add missing NULL checks
* thread: handle case where HAVE_EVENTFD_H isn't defined
* wlog: return NULL instead of 0
* wlog: use g_RootLog instead of WLog_GetRoot
  otherwise a new root might be initialized on uninit
* indentation and style fixes
2015-03-25 17:38:21 +01:00
Bernhard Miklautz
3c7662517c hardening
Start to add missing checks for:
* *alloc
* *_New
2015-03-25 17:38:21 +01:00
David FORT
52bd4469d9 Make handle operations static
This patch moves the handle operations in a static struct.
2015-03-16 10:31:26 +01:00
Armin Novak
9153af6a3e Using new handle cleanup structure 2015-03-11 17:57:01 +01:00
Emmanuel Ledoux
4aeaffa286 libwinpr: better indentation 2015-01-28 12:43:20 +01:00