-
Notifications
You must be signed in to change notification settings - Fork 43
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 mqtt3 client shutdown callback #498
Conversation
… into 5to3adapter
@@ -1549,117 +1549,6 @@ def test_operation_statistics_uc1(self): | |||
client.stop() | |||
callbacks.future_stopped.result(TIMEOUT) | |||
|
|||
# ============================================================== | |||
# 5to3 ADAPTER TEST CASES | |||
# ============================================================== |
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.
The adapter tests are moved to its own file.
source/mqtt_client_connection.c
Outdated
@@ -374,9 +382,11 @@ PyObject *aws_py_mqtt_client_connection_new(PyObject *self, PyObject *args) { | |||
Py_DECREF(self_proxy); | |||
proxy_new_failed: | |||
use_websockets_failed: | |||
set_on_closed_failed: |
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.
I've come to hate this pattern for cleanup. We did it early on, but it is far better (imo) to have a failure path that can safely be executed from all branch points. If scoping is an issue, declarations can be moved up to the top of the function.
Would much rather see something like this:
on_failure:
Py_XDECREF(self_proxy);
aws_mqtt_client_connection_release(py_connection->native);
aws_mem_release(allocator, py_connection);
return NULL;
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.
Fix n ship
source/mqtt_client_connection.c
Outdated
aws_mem_release(allocator, py_connection); | ||
creation_failed: | ||
Py_XDECREF(self_proxy); | ||
if (py_connection) { |
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.
py_connection has to be non-null at this point.
Also, maybe just "on_error:" rather than "creation_failed:"
source/mqtt_client_connection.c
Outdated
creation_failed: | ||
Py_XDECREF(self_proxy); | ||
if (py_connection) { | ||
if (py_connection->native) { |
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.
You also don't need to null check this either. release handles a null invocation. The original suggestion would work verbatim.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.