summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorGreg Kaiser <gkaiser@google.com>2016-10-12 21:42:09 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-10-12 21:42:09 +0000
commit589faf3358a9dff188b158b68c1f8e85b21c976f (patch)
tree86dcbb8d1047a18d502db5b18c512f13291de1b2 /inc
parentbfc225a68a00cce964df4927aa381556d6609e28 (diff)
parent7eaa88b5beb8c465c82b294af5cd92952ac488cf (diff)
downloadcontexthub-589faf3358a9dff188b158b68c1f8e85b21c976f.tar.gz
CHRE API: Allow exception to non-reentrant rule am: 964a25f657 am: 98882b7067
am: 7eaa88b5be Change-Id: I2a660b1158bceff3966f3835b38f110e15ce3d7d
Diffstat (limited to 'inc')
-rw-r--r--inc/chre.h12
-rw-r--r--inc/chre/event.h9
2 files changed, 15 insertions, 6 deletions
diff --git a/inc/chre.h b/inc/chre.h
index 55fed265..2587e3d5 100644
--- a/inc/chre.h
+++ b/inc/chre.h
@@ -73,9 +73,15 @@
* callback, the CHRE is not allowed to call nanoappHandleEvent(), or invoke
* another memory freeing callback.
*
- * For a nanoapp author, this means no thought needs to be given to
- * synchronization issues with global objects, as they will, by definition,
- * only be accessed by a single thread at once.
+ * There is one exception to this rule: If an invocation of chreSendEvent()
+ * or chreSendMessageToHost() fails (returns 'false'), it is allowed to
+ * immediately invoke the memory freeing callback passed into that function.
+ * This is a rare case, and one where otherwise a CHRE implementation is
+ * likely to leak memory.
+ *
+ * For a nanoapp author, this means no thought (outside of our one exception)
+ * needs to be given to synchronization issues with global objects, as they
+ * will, by definition, only be accessed by a single thread at once.
*
*
* [1] Note to CHRE implementors: A future version of the CHRE platform may
diff --git a/inc/chre/event.h b/inc/chre/event.h
index 465c40ac..c1c95108 100644
--- a/inc/chre/event.h
+++ b/inc/chre/event.h
@@ -202,7 +202,9 @@ typedef void (chreMessageFreeFunction)(void *message, size_t messageSize);
* to. Note that this is allowed to be our own instance.
* @returns true if the event was enqueued, false otherwise. Note that even
* if this method returns 'false', the 'freeCallback' will be invoked,
- * if non-NULL.
+ * if non-NULL. Note in the 'false' case, the 'freeCallback' may be
+ * invoked directly from within chreSendEvent(), so it's necessary
+ * for nanoapp authors to avoid possible recursion with this.
*
* @see chreEventDataFreeFunction
*/
@@ -252,8 +254,9 @@ bool chreSendEvent(uint16_t eventType, void *eventData,
* to be NULL, in which case no callback will be invoked.
* @returns true if the message was accepted for transmission, false otherwise.
* Note that even if this method returns 'false', the 'freeCallback' will
- * be invoked, if non-NULL.
- *
+ * be invoked, if non-NULL. Note in the 'false' case, the 'freeCallback'
+ * may be invoked directly from within chreSendMessageToHost(), so it's
+ * necessary for nanoapp authors to avoid possible recursion with this.
*
* @see chreMessageFreeFunction
*/