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
Fix websocket transfer callback userdata & server name in tls_options #313
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,6 +314,20 @@ static struct aws_mqtt_adapter_connect_task *s_aws_mqtt_adapter_connect_task_new | |
if (connection_options->tls_options) { | ||
aws_tls_connection_options_copy(&connect_task->tls_options, connection_options->tls_options); | ||
connect_task->tls_options_ptr = &connect_task->tls_options; | ||
|
||
/* Cheat and set the tls_options host_name to our copy if they're the same */ | ||
if (!connect_task->tls_options.server_name) { | ||
struct aws_byte_cursor host_name_cur = aws_byte_cursor_from_buf(&connect_task->host_name); | ||
|
||
if (aws_tls_connection_options_set_server_name( | ||
&connect_task->tls_options, connect_task->allocator, &host_name_cur)) { | ||
AWS_LOGF_ERROR( | ||
AWS_LS_MQTT5_TO_MQTT3_ADAPTER, | ||
"id=%p: mqtt3-to-5-adapter - Failed to set TLS Connection Options server name", | ||
(void *)adapter); | ||
goto error; | ||
} | ||
} | ||
} | ||
|
||
aws_byte_buf_init_copy_from_cursor(&connect_task->client_id, allocator, connection_options->client_id); | ||
|
@@ -326,6 +340,13 @@ static struct aws_mqtt_adapter_connect_task *s_aws_mqtt_adapter_connect_task_new | |
connect_task->clean_session = connection_options->clean_session; | ||
|
||
return connect_task; | ||
|
||
error: | ||
aws_ref_count_release(&adapter->internal_refs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of doing this, let's move the acquire after the last control flow that can error out. Having to release refs in error blocks is something to avoid if possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The task is using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no |
||
|
||
s_aws_mqtt_adapter_connect_task_destroy(connect_task); | ||
|
||
return NULL; | ||
} | ||
|
||
static int s_validate_adapter_connection_options( | ||
|
@@ -1350,7 +1371,10 @@ static void s_aws_mqtt5_adapter_transform_websocket_handshake_fn( | |
adapter->mqtt5_websocket_handshake_completion_user_data = complete_ctx; | ||
|
||
(*adapter->websocket_handshake_transformer)( | ||
request, user_data, s_aws_mqtt5_adapter_websocket_handshake_completion_fn, adapter); | ||
request, | ||
adapter->websocket_handshake_transformer_user_data, | ||
s_aws_mqtt5_adapter_websocket_handshake_completion_fn, | ||
adapter); | ||
} else { | ||
(*complete_fn)(args.output_request, args.completion_error_code, complete_ctx); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call can fail. Since
s_aws_mqtt_adapter_connect_task_new
is already changed, maybe add a check for this call as well?