summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2934e57)
- ObserverList should be removed before destroying ResourceList
to avoid the error of dangling pointer. because ResourceObserver
object includes a resource handle which is memory address allocated
when resource is created.
- Add function to unset network monitoring callback when OCStop()
is called.
bug: https://jira.iotivity.org/browse/IOT-1671
Change-Id: I8a367a24a2100c97bf612db26bc41db5f47f2feb
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15499
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
CAConnectionStateChangedCB connStateCB);
/**
CAConnectionStateChangedCB connStateCB);
/**
+ * Unregister network monitoring callback.
+ * @param[in] adapterStateCB Adapter state monitoring callback.
+ * @param[in] connStateCB Connection state monitoring callback.
+ *
+ * @return ::CA_STATUS_OK or ::CA_STATUS_FAILED or ::CA_MEMORY_ALLOC_FAILED
+ */
+CAResult_t CAUnregisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB);
+
+/**
* Set device to handle for auto connection.
* @param[in] address LE address to set.
*
* Set device to handle for auto connection.
* @param[in] address LE address to set.
*
CAConnectionStateChangedCB connCB);
/**
CAConnectionStateChangedCB connCB);
/**
+ * Unset the network status changed callback for CAUtil.
+ * @param[in] adapterCB CAUtil callback to receive adapter status changes.
+ * @param[in] connCB CAUtil callback to receive connection status changes.
+ * @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CAUnsetNetworkMonitorCallbacks(CAAdapterStateChangedCB adapterCB,
+ CAConnectionStateChangedCB connCB);
+
+/**
* Starting different connectivity adapters based on the network selection.
* @param[in] transportType interested network for starting.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
* Starting different connectivity adapters based on the network selection.
* @param[in] transportType interested network for starting.
* @return ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+CAResult_t CAUnsetNetworkMonitorCallbacks(CAAdapterStateChangedCB adapterCB,
+ CAConnectionStateChangedCB connCB)
+{
+ OIC_LOG(DEBUG, TAG, "Unset network monitoring callback");
+ CAResult_t res = RemoveNetworkStateChangedCallback(adapterCB, connCB);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG(ERROR, TAG, "RemoveNetworkStateChangedCallback has failed");
+ }
+ return res;
+}
+
void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback)
{
OIC_LOG(DEBUG, TAG, "Set error handle callback");
void CASetErrorHandleCallback(CAErrorHandleCallback errorCallback)
{
OIC_LOG(DEBUG, TAG, "Set error handle callback");
+CAResult_t CAUnregisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
+ CAConnectionStateChangedCB connStateCB)
+{
+ OIC_LOG(DEBUG, TAG, "CAUnregisterNetworkMonitorHandler");
+
+ return CAUnsetNetworkMonitorCallbacks(adapterStateCB, connStateCB);
+}
+
CAResult_t CASetAutoConnectionDeviceInfo(const char *address)
{
OIC_LOG(DEBUG, TAG, "CASetAutoConnectionDeviceInfo");
CAResult_t CASetAutoConnectionDeviceInfo(const char *address)
{
OIC_LOG(DEBUG, TAG, "CASetAutoConnectionDeviceInfo");
{
case OC_OBSERVER_NOT_INTERESTED:
OIC_LOG(DEBUG, TAG, "observer not interested in our notifications");
{
case OC_OBSERVER_NOT_INTERESTED:
OIC_LOG(DEBUG, TAG, "observer not interested in our notifications");
- observer = GetObserverUsingToken (token, tokenLength);
- if(observer)
+ observer = GetObserverUsingToken(token, tokenLength);
+ if (observer)
{
result = FormOCEntityHandlerRequest(&ehRequest,
0,
{
result = FormOCEntityHandlerRequest(&ehRequest,
0,
OC_OBSERVE_DEREGISTER,
observer->observeId,
0);
OC_OBSERVE_DEREGISTER,
observer->observeId,
0);
- if(result != OC_STACK_OK)
+ if (result != OC_STACK_OK)
- observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
- observer->resource->entityHandlerCallbackParam);
+
+ if (observer->resource && observer->resource->entityHandler)
+ {
+ observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
+ observer->resource->entityHandlerCallbackParam);
+ }
- result = DeleteObserverUsingToken (token, tokenLength);
- if(result == OC_STACK_OK)
+ result = DeleteObserverUsingToken(token, tokenLength);
+ if (result == OC_STACK_OK)
{
OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
{
OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
case OC_OBSERVER_STILL_INTERESTED:
OIC_LOG(DEBUG, TAG, "observer still interested, reset the failedCount");
case OC_OBSERVER_STILL_INTERESTED:
OIC_LOG(DEBUG, TAG, "observer still interested, reset the failedCount");
- observer = GetObserverUsingToken (token, tokenLength);
- if(observer)
+ observer = GetObserverUsingToken(token, tokenLength);
+ if (observer)
{
observer->forceHighQos = 0;
observer->failedCommCount = 0;
{
observer->forceHighQos = 0;
observer->failedCommCount = 0;
case OC_OBSERVER_FAILED_COMM:
OIC_LOG(DEBUG, TAG, "observer is unreachable");
observer = GetObserverUsingToken (token, tokenLength);
case OC_OBSERVER_FAILED_COMM:
OIC_LOG(DEBUG, TAG, "observer is unreachable");
observer = GetObserverUsingToken (token, tokenLength);
- if(observer->failedCommCount >= MAX_OBSERVER_FAILED_COMM)
+ if (observer->failedCommCount >= MAX_OBSERVER_FAILED_COMM)
{
result = FormOCEntityHandlerRequest(&ehRequest,
0,
{
result = FormOCEntityHandlerRequest(&ehRequest,
0,
OC_OBSERVE_DEREGISTER,
observer->observeId,
0);
OC_OBSERVE_DEREGISTER,
observer->observeId,
0);
- if(result != OC_STACK_OK)
+ if (result != OC_STACK_OK)
{
return OC_STACK_ERROR;
}
{
return OC_STACK_ERROR;
}
- observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
- observer->resource->entityHandlerCallbackParam);
- result = DeleteObserverUsingToken (token, tokenLength);
- if(result == OC_STACK_OK)
+ if (observer->resource && observer->resource->entityHandler)
+ {
+ observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,
+ observer->resource->entityHandlerCallbackParam);
+ }
+
+ result = DeleteObserverUsingToken(token, tokenLength);
+ if (result == OC_STACK_OK)
{
OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
{
OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
if(result != OC_STACK_OK)
{
OIC_LOG(ERROR, TAG, "Stack initialization error");
if(result != OC_STACK_OK)
{
OIC_LOG(ERROR, TAG, "Stack initialization error");
+ TerminateScheduleResourceList();
deleteAllResources();
CATerminate();
deleteAllResources();
CATerminate();
- TerminateScheduleResourceList();
stackState = OC_STACK_UNINITIALIZED;
}
return result;
stackState = OC_STACK_UNINITIALIZED;
}
return result;
stackState = OC_STACK_UNINIT_IN_PROGRESS;
stackState = OC_STACK_UNINIT_IN_PROGRESS;
+ CAUnregisterNetworkMonitorHandler(OCDefaultAdapterStateChangedHandler,
+ OCDefaultConnectionStateChangedHandler);
+
#ifdef WITH_PRESENCE
// Ensure that the TTL associated with ANY and ALL presence notifications originating from
// here send with the code "OC_STACK_PRESENCE_STOPPED" result.
#ifdef WITH_PRESENCE
// Ensure that the TTL associated with ANY and ALL presence notifications originating from
// here send with the code "OC_STACK_PRESENCE_STOPPED" result.
TerminateKeepAlive(myStackMode);
#endif
TerminateKeepAlive(myStackMode);
#endif
- // Free memory dynamically allocated for resources
- deleteAllResources();
- CATerminate();
TerminateScheduleResourceList();
// Remove all observers
DeleteObserverList();
TerminateScheduleResourceList();
// Remove all observers
DeleteObserverList();
+ // Free memory dynamically allocated for resources
+ deleteAllResources();
// Remove all the client callbacks
DeleteClientCBList();
// Remove all the client callbacks
DeleteClientCBList();
+ // Terminate connectivity-abstraction layer.
+ CATerminate();
// De-init the SRM Policy Engine
// TODO after BeachHead delivery: consolidate into single SRMDeInit()
SRMDeInitPolicyEngine();
// De-init the SRM Policy Engine
// TODO after BeachHead delivery: consolidate into single SRMDeInit()
SRMDeInitPolicyEngine();
stackState = OC_STACK_UNINITIALIZED;
return OC_STACK_OK;
}
stackState = OC_STACK_UNINITIALIZED;
return OC_STACK_OK;
}