You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2017/03/10 20:26:45 UTC
incubator-mynewt-core git commit: MYNEWT-666;
walk of observer list was ending too soon.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop e67144fc4 -> 2b3d6ccf7
MYNEWT-666; walk of observer list was ending too soon.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2b3d6ccf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2b3d6ccf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2b3d6ccf
Branch: refs/heads/develop
Commit: 2b3d6ccf79be225fbb652e15b93e7044047cf1f8
Parents: e67144f
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Mar 10 12:25:29 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 12:25:29 2017 -0800
----------------------------------------------------------------------
net/oic/src/messaging/coap/observe.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2b3d6ccf/net/oic/src/messaging/coap/observe.c
----------------------------------------------------------------------
diff --git a/net/oic/src/messaging/coap/observe.c b/net/oic/src/messaging/coap/observe.c
index ed88682..3d45e03 100644
--- a/net/oic/src/messaging/coap/observe.c
+++ b/net/oic/src/messaging/coap/observe.c
@@ -231,11 +231,13 @@ coap_notify_observers(oc_resource_t *resource,
coap_observer_t *obs = NULL;
/* iterate over observers */
- for (obs = SLIST_FIRST(&oc_observers);
- obs && ((resource && obs->resource == resource) ||
- (endpoint &&
- memcmp(&obs->endpoint, endpoint, sizeof(oc_endpoint_t)) == 0));
- obs = SLIST_NEXT(obs, next)) {
+ for (obs = SLIST_FIRST(&oc_observers); obs; obs = SLIST_NEXT(obs, next)) {
+ /* skip if neither resource nor endpoint match */
+ if (resource != obs->resource &&
+ 0 != memcmp(&obs->endpoint, endpoint, sizeof(oc_endpoint_t))) {
+ continue;
+ }
+
num_observers = obs->resource->num_observers;
#if MYNEWT_VAL(OC_SEPARATE_RESPONSES)
if (response.separate_response != NULL &&