summaryrefslogtreecommitdiff
path: root/nuttx/drivers
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-09-13 22:32:01 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-09-13 22:32:01 +0000
commit1e6e9f738a8a002a245ccf3334f6529df35d5c18 (patch)
tree6dced6a964afe7328b70daea1c07a531e2d6a2e1 /nuttx/drivers
parent9120a27d14a927091da009248f51d146f93d040a (diff)
downloadpx4-nuttx-1e6e9f738a8a002a245ccf3334f6529df35d5c18.tar.gz
px4-nuttx-1e6e9f738a8a002a245ccf3334f6529df35d5c18.tar.bz2
px4-nuttx-1e6e9f738a8a002a245ccf3334f6529df35d5c18.zip
Add assert to prevent write() method from being by interrupt handlers
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2048 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers')
-rw-r--r--nuttx/drivers/pipe_common.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/nuttx/drivers/pipe_common.c b/nuttx/drivers/pipe_common.c
index 82a822374..174778d6d 100644
--- a/nuttx/drivers/pipe_common.c
+++ b/nuttx/drivers/pipe_common.c
@@ -51,6 +51,9 @@
#include <debug.h>
#include <nuttx/fs.h>
+#if CONFIG_DEBUG
+# include <nuttx/arch.h>
+#endif
#include "pipe_common.h"
@@ -417,6 +420,20 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t
}
#endif
+ /* At present, this method cannot be called from interrupt handlers. That is
+ * because it calls sem_wait (via pipecommon_semtake below) and sem_wait cannot
+ * be called from interrupt level. This actually happens fairly commonly
+ * IF dbg() is called from interrupt handlers and stdout is being redirected
+ * via a pipe. In that case, the debug output will try to go out the pipe
+ * (interrupt handlers should use the lldbg() APIs).
+ *
+ * On the other hand, it would be very valuable to be able to feed the pipe
+ * from an interrupt handler! TODO: Consider disabling interrupts instead
+ * of taking semaphores so that pipes can be written from interupt handlers
+ */
+
+ DEBUGASSERT(up_interrupt_context() == FALSE)
+
/* Make sure that we have exclusive access to the device structure */
if (sem_wait(&dev->d_bfsem) < 0)