Commit Graph

513 Commits

Author SHA1 Message Date
Max Kellermann c18e00daa4 event/PollGroup: move event flags to a separate header
Reduce header dependencies for SocketEvent.hxx.
2020-10-19 14:48:41 +02:00
Max Kellermann 418ba96334 event/SocketEvent: forbid copying 2020-10-18 20:07:49 +02:00
Max Kellermann a60e782959 event/Loop: reorder assertions 2020-10-18 20:05:22 +02:00
Max Kellermann 8bab5733d7 event/Loop: add assertions 2020-10-18 20:04:16 +02:00
Max Kellermann e3270dfd68 event/SocketEvent: use class IntrusiveList<> 2020-10-18 20:02:47 +02:00
Max Kellermann a14997ffb8 event/Loop: manage all SocketEvents in a linked list
Not only those which are "ready".
2020-10-18 20:01:38 +02:00
Max Kellermann dd94f97572 event/Loop: un-inline AddFD(), ModifyFD()
Prepare for adding more code here.
2020-10-18 19:58:42 +02:00
Max Kellermann 7d502fb448 event/Loop: round epoll_wait() timeout up
This implements proper rounding, amending commit dcbb9fe07c
2020-10-18 19:58:42 +02:00
Max Kellermann f64799622d event/IdleEvent: use class IntrusiveList<> 2020-10-18 19:28:12 +02:00
Max Kellermann b5750afb24 event/IdleEvent: use `auto` 2020-10-18 19:23:34 +02:00
Max Kellermann 442dd5e955 event/IdleEvent: forbid copying 2020-10-18 19:23:25 +02:00
Max Kellermann cb382b1e7d event/PollGroupWinSelect: add missing return value
Fixes regression from commit 1473d8474f
2020-10-16 19:02:00 +02:00
Max Kellermann b611b1824a event/Loop: move code to Wait() 2020-10-15 20:21:00 +02:00
Max Kellermann 1473d8474f event/PollGroup: ReadEvents() returns PollResult 2020-10-15 20:15:09 +02:00
Max Kellermann 725985379a event/SocketEvent: add ScheduleImplicit(), Is{Read,Write}Pending() 2020-10-15 17:01:30 +02:00
Max Kellermann 8849b9b62c event/SocketEvent: move Abandon() up 2020-10-15 16:59:45 +02:00
Max Kellermann caa2611ad5 event/SocketEvent: add Abandon() 2020-10-15 16:57:55 +02:00
Max Kellermann f8ff597963 event/SocketEvent: document Close() 2020-10-15 16:55:31 +02:00
Max Kellermann ff6e434caf event/SocketEvent: rename Steal() to ReleaseSocket() 2020-10-15 16:54:33 +02:00
Max Kellermann 55db7105c5 event/SocketEvent: check/clear scheduled_flags in Close()
Fixes regression by commit 521e573be9
2020-10-14 21:08:39 +02:00
Max Kellermann 48afb68f3a event/SocketEvent: remove assert() from GetScheduledFlags()
Fixes regression by commit 7901b04c78
2020-10-14 20:50:02 +02:00
Max Kellermann 21f409d5e2 event/SocketEvent: fix grammar 2020-10-14 16:30:38 +02:00
Max Kellermann 521e573be9 event/SocketEvent: use EventLoop::AbandonFD() in Close() 2020-10-14 16:29:49 +02:00
Max Kellermann abf9ae2dd9 event/Loop: rename Abandon() to AbandonFD() 2020-10-14 16:26:06 +02:00
Max Kellermann 9f013f7de4 event/SocketEvent: allow Close() without socket 2020-10-14 16:26:01 +02:00
Max Kellermann 7fc04fd5cd event/SocketEvent: move Dispatch() down 2020-10-14 16:21:41 +02:00
Max Kellermann 7901b04c78 event/SocketEvent: allow Cancel() without socket 2020-10-14 16:20:43 +02:00
Max Kellermann 653eea5840 event/SocketEvent: remove unnecessary initializer 2020-10-14 16:18:39 +02:00
Max Kellermann 5a4055fb08 event/SocketMonitor: refactor to SocketEvent
Similar to commits 1686f4e857 and
30a5dd267b
2020-10-14 15:54:12 +02:00
Max Kellermann 4d68a12f03 event/Loop: split the AtScopeExit()
Fixes the !HAVE_THREADED_EVENT_LOOP build.
2020-10-14 14:47:59 +02:00
Max Kellermann 0e951da64b event/Loop: add missing #ifdef 2020-10-14 14:37:29 +02:00
Max Kellermann 38dab040b3 event/Loop: add compile-time option to disable multithreading
Not for MPD, but for other applications which might want to copy its
event loop, but do not need multi-threading.
2020-10-14 14:08:38 +02:00
Max Kellermann e9f6af61f9 event/Loop: forward-declare class {Idle,Defer}Event 2020-10-14 14:05:17 +02:00
Max Kellermann b06c4e2711 event/{Idle,Defer}Event: use base_hook instead of member_hook
Allows forward declaration.
2020-10-14 14:04:30 +02:00
Max Kellermann 1686f4e857 event/IdleMonitor: refactor to IdleEvent
Instead of using this as a base class implementing a virtual method,
the new class IdleEvent can be used as a variable, decoupling
IdleMonitor's internal state from the derived class.

