Azure IoT / iothub_client

Dependents:   sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more

Files at this revision

API Documentation at this revision

Comitter:
AzureIoTClient
Date:
Mon Sep 25 13:37:53 2017 -0700
Parent:
75:86205ca63a59
Child:
77:e4e36df9caee
Commit message:
1.1.24

Changed in this revision

iothub_client.c Show annotated file Show diff for this revision Revisions of this file
iothub_client_authorization.c Show annotated file Show diff for this revision Revisions of this file
iothub_client_authorization.h Show annotated file Show diff for this revision Revisions of this file
iothub_client_ll.h Show annotated file Show diff for this revision Revisions of this file
iothub_client_version.h Show annotated file Show diff for this revision Revisions of this file
--- 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++)
--- a/iothub_client_authorization.c	Mon Sep 11 09:22:55 2017 -0700
+++ b/iothub_client_authorization.c	Mon Sep 25 13:37:53 2017 -0700
@@ -290,7 +290,7 @@
     return result;
 }
 
-char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expire_time)
+char* IoTHubClient_Auth_Get_SasToken(IOTHUB_AUTHORIZATION_HANDLE handle, const char* scope, size_t expiry_time_relative_seconds)
 {
     char* result;
     /* Codes_SRS_IoTHub_Authorization_07_009: [ if handle or scope are NULL, IoTHubClient_Auth_Get_SasToken shall return NULL. ] */
@@ -314,7 +314,7 @@
             }
             else 
             {
-                size_t expiry_time = sec_since_epoch+expire_time;
+                size_t expiry_time = sec_since_epoch+expiry_time_relative_seconds;
                 dev_auth_cred.sas_info.expiry_seconds = expiry_time;
                 dev_auth_cred.sas_info.token_scope = scope;
                 dev_auth_cred.dev_auth_type = AUTH_TYPE_SAS;
@@ -372,7 +372,7 @@
                 STRING_HANDLE sas_token;
                 size_t sec_since_epoch;
 
-                /* Codes_SRS_IoTHub_Authorization_07_010: [ IoTHubClient_Auth_Get_ConnString shall construct the expiration time using the expire_time. ] */
+                /* Codes_SRS_IoTHub_Authorization_07_010: [ IoTHubClient_Auth_Get_SasToken` shall construct the expiration time using the expiry_time_relative_seconds added to epoch time. ] */
                 if (get_seconds_since_epoch(&sec_since_epoch) != 0)
                 {
                     /* Codes_SRS_IoTHub_Authorization_07_020: [ If any error is encountered IoTHubClient_Auth_Get_ConnString shall return NULL. ] */
@@ -382,7 +382,7 @@
                 else 
                 {
                     /* Codes_SRS_IoTHub_Authorization_07_011: [ IoTHubClient_Auth_Get_ConnString shall call SASToken_CreateString to construct the sas token. ] */
-                    size_t expiry_time = sec_since_epoch+expire_time;
+                    size_t expiry_time = sec_since_epoch+expiry_time_relative_seconds;
                     if ( (sas_token = SASToken_CreateString(handle->device_key, scope, key_name, expiry_time)) == NULL)
                     {
                         /* Codes_SRS_IoTHub_Authorization_07_020: [ If any error is encountered IoTHubClient_Auth_Get_ConnString shall return NULL. ] */
--- a/iothub_client_authorization.h	Mon Sep 11 09:22:55 2017 -0700
+++ b/iothub_client_authorization.h	Mon Sep 25 13:37:53 2017 -0700
@@ -39,7 +39,7 @@
 MOCKABLE_FUNCTION(, void, IoTHubClient_Auth_Destroy, IOTHUB_AUTHORIZATION_HANDLE, handle);
 MOCKABLE_FUNCTION(, IOTHUB_CREDENTIAL_TYPE, IoTHubClient_Auth_Set_x509_Type, IOTHUB_AUTHORIZATION_HANDLE, handle, bool, enable_x509);
 MOCKABLE_FUNCTION(, IOTHUB_CREDENTIAL_TYPE, IoTHubClient_Auth_Get_Credential_Type, IOTHUB_AUTHORIZATION_HANDLE, handle);
-MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_SasToken, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, scope, size_t, expire_time);
+MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_SasToken, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, scope, size_t, expiry_time_relative_seconds);
 MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Set_xio_Certificate, IOTHUB_AUTHORIZATION_HANDLE, handle, XIO_HANDLE, xio);
 MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_DeviceId, IOTHUB_AUTHORIZATION_HANDLE, handle);
 MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_DeviceKey, IOTHUB_AUTHORIZATION_HANDLE, handle);
--- a/iothub_client_ll.h	Mon Sep 11 09:22:55 2017 -0700
+++ b/iothub_client_ll.h	Mon Sep 25 13:37:53 2017 -0700
@@ -454,6 +454,8 @@
     *                interval in seconds when pings are sent to the server.
     *              - @b logtrace - available for MQTT protocol.  Boolean value that turns on and
     *                off the diagnostic logging.
+    *              - @b sas_token_lifetime - available for MQTT & AMQP protocol.  size_t value that that determines the
+    *                sas token timeout length.
     *
     * @return	IOTHUB_CLIENT_OK upon success or an error code upon failure.
     */
--- a/iothub_client_version.h	Mon Sep 11 09:22:55 2017 -0700
+++ b/iothub_client_version.h	Mon Sep 25 13:37:53 2017 -0700
@@ -8,7 +8,7 @@
 #ifndef IOTHUB_CLIENT_VERSION_H
 #define IOTHUB_CLIENT_VERSION_H
 
-#define IOTHUB_SDK_VERSION "1.1.23"
+#define IOTHUB_SDK_VERSION "1.1.24"
 
 #include "azure_c_shared_utility/umock_c_prod.h"