Skip to content

Create retry strategy after fixing up device info #158

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

Merged
merged 1 commit into from
Dec 3, 2021
Merged
Changes from all 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
4 changes: 2 additions & 2 deletions src/client/src/Client.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ STATUS createKinesisVideoClient(PDeviceInfo pDeviceInfo, PClientCallbacks pClien
// Copy the structures in their entirety
MEMCPY(&pKinesisVideoClient->clientCallbacks, pClientCallbacks, SIZEOF(ClientCallbacks));

CHK_STATUS(configureClientWithRetryStrategy(pKinesisVideoClient));

// Fix-up the defaults if needed
// IMPORTANT!!! The calloc allocator will zero the memory which will also act as a
// sentinel value in case of an earlier version of the structure
// is used and the remaining fields are not copied
fixupDeviceInfo(&pKinesisVideoClient->deviceInfo, pDeviceInfo);

CHK_STATUS(configureClientWithRetryStrategy(pKinesisVideoClient));

Comment on lines +230 to +231
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixupDeviceInfo in turn calls fixupClientInfo whose job is to just set up the defaults. I don't see how this would cause the retry strategy callbacks to be lost? Even if it were the case you need to add logic in fixupClientInfo to see if they're set so it doesn't try to modify them and/or set it to the defaults there like we do for other attributes in clientInfo/deviceInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fixupClientInfo I'm already copying retry strategy callbacks.
https://github.com/awslabs/amazon-kinesis-video-streams-pic/blob/bug-fix/src/client/src/InputValidator.c#L311
But these callbacks are optional. So if they are not present, NULL data will be copied. So we should be calling configureClientWithRetryStrategy after fixupClientInfo to make sure that if no callbacks are provided, then use our own. This way I'm able to inject callbacks in unit tests. I couldn't find a better way. And also like the fixup logic. It confused me a lot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok we can revisit later but maybe I'm missing something but if you call it before it won't be null anymore right so then can't you just do a null check if its not null then don't overwrite it?

// Fix-up the name of the device if not specified
if (pKinesisVideoClient->deviceInfo.name[0] == '\0') {
createRandomName(pKinesisVideoClient->deviceInfo.name, DEFAULT_DEVICE_NAME_LEN, pKinesisVideoClient->clientCallbacks.getRandomNumberFn,
Expand Down