This is similar to commit 30a5dd267b
which refactored TimeoutMonitor to TimerEvent.
2020-10-14 13:47:25 +02:00
Max Kellermann 329382c1da event/SignalMonitor: add `noexcept` 2020-10-13 17:26:33 +02:00
Max Kellermann fadc03df21 meson.build: move macros to event/Features.h 2020-10-13 16:15:52 +02:00
Max Kellermann 54ee0e28ab event/PollGroup: check _WIN32 instead of USE_WINSELECT 2020-10-13 15:27:58 +02:00
Max Kellermann 92fc53ebef event/PollGroupWinSelect: use range-based `for` 2020-10-12 12:44:23 +02:00
Max Kellermann 7e7a1613cf event/PollGroupWinSelect: use std::copy_n() 2020-10-12 12:40:32 +02:00
Max Kellermann f73c4643ef event/PollGroupWinSelect: move IsEmpty() check to GetPtr() 2020-10-12 12:39:10 +02:00
Max Kellermann 8b94e8f260 event/PollGroupWinSelect: use `SOCKET` instead of `int` 2020-10-12 12:13:46 +02:00
Max Kellermann 41bc17a27f event/SocketMonitor: add `ready_flags`
By making each SocketMonitor keep track of its ready flags, this
removes a lot of overhead from EventLoop::RemoveFD().
2020-10-09 17:28:11 +02:00
Max Kellermann 41c0bbab13 event/SocketMonitor: don't filter out ERROR/HANGUP
By bit-wise ANDing the reported flags with GetScheduledFlags(),
ERROR/HANGUP always get cleared.  This means the MPD event loop could
never report those conditions.
2020-10-08 21:16:18 +02:00
Max Kellermann eeb96eb367 event/TimerEvent: add type alias for std::chrono::steady_clock::duration 2020-10-08 20:48:50 +02:00
Max Kellermann ce93e58944 event/TimerEvent: use `using` instead of `typedef` 2020-10-08 20:46:18 +02:00
Max Kellermann 263b0ffdbb event/TimerEvent: use auto_unlink hook 2020-10-08 20:46:15 +02:00
Max Kellermann 22bea5c97e event/Loop: reorder includes
This just happened to break the Windows build because of the
`GetObject` macro in `windows.h`, so I added a kludge to
PollResultGeneric.hxx.
2020-10-08 20:43:21 +02:00
Max Kellermann 947856ca8e event/Loop: forward-declare class TimerEvent 2020-10-08 17:24:32 +02:00
Max Kellermann cd9ff9d9b0 event/TimerEvent: use base_hook instead of member_hook 2020-10-08 17:00:09 +02:00
Max Kellermann 4cd0f661d6 event/Loop: use `using` instead of `typedef` 2020-10-08 16:59:21 +02:00
Max Kellermann ca0179b2a9 event/Loop: set the uring_initialized flag
Don't attempt to initialize the io_uring subsystem more than once.
2020-10-06 18:58:54 +02:00
Max Kellermann cdf8ac001c event/Loop: integrate io_uring support 2020-05-05 17:13:14 +02:00
Max Kellermann 935e622915 event/Loop: allow calling AddFD()... before starting the EventThread
Relax the assertions.  This is necessary if BlockingCall() is used
before the thread is started.
2020-05-05 17:10:17 +02:00
Max Kellermann 0b3acc3eec release v0.21.23
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAl6huEwQHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEgcrD/9jLUkiszNc+QWbUGj+RiTaD6fMxA1M8itn
 nB7MKI/g/3ggryWMWNhG51O+8wFNs/4PmJJPGxKoU6i6wmS3YFhTAcs0ryilDGAU
 1FumnMg/2qIyi2E6K2BMbi0YwZiJhBPWwD4JSt1KGvwPes/qQPFgHAi7ZWhP3tar
 fHmgmjwDZ/Kgpl5/Bn7nVNgVuzk/MpBOSwxX9tFtRxqE9wdpm9idve7SVDT7MTvk
 vdONWbAe8jXl/A8JHWaUsws0l7fyK5ZKSOXvdeSbzd67I8Rz3aqJMqUh2k/rDuv/
 GrDyeEtLV5cXZsL4B3/34kCTKac2ZJmRbSh+buKeDc1Gf0clWnvRMdsMbSoRBY4F
 lTWJbjndfq2+iHHBRfaqRjombv52R11yLT+O0aMLEm6l7xPm/rHZXJIcYSmCafd7
 FR1qMaVKP5s+M+MqGePxzCUJSWJ+1bjZwjLaHrYXYPUoXSg3mSaeDE5g7BjQhm1E
 2Hcfui9lvqR55UNo0NvDBjRT5FBGBUdjF6DjYplUGApw7xFtdahXlEvG7yfyg3ae
 pZ3FQ1MZ4dESAw7EhTEBwajsVRQ9DhGQenYTxxCnGVdCucZRPQ9Abhas0U4iFHUA
 wGj7j4WKPi+OUSyiT0j4nGuwEVtCkBFv34DqPMLjx8jqtJ8YgCt4iJD4dFwhk1zz
 uoQBhq27Gg==
 =sR2r
 -----END PGP SIGNATURE-----

Merge tag 'v0.21.23'

