aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2013-09-25 11:53:59 +0200
committerLukas Larsson <[email protected]>2014-02-24 15:15:57 +0100
commite6c7086e6befb3eb9e8ad4fb7de62f1ee810508c (patch)
tree16c710da5e6c0684d07cb490de0dea7ad481acea /erts
parenteed38c1bb1a12015377d30e9ceff9525e050850e (diff)
downloadotp-e6c7086e6befb3eb9e8ad4fb7de62f1ee810508c.tar.gz
otp-e6c7086e6befb3eb9e8ad4fb7de62f1ee810508c.tar.bz2
otp-e6c7086e6befb3eb9e8ad4fb7de62f1ee810508c.zip
ose: Debug wait__ does receive_fsem instead of wait_fsem
This is done in order to catch rogue signals
Diffstat (limited to 'erts')
-rw-r--r--erts/include/internal/ose/ethr_event.h13
-rw-r--r--erts/lib_src/ose/ethr_event.c26
2 files changed, 36 insertions, 3 deletions
diff --git a/erts/include/internal/ose/ethr_event.h b/erts/include/internal/ose/ethr_event.h
index 86811a87db..000a600813 100644
--- a/erts/include/internal/ose/ethr_event.h
+++ b/erts/include/internal/ose/ethr_event.h
@@ -78,8 +78,17 @@ ETHR_INLINE_FUNC_NAME_(ethr_event_set)(ethr_event *e)
{
ethr_sint32_t val = ethr_atomic32_xchg_mb(&e->state, ETHR_EVENT_ON__);
if (val == ETHR_EVENT_OFF_WAITER__) {
- ETHR_ASSERT(get_fsem(e->proc) == -1);
- signal_fsem(e->proc);
+#ifdef DEBUG
+ OSFSEMVAL fsem_val = get_fsem(e->proc);
+
+ /* There is a race in this assert.
+ This is because the state is set before the wait call in wait__.
+ We hope that a delay of 10 ms is enough */
+ if (fsem_val == 0)
+ delay(10);
+ ETHR_ASSERT(get_fsem(e->proc) == -1);
+#endif
+ signal_fsem(e->proc);
}
}
diff --git a/erts/lib_src/ose/ethr_event.c b/erts/lib_src/ose/ethr_event.c
index 1cb3c223ab..5905fe22a9 100644
--- a/erts/lib_src/ose/ethr_event.c
+++ b/erts/lib_src/ose/ethr_event.c
@@ -127,6 +127,12 @@ wait__(ethr_event *e, int spincount)
#else
/* --- OSE implementation of events ---------------------------- */
+#ifdef DEBUG
+union SIGNAL {
+ SIGSELECT signo;
+};
+#endif
+
int
ethr_event_init(ethr_event *e)
{
@@ -180,8 +186,26 @@ wait__(ethr_event *e, int spincount)
ETHR_ASSERT(val == ETHR_EVENT_OFF__);
}
-
+#if defined(DEBUG)
+ while (1) {
+ /* In debug we also receive any signals to make sure that we do
+ not get any! redir tables should send all to scheduler_1 */
+ SIGSELECT sigsel[] = {0};
+ union SIGNAL *sig = receive_fsem(OSE_NO_TIMEOUT,sigsel,1);
+ //ETHR_ASSERT(sig == OS_RCV_FSEM);
+ if (sig != OS_RCV_FSEM) {
+ int i;
+ printf("0x%x: Got signal in wait: %u ",current_process(),sig->signo);
+ for (i = 0; i < (sigsize(&sig) / sizeof(SIGSELECT)) && i < 5; i++) {
+ printf("%x ",sig[i+1]);
+ }
+ printf("\n");
+ } else
+ break;
+ }
+#else
wait_fsem(1);
+#endif
ETHR_ASSERT(get_fsem(current_process()) == 0);
}
}