aboutsummaryrefslogtreecommitdiffhomepage
path: root/midimonster.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2020-04-19 20:40:42 +0200
committercbdev <cb@cbcdn.com>2020-04-19 20:40:42 +0200
commit79b7e7dae5814942c04ca33e94e92b89547ffeb2 (patch)
tree0b1ca9a30b95d43604c81e7bde78786c33f8c186 /midimonster.c
parent7c1a283c9213dd273d04af72e24b08beb83aec12 (diff)
parent462b409d3d1fa16fcab0c7f8b475bb8d8e8b3e90 (diff)
downloadmidimonster-79b7e7dae5814942c04ca33e94e92b89547ffeb2.tar.gz
midimonster-79b7e7dae5814942c04ca33e94e92b89547ffeb2.tar.bz2
midimonster-79b7e7dae5814942c04ca33e94e92b89547ffeb2.zip
Merge current master to rtpmidirtpmidi
Diffstat (limited to 'midimonster.c')
-rw-r--r--midimonster.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/midimonster.c b/midimonster.c
index 5109eab..8100607 100644
--- a/midimonster.c
+++ b/midimonster.c
@@ -10,6 +10,7 @@
#define MM_API __attribute__((dllexport))
#endif
#define BACKEND_NAME "core"
+#define MM_SWAP_LIMIT 20
#include "midimonster.h"
#include "config.h"
#include "backend.h"
@@ -339,7 +340,7 @@ static int args_parse(int argc, char** argv, char** cfg_file){
static int core_process(size_t nfds, managed_fd* signaled_fds){
event_collection* secondary = NULL;
- size_t u;
+ size_t u, swaps = 0;
//run backend processing, collect events
DBGPF("%lu backend FDs signaled\n", nfds);
@@ -347,7 +348,8 @@ static int core_process(size_t nfds, managed_fd* signaled_fds){
return 1;
}
- while(routing.events->n){
+ //limit number of collector swaps per iteration to prevent complete deadlock
+ while(routing.events->n && swaps < MM_SWAP_LIMIT){
//swap primary and secondary event collectors
DBGPF("Swapping event collectors, %lu events in primary\n", routing.events->n);
for(u = 0; u < sizeof(routing.pool) / sizeof(routing.pool[0]); u++){
@@ -368,6 +370,10 @@ static int core_process(size_t nfds, managed_fd* signaled_fds){
secondary->n = 0;
}
+ if(swaps == MM_SWAP_LIMIT){
+ LOG("Iteration swap limit hit, a backend may be configured to route events in an infinite loop");
+ }
+
return 0;
}