release v0.21.23
2020-04-23 18:01:23 +02:00
Max Kellermann 8ed533acf3 event/SocketMonitor: handle epoll_ctl()=EBADF/ENOENT in Schedule()
This fixes a freeze bug in the NFS input/storage plugins: when libnfs
auto-reconnets after a failure, it installs the new socket on the same
file descriptor number.  MPD's attempt to unregister the old socket by
calling SocketMonitor::Steal() from NfsConnection::ScheduleSocket()
fails because the new/old socket number is not registered in epoll, so
epoll_ctl() returns ENOENT.  The problem is that it left
`scheduled_flags`, and so subsequent Schedule() calls will use
`EPOLL_CTL_MOD`, which will fail again and again.  Instead, we need to
use `EPOLL_CTL_ADD` to register the new socket.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/806

Closes https://github.com/MusicPlayerDaemon/MPD/issues/756
2020-04-23 16:58:26 +02:00
Max Kellermann 4242aee21e event/SocketMonitor: remove HANGUP|ERROR from ScheduleRead()
These flags are output-only.  Using them here is misleading.
2020-04-23 15:18:18 +02:00
Max Kellermann e71bd2a08b event/PollGroupWinSelect: make EVENT_{READ,WRITE} `static` 2020-04-23 15:10:57 +02:00
Max Kellermann 12b97bbe38 release v0.21.22
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAl6GCWgQHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEvkQD/9qg6cnCgCKSOmTjteJu1ayeXBMDiL3cCCg
 AwarHQoxsB0102NpV+MLka+4HIwHn+WNL55TzYgfbSh0nfmnki2fZ0YpsZoQR79w
 MP11iMPnFH1oKqj58minBkFNmAis2aLYHJGKaQNUh7wcf0WhbVTqtWBUrKb07RQ0
 Zj5lXtg65O/+yaCVdQGS6fMk2t7CqBM+S3RmbXCib/JRMC6aozoC7nWPvj8b2R8d
 PgxwKMRzyslyFoxDQZrusDjJ1piyigzUMMr32yzYDED4Xr8jsEELaJfULbr6qWT2
 ZNYF91e+D5V7riASAtlFTaVMaISx4QbHjKWR5Xcx0q/SJPAXTxF8RrAqGvqpWYmc
 kqmC8iNxQsW5o3sNhI9qg6sOkq2dIu43VasRCvuo19GABR36wwTK5ORoazIi8fbU
 /Ki/oZHtZczHRop9Cd6698Qr9jyTPdIs55FbgejzrVADvAmslqtcA6XxCBuG1nSF
 Qo48dp9Px7J74qNNuDt5/xLnQGJKaW60/BXrMK9G9QG4x9r4zuCayDO6Qc7FMWWR
 DG7k9nYoXJU5YG7xp9Rk+Yj3Ade8kqhTnKfqw0f2JfkLt0ChPG+rZcxICWSdzZm0
 AfHxuEQlwKaaFHFEsZhVehlsXkeU9OVywo+QDzmY2uqQ2ddlBZ47Qm2MWgTsv8i/
 euVsrzLtag==
 =EedX
 -----END PGP SIGNATURE-----

Merge tag 'v0.21.22'

