Microsoft Azure IoTHub client libraries
Dependents: sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more
This library implements the Microsoft Azure IoTHub client library. The code is replicated from https://github.com/Azure/azure-iot-sdks
Diff: iothub_client.c
- Revision:
- 76:943524fee0b7
- Parent:
- 71:0d498da5ece1
- Child:
- 78:74a8d3068204
--- a/iothub_client.c Mon Sep 11 09:22:55 2017 -0700 +++ b/iothub_client.c Mon Sep 25 13:37:53 2017 -0700 @@ -862,14 +862,6 @@ LogError("unable to Lock - - will still proceed to try to end the thread without locking"); } -#ifndef DONT_USE_UPLOADTOBLOB - /*Codes_SRS_IOTHUBCLIENT_02_069: [ IoTHubClient_Destroy shall free all data created by IoTHubClient_UploadToBlobAsync ]*/ - /*wait for all uploading threads to finish*/ - while (singlylinkedlist_get_head_item(iotHubClientInstance->savedDataToBeCleaned) != NULL) - { - garbageCollectorImpl(iotHubClientInstance); - } -#endif if (iotHubClientInstance->ThreadHandle != NULL) { iotHubClientInstance->StopThread = 1; @@ -880,16 +872,6 @@ okToJoin = false; } - /* Codes_SRS_IOTHUBCLIENT_01_006: [That includes destroying the IoTHubClient_LL instance by calling IoTHubClient_LL_Destroy.] */ - IoTHubClient_LL_Destroy(iotHubClientInstance->IoTHubClientLLHandle); - -#ifndef DONT_USE_UPLOADTOBLOB - if (iotHubClientInstance->savedDataToBeCleaned != NULL) - { - singlylinkedlist_destroy(iotHubClientInstance->savedDataToBeCleaned); - } -#endif - /*Codes_SRS_IOTHUBCLIENT_02_045: [ IoTHubClient_Destroy shall unlock the serializing lock. ]*/ if (Unlock(iotHubClientInstance->LockHandle) != LOCK_OK) { @@ -915,6 +897,35 @@ } } + + if (Lock(iotHubClientInstance->LockHandle) != LOCK_OK) + { + LogError("unable to Lock - - will still proceed to try to end the thread without locking"); + } + +#ifndef DONT_USE_UPLOADTOBLOB + /*Codes_SRS_IOTHUBCLIENT_02_069: [ IoTHubClient_Destroy shall free all data created by IoTHubClient_UploadToBlobAsync ]*/ + /*wait for all uploading threads to finish*/ + while (singlylinkedlist_get_head_item(iotHubClientInstance->savedDataToBeCleaned) != NULL) + { + garbageCollectorImpl(iotHubClientInstance); + } + + if (iotHubClientInstance->savedDataToBeCleaned != NULL) + { + singlylinkedlist_destroy(iotHubClientInstance->savedDataToBeCleaned); + } +#endif + + /* Codes_SRS_IOTHUBCLIENT_01_006: [That includes destroying the IoTHubClient_LL instance by calling IoTHubClient_LL_Destroy.] */ + IoTHubClient_LL_Destroy(iotHubClientInstance->IoTHubClientLLHandle); + + if (Unlock(iotHubClientInstance->LockHandle) != LOCK_OK) + { + LogError("unable to Unlock"); + } + + vector_size = VECTOR_size(iotHubClientInstance->saved_user_callback_list); size_t index = 0; for (index = 0; index < vector_size; index++)