mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
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
This commit is contained in:
@@ -51,6 +51,9 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/fs.h>
|
#include <nuttx/fs.h>
|
||||||
|
#if CONFIG_DEBUG
|
||||||
|
# include <nuttx/arch.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "pipe_common.h"
|
#include "pipe_common.h"
|
||||||
|
|
||||||
@@ -417,6 +420,20 @@ ssize_t pipecommon_write(FAR struct file *filep, FAR const char *buffer, size_t
|
|||||||
}
|
}
|
||||||
#endif
|
#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 */
|
/* Make sure that we have exclusive access to the device structure */
|
||||||
|
|
||||||
if (sem_wait(&dev->d_bfsem) < 0)
|
if (sem_wait(&dev->d_bfsem) < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user