release v0.21.22
2020-04-02 18:02:10 +02:00
Max Kellermann e94c436264 src/event/meson.build: depend in libnet.a
The event library uses various libnet.a classes,
e.g. SocketDescriptor.
2020-04-02 17:16:05 +02:00
Max Kellermann 8cd5e79fbd event/*, ...: make GetEventLoop() const 2020-03-26 17:19:13 +01:00
Rosen Penev f319f88df4 [cppcheck] use const for several variables
Found with constVariable

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-23 21:03:22 -07:00
Rosen Penev 97425d56e7
remove gcc_unused
[[maybe_unused]] (introduced in C++17) is standard C++.

https://clang.llvm.org/docs/AttributeReference.html#maybe-unused-unused
says that this is equivalent to the GNU unused attribute.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-16 00:08:21 -07:00
Rosen Penev a2f5a63bbc
replace stdint.h with cstdint
The former is deprecated by C++14. The standard says they are the same:

The header defines all types and macros the same as the C standard library
header<stdint.h>.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-12 19:04:39 -07:00
Rosen Penev 2db8bcc353
replace stddef.h with cstddef
The former is deprecated with C++14. The standard says both are the same:

The contents and meaning of the header<cstddef>are the same as the C
standard library header<stddef.h>,except that it does not declare the type
wchar_t, that it also declares the type byte and its associated
operations (21.2.5), and as noted in 21.2.3 and 21.2.4.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-12 19:04:38 -07:00
Rosen Penev 69a51e12c9
replace signal.h with csignal.h
The former was deprecated with C++14. The standard says they are the same:

The contents of the header<csignal>are the same as the C standard library
header<signal.h>.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-12 18:56:51 -07:00
Rosen Penev edc4989d9c
change errno.h to cerrno
The former is deprecated by C++14. It's also functionally the same.

From the standard:

19.4
The header<cerrno>is described in Table 43. Its contents are the same as
the POSIX header<errno.h>,except that errno shall be defined as a macro.
[Note: The intent is to remain in close alignment with the POSIX
standard.] A separate errno value shall be provided for each thread.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-12 15:51:16 -07:00
Rosen Penev ab9f5d2067
replace assert.h with cassert
The former was deprecated with C++14.

According to the C++11 and C++17 standards, both files are identical.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-12 15:25:38 -07:00
Rosen Penev f00f8b002a
[clang-tidy] use nodiscard
Introduced in C++17. It replaces gcc's warn_unused_result.

Found with modernize-use-nodiscard.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-03-12 12:59:16 -07:00
Rosen Penev afb29942b0
[clang-tidy] simplify boolean expressions
Found with readability-simplify-boolean-expr

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-02-01 19:47:47 -08:00
Max Kellermann bc6eca2115 *: add `explicit` 2020-02-01 14:02:43 +01:00
Rosen Penev b64fdae938
[clang-tidy] use override instead of virtual
Found with modernize-use-override

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-01-31 21:27:26 -08:00
Max Kellermann 7551867249 meson.build: move Log.cxx and LogBackend.cxx into a static library
Prevents compiling those sources many times, once for each debug
program using it.
2020-01-18 19:56:16 +01:00
Max Kellermann 2817bf9e95 copyright year 2020 2020-01-18 19:23:49 +01:00
Max Kellermann 803a48e96d release v0.21.18
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCgAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAl4CKwwQHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEp46D/9q1pRkhYzCyZPQGX967UPoV+Bc1YMX4o2U
 Uh/HqQrKKRAK9goaxu9yMKBIFCbzj6WEZou+/uMEf6ZwXuRcnJMobrUU4+G9Yu3r
 FzlQPW870DyOhk2PWHF8CW3oMt/YH05b6nYNo2ocRnX69/oqL1G7ukbF2Pz3TPc0
 0uNQYYERdMawNCEi1OarzziR6DKuiN+MtZRgUQVacAsoUirwWGNJuaGSDtc3MMM7
 YhgKVmd9XsgVr7fykArj6PLsm2iyXJP5nDB/tIqmwMpQFyhuLUnGOMfhCq02em+r
 47LGvmZiSS/9F2JzPU8EL2yzYdBe4QvU6Ol5SfXbom11MZc3Ty502g2jUXVHjCeo
 1FljCPHbarTmKhvUc0xQXA9i6exZ0wwtxL+Zv7ZQKquRPAhq8E07qkQpdaTWa6vn
 3RfilLE1B/GCgoT6D1+zABxdJ1HRLT7tzFob2kkCccxguK3j2JjCUIkSgM6IY0yv
 a6sMEXbqa+Lh8jggs9ksoT6O+T2HHEr3tEfpFHY+t0NFRfwHd9aX9bNjK+Ji0n51
 YBf2FCb2EBrMAWNZmEnq+TuKX0HASDtoAXTviRKqBXtEG5V8MdAt4PPICCb+bkDr
 psIuYcGeK3vofvq1SwEC7h7gCvsBK5w17/oE2/jYcZLo12H1IdHe5gMP3OUhjel5
 BRi6rLlkYw==
 =XXXs
 -----END PGP SIGNATURE-----

Merge tag 'v0.21.18'

release v0.21.18
2019-12-24 16:31:06 +01:00
Max Kellermann f1116c9258 event/Loop: remove bogus assertion
Can fail if somebody calls Break().
2019-12-23 14:20:09 +01:00
Max Kellermann 9a577f8060 event/MultiSocketMonitor: add workaround for /dev/null
The ALSA "null" driver opens /dev/null and returns the file handle
from snd_pcm_poll_descriptors(), but /dev/null cannot be used with
epoll, the epoll_ctl() system call returns -EPERM.  This means that
the ALSA output hangs, eventually freezing the whole MPD process.

This commit adds a workaround to the MultiSocketMonitor class which is
used by the ALSA output plugin.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/695
2019-12-22 12:08:44 +01:00
Max Kellermann d75a0d714e event/MultiSocketMonitor: remove unnecessary `friend` declaration 2019-12-22 12:08:44 +01:00
Max Kellermann 9be3a1554e event/MultiSocketMonitor: remove duplicate IdleMonitor::Schedule() call
SetReady() does this already.
2019-12-22 12:08:10 +01:00
Max Kellermann 7764719513 event/MultiSocketMonitor: un-inline AddSocket() 2019-12-22 12:00:12 +01:00
Max Kellermann dcbb9fe07c event/Loop: round timeout up to avoid unnecessary wakeups 2019-12-22 11:58:31 +01:00
Max Kellermann e3b347820a event/MultiSocketMonitor: use std::exchange() 2019-12-20 13:42:35 +01:00
Max Kellermann a84bf5a92e event/MultiSocketMonitor: AddSocket() returns bool 2019-12-18 17:50:21 +01:00
Max Kellermann 732bdc800d event/SocketMonitor: Schedule() returns bool 2019-12-18 17:46:33 +01:00
Max Kellermann 8f981845dc switch to C++17
Time to move on, two years after 2017.
2019-08-03 12:57:56 +02:00
Max Kellermann d663f81420 include cleanups (powered by iwyu) 2019-07-05 09:59:58 +02:00
Max Kellermann a139279575 Copyright year 2019 2019-06-17 11:17:30 +02:00
Max Kellermann 620a39afb4 thread/Slack: use std::chrono::duration 2019-05-29 21:11:32 +02:00
Max Kellermann 9d1906da8a {event,output}/Thread: downgrade realtime scheduling errors to "info"
These messages can be confusing, but they are not critical.
2019-05-23 14:24:27 +02:00
Max Kellermann 973c87b351 event/Call, ...: use wait() with predicate 2019-05-07 20:01:45 +02:00
Max Kellermann 92022658f9 thread/Cond: add wait() overload which takes a unique_lock<>
Just like std::condition_variable, which however has no way to specify
the std::mutex directly.
2019-04-26 11:51:45 +02:00
Max Kellermann b51bae5500 thread/*Cond: rename methods to match std::condition_variable 2019-04-25 19:46:43 +02:00
Max Kellermann 5bc8cd0ecb event/Call: use std::lock_guard 2019-04-25 19:45:52 +02:00
Max Kellermann 0e48747607 event/Call: use std::lock_guard 2019-04-25 18:57:58 +02:00
Max Kellermann 093bf5d859 event/*, ...: make GetEventLoop() const 2019-04-04 20:07:57 +02:00
Max Kellermann 43677d5740 event/MaskMonitor: add `noexcept` 2019-04-04 19:54:17 +02:00
Max Kellermann ea5e6d8f33 Merge branch 'v0.21.x' 2019-04-04 10:29:58 +02:00
Max Kellermann f6941f9a44 event/SocketMonitor: don't cancel if OnSocketReady() returns false
Expect OnSocketReady() to cancel events.  If it returns false, the
SocketMonitor may be destructed already.  This fixes a use-after-free
bug in the "httpd" output plugin.
2019-04-04 10:24:58 +02:00
Max Kellermann d2eb4df8fc event/{Fully,}BufferedSocket: add more API documentation 2019-04-04 10:24:58 +02:00
Max Kellermann c340485dd5 client: make GetEventLoop() public 2019-04-03 14:32:28 +02:00
Max Kellermann a854595886 event/ServerSocket: runtime error if abstract sockets are unavailable 2019-03-20 13:09:16 +01:00
Max Kellermann 8fc3c5c612 event/ServerSocket: add HAVE_UN check to AddAbstract()
Closes https://github.com/MusicPlayerDaemon/MPD/issues/510
2019-03-20 13:06:09 +01:00
Max Kellermann 4f408bd952 event/ServerSocket, doc, ...: refer to AF_LOCAL as "local socket"
.. and not "UNIX domain socket.  Be consistent about the naming.
2019-03-20 12:57:26 +01:00
Max Kellermann 44422b2b2f event/ServerSocket, config/Net: abstract socket support 2019-02-25 13:08:33 +01:00
Max Kellermann 6c67408944 event/Loop: add flag `alive`
This replaces the old `dead` flag which was unreliable; it was `false`
if the EventThread was not yet started, which could cause deadlocks in
BlockingCall().
2019-02-05 22:38:45 +01:00
Jacob Vosmaer 66f5b0fed7 Add boost_dep in subdir meson.build files 2018-12-09 17:20:47 +01:00
Max Kellermann ce49d99c2f check.h: remove obsolete header
Since we switched from autotools to Meson in commit
94592c1406, we don't need to include
`config.h` early to properly enable large file support.  Meson passes
the required macros on the compiler command line instead of defining
them in `config.h`.

This means we can include `config.h` at any time, whenever we want to
check its macros, and there are no ordering constraints.
2018-11-19 16:33:49 +01:00
Max Kellermann a8bf8ede01 event/Thread: reduce the RTIO timer slack to 10us
MPD's default is 100ms, which is too long for the real-time I/O
thread.  The OutputThread has 100us, but the real-time I/O thread
might have tighter deadlines.

This change has currently no effect (I believe), because nobody uses
timers on the RTIO thread.
2018-11-14 12:11:57 +01:00
Max Kellermann ba5c856f15 events/MultiSocketMonitor: add method ForEachResult() 2018-11-11 12:37:28 +01:00
Max Kellermann f5c9071494 *: copyright year 2018 2018-10-31 17:54:59 +01:00
Max Kellermann 64da9399ca event/ServerSocket: allow mixing AddFD() with other Add*() methods 2018-10-30 22:14:53 +01:00
Max Kellermann a943f4063c event/ServerSocket: add AddFD() overload with AllocatedSocketAddress&& 2018-10-30 20:44:56 +01:00
Max Kellermann ce9f09c69a event/ServerSocket: make AddAddress() a template 2018-10-30 20:43:52 +01:00
Max Kellermann 3ddc7a5353 event/ServerSocket: include cleanup 2018-10-30 20:19:07 +01:00
Max Kellermann e575392b94 event/ServerSocket: use class IPv6Address 2018-10-30 20:19:04 +01:00
Max Kellermann c6f61a699c event/ServerSocket: make OneServerSocket an inner class 2018-10-30 20:16:26 +01:00
Max Kellermann 0307b49f43 event/ServerSocket: make OnAccept() noexcept 2018-10-30 20:13:07 +01:00
Max Kellermann 413ab80295 event/ServerSocket: use C++11 initializer 2018-10-30 20:11:58 +01:00
Max Kellermann daffefdb10 event/ServerSocket: pass UniqueSocketDescriptor to AddFD() 2018-10-30 20:05:57 +01:00
Max Kellermann 5fb21fbdb1 event/ServerSocket: add `noexcept` 2018-10-30 19:57:39 +01:00
Max Kellermann 94592c1406 build with Meson instead of autotools
So long, autotools!  This is my last MPD related project to migrate
away from it.  It has its strengths, but also very obvious weaknesses
and weirdnesses.  Today, many of its quirks are not needed anymore,
and are cumbersome and slow.  Now welcome our new Meson overlords!
2018-10-14 23:41:38 +02:00
Max Kellermann dd461400fb system/EPollFD: rename to EpollFD 2018-08-22 15:40:45 +02:00
Max Kellermann 4a1e885c0a net/Resolver: replace with more advanced implementation
The new implementation is copied from another project and is
BSD-licensed.  It is exception-safe and can parse IPv6 scope ids with
interface names.
2018-08-21 08:26:12 +02:00
Max Kellermann ec54754e22 Compiler.h: move to util/ 2018-08-20 16:19:17 +02:00
1848 4797357fa9 fixed setting unix socket permissions
first call fchmod() to prevent TOCTTOU, then apply permissions using
chmod()
2018-08-14 22:53:19 +02:00
Max Kellermann c1b33533da event/ServerSocket: fix get_remote_uid() call
This call was broken since commit
9a5bcc6db0 because the
`UniqueSocketDescriptor` had already been moved.
2018-08-09 13:22:25 +02:00
1848 737267cedc Moved call to fchmod() on socket from OneServerSocket::Open() to socket_bind_listen() 2018-08-07 22:01:13 +02:00
1848 84054203af Use fchmod instead of chmod for unix sockets to prevent TOCTTOU 2018-08-07 21:30:25 +02:00
Max Kellermann 7df0d3b7fc event/SignalMonitor: make SignalMonitorFinish() noexcept 2018-08-06 12:01:46 +02:00
Max Kellermann fdd101c4c5 event/SignalMonitor: add `noexcept` 2018-08-06 12:00:49 +02:00
Max Kellermann dd18fe34a7 system/SignalFD: throw exception on error 2018-08-06 11:58:29 +02:00
Max Kellermann 0c1a001622 system/Event{FD,Pipe}: throw exception on error 2018-08-06 11:49:38 +02:00
Max Kellermann 56bfff5a57 event/ServerSocket: add method IsEmpty() 2018-07-15 21:35:35 +02:00
Max Kellermann d29d186d62 output/alsa: use a new I/O thread with real-time scheduling
The normal I/O event thread can have a large latency, e.g. when
libgnutls loads all TLS CA certificates for a https connect.  This
makes it unreliable for the ALSA I/O notifications, and causes ring
buffer xruns.  To avoid interfering with high latency events such as
CURL's, we move the ALSA I/O events to a separate I/O thread which
also obtains real-time scheduling (if possible).

Closes #221
2018-02-16 22:38:55 +01:00
Max Kellermann 19af364400 event/Thread: add "noexcept" 2018-01-29 23:11:15 +01:00
Max Kellermann 3fd9a86f3c event/Call: invoke function directly if the EventLoop is dead
Works around a deadlock bug which happens when waiting for an
EventLoop which isn't running anymore.
2018-01-29 23:06:43 +01:00
Max Kellermann ce68701c0c event/Loop: add flag "dead" 2018-01-29 22:52:13 +01:00
Max Kellermann 6ea2cb3644 event/Thread: remove unused method StopAsync() 2018-01-29 22:50:21 +01:00
Max Kellermann 199c8aaa25 event/Loop: move code to HandleTimers() 2018-01-29 22:40:12 +01:00
Max Kellermann 3890bc5a96 event/Loop: add "noexcept" 2018-01-29 22:05:58 +01:00
Max Kellermann 2c65f986d6 event/EPoll: use C++11 initializer 2018-01-29 22:05:13 +01:00
Max Kellermann ea402b765c event/WinSelect: pass const reference to copy constructor 2018-01-29 22:05:13 +01:00
Max Kellermann 497e0669ff event/PollResult: use size_t for size and index 2018-01-29 21:56:12 +01:00
Max Kellermann bbc5212436 fs/AllocatedPath: make the nullptr_t constructor public 2018-01-17 12:17:41 +01:00
Max Kellermann f8bb66b4e0 event/Loop: use std::atomic_bool for the "quit" variable
Fixes thread sanitizer warnings.
2017-12-22 11:04:24 +01:00
Max Kellermann 36899dba0b event/Call: document exceptions 2017-12-20 10:50:36 +01:00
Max Kellermann 6a31446671 event/TimerEvent: add "noexcept" 2017-12-20 10:45:30 +01:00
Max Kellermann 451fbbcea1 event/FullyBufferedSocket: add "noexcept" 2017-12-20 10:44:47 +01:00
Max Kellermann a17a481e30 event/BufferedSocket: add "noexcept" 2017-12-20 10:42:17 +01:00
Max Kellermann 914df18bf9 Main, ...: catch any exception, not just std::runtime_error 2017-12-19 10:56:23 +01:00
Max Kellermann 6246d36fe6 Merge branch 'v0.20.x' 2017-12-16 20:56:06 +01:00
Max Kellermann dfaf08743c *: check defined(_WIN32) instead of defined(WIN32)
Only _WIN32 is defined by the compiler, and WIN32 is not standardized
and may be missing.

Closes #169
2017-12-12 10:22:20 +01:00
Max Kellermann c582a9faae event/MultiSocketMonitor: add "noexcept" 2017-11-12 17:42:50 +01:00
Max Kellermann cf483107c9 event/IdleMonitor: add "noexcept" 2017-11-12 17:40:25 +01:00
Max Kellermann b57e2f5521 event/DeferredMonitor: eliminate obsolete class
Move its code to DeferEvent instead.
2017-11-12 17:34:06 +01:00
Max Kellermann bf3ced6a34 event/Call: migrate from DeferredMonitor to DeferEvent 2017-11-12 17:32:23 +01:00
Max Kellermann 42ad753e39 event/MaskMonitor: migrate from DeferredMonitor to DeferEvent 2017-11-10 21:10:46 +01:00
Max Kellermann 593d82c6a9 event/DeferEvent: add "noexcept" 2017-11-10 20:55:24 +01:00
Max Kellermann 43dccbd45d event/SocketMonitor: remove unused method Abandon() 2017-11-10 20:52:37 +01:00
Max Kellermann 0ff4350352 event/ServerSocket: pass UniqueSocketDescriptor by value
Passing it by value is actually smaller (32 bit) than the rvalue
reference (64 bit pointer), and it ensures that the object is consumed
after the call returns, no matter how the methods are implemented.
2017-11-10 20:43:14 +01:00
Max Kellermann 5fd2b7cc79 event/SocketMonitor: eliminate Read(), Write()
Migrate callers to GetSocket().Read(), GetSocket.Write(), which is the
same.
2017-11-10 20:37:52 +01:00
Max Kellermann 7e16ac305d event/SocketMonitor: rename Get() to GetSocket() 2017-11-10 20:34:45 +01:00
Max Kellermann 59a8836924 event/SocketMonitor: add "noexcept" 2017-11-10 20:20:07 +01:00
Max Kellermann 9d4020501c event/SocketMonitor: make constructor "explicit" 2017-11-10 20:17:27 +01:00
Max Kellermann 81350d65bc event/SocketMonitor: use C++11 initializers 2017-11-10 20:16:26 +01:00
Max Kellermann 3c41e9f022 evnet/SocketMonitor: move WIN32/ERROR comment to PollGroupWinSelect.hxx 2017-11-10 19:57:54 +01:00
Max Kellermann 49784513b1 util/{Const,Writable}Buffer, ...: rename IsEmpty() to empty(), imitating STL 2017-11-10 19:24:33 +01:00
Max Kellermann 9df4853e23 event/DeferredCall: rename to DeferEvent 2017-09-21 22:40:25 +02:00
Max Kellermann 987c505906 event/TimeoutMonitor: remove obsolete class 2017-08-29 16:53:15 +02:00
Max Kellermann 7ae57a3531 event/MultiSocketMonitor: migrate from TimeoutMonitor to TimerEvent 2017-08-29 16:28:27 +02:00
Max Kellermann 30a5dd267b event/TimeoutMonitor: move code to new class TimerEvent 2017-08-29 16:28:27 +02:00
Max Kellermann 2f0d683378 event/Loop: fix inverted checkin RemoveDeferred() 2017-08-29 16:28:24 +02:00
Max Kellermann a1309a90ac event/Loop: use boost::intrusive::list to store IdleMonitors and DeferredMonitors
The intrusive contains can easily erase items without searching
through the whole list.  This removes a good amount of runtime
overhead.
2017-08-29 15:43:16 +02:00
Max Kellermann 010855a294 event/Loop: use boost::intrusive::multiset to store TimeoutMonitors
By using an "intrusive" data structure, we can easily eliminate
struct TimerRecord.
2017-08-29 14:42:59 +02:00
Max Kellermann 71ed3ff992 event/Loop: move TimerRecord::due to class TimeoutMonitor
Prepare to eliminate the TimerRecord struct.
2017-08-29 14:13:09 +02:00
Max Kellermann d4266d0063 event/Loop: remove unused method TimerRecord::IsDue() 2017-08-29 13:41:11 +02:00
Max Kellermann 5ac72211cd event/Loop: set thread to current thread by default
Allows eliminating lots of complexity and workarounds for bogus
assertion failures.
2017-08-18 18:18:55 +02:00
Max Kellermann 7f9a2f8adb event/Loop: schedule and cancel the WakeFD in Run()
This is only needed while Run() is alive, and moving it there avoids
problems with thread-checking assertions.
2017-08-18 18:08:06 +02:00
Max Kellermann 6d43e70a93 event/SignalMonitor: throw exception instead of raising fatal error 2017-08-11 09:36:22 +02:00
Max Kellermann 33b4114534 system/fd_util: remove unused library 2017-08-11 09:20:15 +02:00
Max Kellermann d705a92e43 net/IPv4Address: new class 2017-08-11 09:09:04 +02:00
Max Kellermann 1f47dc990d net/SocketDescriptor: add method SetKeepAlive() 2017-08-10 19:25:02 +02:00
Max Kellermann 9a5bcc6db0 net/ServerSocket: pass UniqueSocketDescriptor&& to OnAccept() 2017-08-10 19:20:14 +02:00
Max Kellermann 492b20a89d event/SocketMonitor: use class SocketDescriptor 2017-08-10 19:19:58 +02:00
Max Kellermann da90f484aa net/SocketUtil: socket_bind_listen() returns UniqueSocketDescriptor 2017-08-10 13:12:13 +02:00
Max Kellermann 979f1b6c39 release v0.20.9
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCAAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAlkz5jkQHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEubuD/kBXMcV4XawqGNNtSHdrY8CxSL8wJMCMJQl
 aMgRkKLPRml8Hj9FNNG9pjXBuT+qUgPX7t9gBEiT7c+sV3fHH40gUf1js5GIsEPm
 BAVfvww5EhmQWWVhPTLk1iZ4jp6E96mDmIG1znwo7etSZHXU8RJfR7woBi3SPJ9f
 OPcrimskNuWpAWeaEIKi/1Iwzy8d9VK9Ttb73gA3M5zSm7ioXzt3YClpwLRM8JU6
 QeUJchy6VwXnygswjUNmbhPc3GsD2FyUZ4OtJ0hodnqqajfldBxhcHUnQk4zZULr
 1nLSyOuA9bwLuFohH1T6HiY9z8PFzgqdIHvsjOJgZ4gQa69PVNjal2tUEUav9zFv
 aK4LvTVPnIk+hqRbtLpV7/rPKuClrC9BO4oYdBGBDNY4hqVpvRA9obP1s00aOi+K
 UhYqLqg7yeIEeTlUxFOhXJCKAEL69BuXT5ihJtDlB/dCUzv37sEch/4WDgs7uc+O
 9kJYlElvozw57mbczsee/PCSnSWrLCq/qG/bNEUUQOTueWNuifh3PL62UXGgfbEH
 01hJDyLr6ETSmWn7rjTfLJiHThX/EQQvOhs+35fbCyry65z4tFwrilGDmFVUWGPq
 /6QEpY1D6q4fkoma/iWOZoTkfKewatAPGMGWoJaGhCnfQFz4VTFtS2bDtuUctQ16
 jnXnPFxqBw==
 =0SSp
 -----END PGP SIGNATURE-----

Merge tag 'v0.20.9'

release v0.20.9
2017-06-04 12:57:05 +02:00
Max Kellermann a057b4f6d8 *: add lost of "noexcept" specifications 2017-06-04 12:46:48 +02:00
Max Kellermann 4faef28cc5 release v0.20.7
-----BEGIN PGP SIGNATURE-----
 
 iQJEBAABCAAuFiEEA5IzWngIOJSkMBxDI26KWMbbRRIFAlkaFL0QHG1heEBtdXNp
 Y3BkLm9yZwAKCRAjbopYxttFEr4ID/9iAQC+7fFv06uLOm48Ufu+PgoD8uJkAwF5
 QuLQkc85g9urn+bu9N7Qs7Vypp7aLyGcJKY0jyA8wxkOj24pUC3GYk80daUt561V
 5s20FnoS/Uoman3CSJL94IfCUBxejizE6vgIIHTc5bb6U0qIsPub/8JTTE2Ih7uP
 nvFZ5uBQ+YTc7at+iIH9123eUMKkitkh8osNblovqQT9v42++Tm4ztAytRHBjwUA
 Itew5HhlvahbLKqFs/7vmICh/YX1FcOV7cV+erEWYfkH0KCI2bhSle4u2d0CBOvD
 VJlDnBCo9bM7WKcPYqJiFFFXA0CRk06wbkkkAtwF4zjp8xos7aQcq4FyQnYL8KXo
 5lijIhRwBURBd+nt8oA9kuEhBt/T75otcemJkzVaYappHTJCLjhxSGcPt8mw+nE9
 9WQzsp/MIVzg9l5g3D9S/43xM7uhvn98Tn1Qf2s8YRd2o8CZeOhW+X3RvbCvVPv2
 mOlx4sFAv8DOJ3KxMdqiJT+PmylPyJluQdqH+tMc8BdPg/kpSpYIPTuSjjRqK1yh
 ld5do0HtAAwiHtvXfk5YVFjJSpO0c8yVn6xci2Cl4k/5ZHj2UE1ln+N5vCea2BRF
 2J3HAjROwtcwY3lU1jFnEAogf24KWiFJqhhC0EqBGUdlrM8Dn37P5cEWWjROIMNK
 lPEdovokNw==
 =CdDy
 -----END PGP SIGNATURE-----

Merge tag 'v0.20.7'

release v0.20.7
2017-05-15 23:01:49 +02:00
Max Kellermann 71f0ed8b74 *: add "noexcept" to many, many function prototypes
This eliminates some overhead, because the compiler doesn't need to
consider these functions throwing.
2017-05-08 14:44:49 +02:00
Max Kellermann 781487c4dd thread/Thread: use BoundMethod 2017-02-10 22:46:09 +01:00
Max Kellermann 9324fbf921 event/Thread: remove the Mutex
We don't need to access Thread::handle early inside the EventThread,
so we don't need this trick anymore.
2017-02-10 22:29:31 +01:00
Max Kellermann 115af4f565 event/Loop: Break() is no-op if "quit" is already set 2017-02-10 22:24:48 +01:00
Max Kellermann 822724d1aa event/Thread: auto-stop in the destructor 2017-02-10 22:24:46 +01:00
Max Kellermann de80c270bd IOThread: move code to class EventThread 2017-02-10 21:40:39 +01:00
Max Kellermann 14986b153a event/Loop: use std::lock_guard 2017-02-09 21:26:55 +01:00
Max Kellermann 7372c931b3 event/Loop: make IsInsideOrNull() available in the NDEBUG build
Fixes build breakage by commit 4e5271fcdf7; and this method does make
sense in non-debug builds.
2017-02-09 21:21:49 +01:00
Max Kellermann eda06993f8 event/MultiSocketMonitor: add method Reset() 2017-02-09 21:12:23 +01:00
Max Kellermann 4b30ef1cf2 event/MultiSocketMonitor: use C++11 initializer 2017-02-09 21:12:23 +01:00
Max Kellermann e92e5e8eb8 event/MultiSocketMonitor: more API documentation
Now ClearSocketList() may only be called from PrepareSockets().
Calling it before destroying the object doesn't work properly, because
it doesn't unregister the TimeoutMonitor and the IdleMonitor.  Some of
its callers need to be fixed.
2017-02-09 21:12:23 +01:00
Max Kellermann 4e5271fcdf event/Call: allow usage during shutdown
Change EventLoop::IsInside() call to EventLoop::IsInsideOrNull().
This means that BlockingCall() may be used during shutdown, after the
main EventLoop::Run() has finished.  This is important because mixers
are currently registered in the main EventLoop.
2017-02-09 21:12:23 +01:00