Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate file upload timeout #2439

Merged
merged 8 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion iothub_client/inc/internal/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ MU_DEFINE_ENUM_WITHOUT_INVALID(BLOB_RESULT, BLOB_RESULT_VALUES)
* @param certificates A null terminated string containing CA certificates to be used
* @param proxyOptions A structure that contains optional web proxy information
* @param networkInterface An optional null terminated string containing the network interface
* @param timeout An optional timeout value for sending and receiving messages
*
* @return A @c BLOB_RESULT. BLOB_OK means the blob has been uploaded successfully. Any other value indicates an error
*/
MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadMultipleBlocksFromSasUri, const char*, SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX, getDataCallbackEx, void*, context, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse, const char*, certificates, HTTP_PROXY_OPTIONS*, proxyOptions, const char*, networkInterface)
MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadMultipleBlocksFromSasUri, const char*, SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX, getDataCallbackEx, void*, context, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse, const char*, certificates, HTTP_PROXY_OPTIONS*, proxyOptions, const char*, networkInterface, const long*, timeout)

/**
* @brief Synchronously uploads a byte array as a new block to blob storage
Expand Down
7 changes: 6 additions & 1 deletion iothub_client/src/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ static BLOB_RESULT SendBlockIdList(HTTPAPIEX_HANDLE httpApiExHandle, const char*
}


BLOB_RESULT Blob_UploadMultipleBlocksFromSasUri(const char* SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX getDataCallbackEx, void* context, unsigned int* httpStatus, BUFFER_HANDLE httpResponse, const char* certificates, HTTP_PROXY_OPTIONS *proxyOptions, const char* networkInterface)
BLOB_RESULT Blob_UploadMultipleBlocksFromSasUri(const char* SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX getDataCallbackEx, void* context, unsigned int* httpStatus, BUFFER_HANDLE httpResponse, const char* certificates, HTTP_PROXY_OPTIONS *proxyOptions, const char* networkInterface, const long* timeout)
{
BLOB_RESULT result;
const char* hostnameBegin;
Expand Down Expand Up @@ -328,6 +328,11 @@ BLOB_RESULT Blob_UploadMultipleBlocksFromSasUri(const char* SASURI, IOTHUB_CLIEN
LogError("unable to create a HTTPAPIEX_HANDLE");
result = BLOB_ERROR;
}
else if ((timeout != NULL) && (HTTPAPIEX_SetOption(httpApiExHandle, "timeout", timeout) == HTTPAPIEX_ERROR))
{
LogError("unable to set blob transfer timeout");
result = IOTHUB_CLIENT_ERROR;
}
else if ((certificates != NULL) && (HTTPAPIEX_SetOption(httpApiExHandle, "TrustedCerts", certificates) == HTTPAPIEX_ERROR))
{
LogError("failure in setting trusted certificates");
Expand Down
3 changes: 2 additions & 1 deletion iothub_client/src/iothub_client_ll_uploadtoblob.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ IOTHUB_CLIENT_RESULT IoTHubClient_LL_UploadMultipleBlocksToBlob_Impl(IOTHUB_CLIE
}
else
{
BLOB_RESULT uploadMultipleBlocksResult = Blob_UploadMultipleBlocksFromSasUri(STRING_c_str(sasUri), getDataCallbackEx, context, &httpResponse, responseToIoTHub, upload_data->certificates, &(upload_data->http_proxy_options), upload_data->networkInterface);
long timeout = ((long)upload_data->blob_upload_timeout_secs * 1000);
BLOB_RESULT uploadMultipleBlocksResult = Blob_UploadMultipleBlocksFromSasUri(STRING_c_str(sasUri), getDataCallbackEx, context, &httpResponse, responseToIoTHub, upload_data->certificates, &(upload_data->http_proxy_options), upload_data->networkInterface, timeout != 0 ? &timeout : NULL);
if (uploadMultipleBlocksResult == BLOB_ABORTED)
{
LogInfo("Blob_UploadFromSasUri aborted file upload");
Expand Down