Sönke Ludwig
b77adfcbd2
Add proper thread synchronization to EventDriverDNS_GAI.
2019-10-07 11:18:58 +02:00
Sönke Ludwig
5255645455
Start a thread for each DNS lookup. Fixes vibe-d/vibe.d#2378 .
...
std.parallelism.Task.executeInNewThread leaks the thread's resources instead of reusing it in later calls. As a workaround, this commit starts a new thread for every lookup and properly tears it down afterwards. At a later point, this code should be changed to reuse the thread(s), if possible, to avoid the startup overhead.
2019-10-07 11:10:21 +02:00
Hiroki Noda
4aa6420662
Remove unused function safeYield
2019-09-26 20:33:05 +09:00
Benjamin Schaaf
782fc40152
Add MSG_NOSIGNAL flag to send call to avoid SIGPIPE ( #128 )
...
Add MSG_NOSIGNAL flag to send call to avoid SIGPIPE
merged-on-behalf-of: Sönke Ludwig <s-ludwig@users.noreply.github.com>
2019-09-06 19:15:30 +02:00
Geod24
312f49ce65
Remove outdate comments for unsupported compilers
2019-09-03 02:10:02 +09:00
Sönke Ludwig
20373d10db
Fix indentation and remove unused imports/variables.
2019-08-23 19:55:55 +02:00
Sönke Ludwig
5c3afcc175
Ensure that a valid PID is passed to kill().
2019-08-23 09:35:13 +02:00
Sönke Ludwig
01c2c26964
Fix Windows compilation.
...
Integrates the contents of StaticProcesses into PosixEventDriverProcesses to fully hide it form the Windows build. It also changes lockedProcessInfo to be a non-template function, as that lead to a linker error on macOS.
2019-08-23 09:35:13 +02:00
Sönke Ludwig
f1c2eb779f
Use the Posix process driver on all Posix operating systems.
2019-08-23 09:35:13 +02:00
Sönke Ludwig
7ebad49ed0
Rework the child process exit code to not rely in SIGCHLD.
...
It turns out that in a heterogeneous process where other parts of the code may start processes or threads and may be waiting for those to finish, it is not realistic to rely on signalfd or even SIGCHLD in general to get notified about child process exits. The only solid way appears to be to start a separate waiter thread that uses waitid/waitpid to wait for exited child processes in a blocking way.
This also fixes the hanging vibe.core.process test in vibe-core with DMD 2.087.x.
2019-08-23 09:35:12 +02:00
Sönke Ludwig
4724f14145
Avoid interference with other users of waitpid.
...
Instead of using waitpid(-1), explicitly waits on all known processes. This is inefficient for large numbers of child processes, but seems to be the only way to ensure to not interfere with other code that uses waitpid().
2019-08-23 09:35:12 +02:00
Sönke Ludwig
72234fc0a7
Return an invalid wait ID for processes.wait() if the process has already exited.
...
Avoids overlap with valid wait IDs, so that a paired cancelWait() doesn't cancel a different wait.
2019-08-23 09:35:12 +02:00
Sönke Ludwig
507fb5a0c9
Use waitpid to iterate over all exited child processes. Fixes #116 . Closes #117 .
2019-08-23 09:35:12 +02:00
Sönke Ludwig
e1c6d99798
Fix indentation style.
2019-08-23 09:35:11 +02:00
Caleb Connolly
c2e55122bf
Fix #119
...
Added missing import to fix `undefined identifier intptr_t`
2019-08-20 17:43:25 +00:00
Sönke Ludwig
9bb6be87c3
Fix possible access of freed directory watcher entries.
...
This mainly affected macOS, which currently uses the polling directory watcher. Since entries were freed during the loop, the remaining keys could point to already freed entries.
2019-08-19 23:59:11 +02:00
Sönke Ludwig
cf33c3d859
Merge pull request #112 from BenjaminSchaaf/socket-fix
...
Fix socket not being in a connected state after connectStream
2019-08-17 14:44:48 +02:00
Sönke Ludwig
2d0fd8b1e6
Merge pull request #115 from v1ne/win-fix-appending-to-file
...
winapi/files: Append to files with FILE_APPEND_DATA
2019-08-17 14:29:14 +02:00
v1ne
c2708f1de8
winapi/files: Append to files with FILE_APPEND_DATA
...
Before, the mode GENERIC_WRITE was used. This tells Windows to not
append to the file, but overwrite it normally. This is not the intended
semantics. FILE_APPEND_DATA does what we want.
2019-07-25 23:56:04 +02:00
Benjamin Schaaf
4d71b62507
Fix crash when subprocess was not spawned by eventcore
2019-07-22 10:55:45 +10:00
Benjamin Schaaf
a8cd897df7
Proposed fix for processes in multi-threaded environments
2019-07-21 20:43:06 +10:00
Benjamin Schaaf
472321f1f5
Fix socket not being in a connected state after connectStream
2019-07-17 23:12:59 +10:00
Sönke Ludwig
e7bf50ea2d
Merge pull request #110 from BenjaminSchaaf/process
...
Fix pipe writing
2019-06-02 09:13:26 +02:00
Sönke Ludwig
731936ce9e
Separate the polling logic of PollEventDriverWatchers into a separate class.
...
Allows to keep thread-local state separate from the mutex-protected/immutable state in PollingThread to make sure that there are no unwanted accesses.
2019-05-30 11:33:04 +02:00
Benjamin Schaaf
9a09e42802
Fix pipe writing
2019-05-05 14:31:12 +10:00
The Dlang Bot
83310fda70
Merge pull request #109 from vibe-d/fixes
...
Threading fixes
merged-on-behalf-of: Leonid Kramer <l-kramer@users.noreply.github.com>
2019-04-13 22:17:24 +02:00
Sönke Ludwig
78db7c9573
Fix race-condition in ThreadedFileEventDriver.
...
The m_files field was accessed from the worker threads, which is unsafe, because the chunk index of the ChoppedVector could change at any time. The accessed field is now copied to the worker thread instead.
Also, instead of a custom spin lock, StaticTaskPool now uses a normal Mutex, which is just as fast, but emits the proper memory barriers and is integrated with LDC's thread sanitizer.
2019-04-13 18:27:23 +02:00
Sönke Ludwig
48d083b20f
Fix possible race condition in PosixEventDriverEvents.trigger.
...
Accessing the event slot should only be done from the owner thread, since the chunk index of the ChoppedVector could be updated at any time. Instead of a triggerAll field, this flag is now propagated through the underlying eventfd/socket pair.
2019-04-13 18:27:23 +02:00
Sönke Ludwig
9feccbe537
Fix missing nogc annotations for userData accessors.
...
User data only compiled successfully for sockets before this change.
2019-04-13 17:25:47 +02:00
Sönke Ludwig
304de7a39a
Use Mallocator for Win32 file system watcher buffer.
...
Avoids allocating using the GC, which `theAllocator` points to by default.
2019-04-09 18:23:24 +02:00
Leonid Kramer
1bbe244196
Merge pull request #107 from vibe-d/disable_so_addr
...
Add `StreamListenOptions.reuseAddress`.
2019-04-01 20:38:29 +02:00
The Dlang Bot
b11936e4bc
Merge pull request #100 from BenjaminSchaaf/process
...
Add APIs for working with Subprocesses and Pipes
merged-on-behalf-of: Sönke Ludwig <s-ludwig@users.noreply.github.com>
2019-04-01 14:48:41 +02:00
Sönke Ludwig
891eed3d62
Add StreamListenOptions.reuseAddress
and make it the default.
...
Replaces the current combined behavior controlled by `reusePort`, introduced by #103 .
2019-04-01 13:50:33 +02:00
Sönke Ludwig
d20b7a77ee
Properly zero-initialize ChoppedVector's chunk index table.
2019-04-01 10:59:28 +02:00
Radu Racariu
11ad96be4d
Import the druntime core.sys.posix.sys.socket
...
This will pickup platform specific definitions from the
2019-03-14 16:29:02 +02:00
Sönke Ludwig
5f703cf039
Merge pull request #104 from rracariu/patch-1
...
[PosixEventDriverEvents] Use Linux definitions from druntime
2019-02-23 14:04:37 +01:00
Sönke Ludwig
b08bd6a9db
Merge pull request #103 from rracariu/master
...
Don't try to set the SO_REUSEPORT flag on Linux
2019-02-23 14:03:17 +01:00
Sönke Ludwig
a59e4b6455
Make handling of corrupt Windows file system watcher events more robust.
...
The reason for the intermittent corruptions still needs to be found.
2019-02-22 21:29:18 +01:00
Benjamin Schaaf
1afc5ca1c0
Fix waiterCount not including waiting processes
2019-02-21 22:13:05 +11:00
Radu Racariu
07b09e8692
fix @safe
2019-02-12 19:55:32 +02:00
Radu Racariu
6286c7980d
[PosixEventDriverEvents] Use Linux definitions from druntime
...
This doesn't duplicate the definitions form `core.sys.linux.sys.eventfd` and will pickup any platform specifics for better portability.
Fixes https://github.com/vibe-d/eventcore/issues/102
2019-02-12 19:47:37 +02:00
Radu Racariu
cb06ecfbcf
don't try to set the SO_REUSEPORT flag
...
On Linux this option was always set, regardless if the `StreamListenOptions` specifies it.
On some systems setting that option will result in a failure.
2019-02-11 15:42:42 +02:00
Benjamin Schaaf
7ef5c6686e
Fix more Windows compiler errors
2019-01-16 10:23:25 +11:00
Benjamin Schaaf
dd915e74b1
Fix Windows compiler errors
2019-01-16 10:09:49 +11:00
Benjamin Schaaf
6108a64973
Fix OSX compiler errors
2019-01-15 21:32:36 +11:00
Benjamin Schaaf
7d091ed504
Add APIs for working with Subprocesses and Pipes with an implementation for Posix
2019-01-15 19:58:01 +11:00
The Dlang Bot
36f43690c6
Merge pull request #98 from vibe-d/file_truncation
...
Add EventDriverFiles.truncate.
merged-on-behalf-of: Sönke Ludwig <s-ludwig@users.noreply.github.com>
2018-12-28 10:27:38 +01:00
Sönke Ludwig
8205258ee9
Define handles as properly named structs.
...
Greatly enhances the readability of compiler error messages, as well as sometimes considerably reducing the size of symbol bloat.
2018-12-28 00:43:11 +01:00
Sönke Ludwig
3e81cefcda
Add EventDriverFiles.truncate.
2018-12-28 00:34:30 +01:00
Hiroki Noda
3b6b2ab900
Use monotonic clock for timeout
...
The system clock can be updated manually by the sys-admin or
automatically by NTP, so use monotonic clock instead.
2018-12-23 21:37:12 +09:00
Sönke Ludwig
968084f074
Remove the default dependency to libanl. Fixes #78 .
...
The dependency wasn't used at all, but is now optionally used through the epoll-gaia configuration.
2018-11-11 13:07:48 +01:00
Sönke Ludwig
4ae402223c
Fix compilation of the getaddrinfo_a based DNS resolver.
2018-11-11 13:06:56 +01:00
Martin Nowak
619f266a4b
typo
2018-11-06 00:54:23 +01:00
Sönke Ludwig
b33f710420
Keep timers with active waits referenced.
...
Avoids calling the wait callback with reference count zero. In case of a non-pending timer, the wait will be canceled if the wait reference is the last one to avoid keeping starved timers.
2018-10-27 15:45:55 +02:00
Sönke Ludwig
dbb8267540
Introduce TimerCallback2.
...
This allows getting notified also if the timer has been stopped, so that it is guaranteed to be called, except if cancelWait is called.
Necessary for fixing vibe-d/vibe-core#86
2018-10-27 14:11:11 +02:00
Sönke Ludwig
16749d0a58
Use stderr instead of stdout for debug messages.
...
Avoids polluting the regular application output.
2018-10-26 20:40:22 +02:00
Sönke Ludwig
e2e8bf30aa
Change shutdown behavior to allow graceful handle leaks.
...
This avoids crashing in case of any handle references left-over in GC allocated memory that gets finalized after module destructors have already been run.
2018-10-26 20:40:22 +02:00
Sönke Ludwig
c553df66e1
Fix freeing of the loop in PosixEventDriver
2018-10-24 21:06:31 +02:00
Sönke Ludwig
4d8d08b27d
Fix destruction code in ChoppedVector.
2018-10-24 21:05:45 +02:00
Sönke Ludwig
406367b6c6
Fix epoll compile error on older frontends.
2018-10-24 12:08:38 +02:00
Sönke Ludwig
6e839de7e2
Refactor PollEventDriverWatchers.
...
- Better encapsulates the mutex protection inside PollingThread
- Uses mallocT/freeT to allocate snapshot nodes
2018-10-24 11:38:14 +02:00
Sönke Ludwig
0b73eda8d5
Deprecate the non-nogc userData overload.
...
This allows more of the implementation to become nogc.
2018-10-24 11:38:14 +02:00
Sönke Ludwig
73abd867b4
Initialize the driver instance lazily.
2018-10-24 11:38:14 +02:00
Sönke Ludwig
284d4f43c3
Make the WinAPI driver initialization nogc.
2018-10-24 11:38:14 +02:00
Sönke Ludwig
e7e4a0f5f5
Make the Posix driver initialization nogc.
2018-10-24 11:38:14 +02:00
Sönke Ludwig
a4eaafce9a
Avoid GC allocation in StaticTaskPool.
2018-10-24 11:38:13 +02:00
Sönke Ludwig
d66f257179
Avoid GC allocations for LoopTimeoutTimerDriver.m_firedTimers.
2018-10-24 11:38:13 +02:00
Sönke Ludwig
4a605640bc
Make ConsumableQueue nogc.
2018-10-24 11:38:13 +02:00
Sönke Ludwig
90a60f7981
Add nogc typed alloc/free functions and make assert_nogc actually nogc.
2018-10-24 11:38:13 +02:00
Sönke Ludwig
4e3edf5292
Fix ThreadedFileEventDriver event cancellation when not waiting.
2018-10-02 10:16:26 +02:00
Sönke Ludwig
8495d7d91c
Fix UCS-2 to UTF-8 conversion in the Windows watchers implementation.
2018-10-01 22:00:26 +02:00
Sönke Ludwig
87fb595aee
Clear WSA buffers to make sure to detect erroneous accesses.
2018-10-01 22:00:22 +02:00
Sönke Ludwig
491e100ef5
Merge pull request #83 from vibe-d/s-ludwig-patch-1
...
Add Solaris definition for O_CLOEXEC. Fixes #82 .
2018-08-29 23:16:47 +02:00
Sönke Ludwig
c404cc2e5b
Merge pull request #76 from Boris-Barboris/keepalive_params
...
fix Keepalive on Linux, expose keepalive options, TCP_USER_TIMEOUT for linux.
2018-08-29 23:16:23 +02:00
Sönke Ludwig
0c62764216
Add Solaris definition for O_CLOEXEC. Fixes #82 .
2018-08-16 15:19:12 +02:00
Boris-Barboris
ed9fdcd467
ease asserting, constants wrapped for future robustness
2018-06-06 11:45:36 +00:00
Sönke Ludwig
5d317ca9e7
Remove special case for zero-wait processing off events.
...
This ensures that all kinds of events are processed, including timers and I/O events.
2018-06-05 11:35:57 +02:00
Sönke Ludwig
abdbc91c4b
Merge pull request #72 from kubo39/res_init
...
Call __res_init on linux when getaddrinfo failed, fix #40
2018-05-13 09:45:12 +02:00
The Dlang Bot
ca56b31566
Merge pull request #71 from kubo39/somaxconn
...
Get the listen backlog size from net.core.somaxconn on Linux
merged-on-behalf-of: Sönke Ludwig <s-ludwig@users.noreply.github.com>
2018-05-13 09:44:42 +02:00
Sönke Ludwig
48b214dd09
Fix initialization behavior when being loaded as a shared library.
...
When loading a shared library where both, the host and the library, use eventcore, the static constructors/destructors will be called multiple times.
2018-05-04 17:45:10 +02:00
Boris-Barboris
a2d96f1831
fix setKeepAliveParams on Windows
2018-04-02 18:06:00 +03:00
Boris-Barboris
322438697c
TCP_USER_TIMEOUT
2018-04-02 14:02:09 +00:00
Boris-Barboris
cdb141ba4a
add setKeepAliveParams method
2018-04-02 11:11:28 +00:00
Sönke Ludwig
242432c416
Fix two possible causes for range violations in the WinAPI handle map.
2018-03-30 16:57:45 +02:00
Sönke Ludwig
811ae63698
Fix indentation.
2018-03-30 16:56:42 +02:00
Hiroki Noda
e68f1425a9
format
2018-03-22 05:16:36 +09:00
Hiroki Noda
d3708c5e66
Fix: leak fd
2018-03-22 05:14:10 +09:00
Hiroki Noda
041d55e584
Get the listen backlog size from net.core.somaxconn on linux
2018-03-22 05:12:37 +09:00
Sönke Ludwig
51527e77f8
Actually close files in the WinAPI driver.
2018-03-20 21:03:43 +01:00
Sönke Ludwig
3cb0891c58
Create the DNS helper event lazily.
...
Reduces resource usage on threads that don't perform DNS queries.
2018-03-18 01:32:09 +01:00
Sönke Ludwig
b09d15d503
Fix dangling handles resulting from actively closing a file.
2018-03-17 17:11:03 +01:00
Sönke Ludwig
7da41301af
Tighten the file descriptor slot checks.
...
Gives the chance to detect possible dangling file descriptors earlier.
2018-03-17 13:11:44 +01:00
Sönke Ludwig
16e2d9587d
Implement EventDriverCore.runInOwnerThread.
2018-03-16 16:11:46 +01:00
Sönke Ludwig
7bfbb64899
Add userData!T properties for all descriptor based primitives.
2018-03-16 13:39:03 +01:00
Sönke Ludwig
68b8f44957
Merge pull request #63 from vibe-d/fix_connect_socket_callback
...
Call the callback on connectStream socket creation failure.
2018-03-14 22:19:14 +01:00
Sönke Ludwig
6262c48db3
Merge pull request #65 from vibe-d/fix_eventfd_leak
...
Fix leaked eventfd in PosixEventDriverCore.
2018-03-14 22:19:00 +01:00
Sönke Ludwig
b6b32f4a49
Fix leaked eventfd in PosixEventDriverCore.
...
The leak occurred once per thread, which showed up in conjunction with DNS lookups in particular, as a thread is currently created for each lookup.
2018-03-14 21:59:42 +01:00
Sönke Ludwig
4192d31716
Create the event object in ThreadedFileEventDriver lazily.
...
Avoids creating event objects for every worker thread, even if never used.
2018-03-14 21:39:54 +01:00
Sönke Ludwig
02de8341aa
Call the callback on connectStream socket creation failure.
...
The callback must *always* be called at some point, because the generic async->sync logic in vibe-core otherwise has no way to know whether to expect a callback or not.
2018-03-14 20:43:40 +01:00
Sönke Ludwig
53bb8eeead
Fix cleanup code for directory watchers in the WinAPI driver.
...
- Fixes an assertion triggered by accessing a file field in releaseRef
- Fixed a potential leak of file system watcher handles when calling releaseRef from inside the supplied callback - this was the reason why the fixed assertion error wasn't triggered by the test code
2018-03-14 16:39:57 +01:00