Fix crash and connection failure when invalid bind_address is set #274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR has two patches to fix bugs around udp_create_socket error handling.
The first one is to fix issue where:
If conn_poll_init fails, for example by setting an invalid bind address, and it is the only agent at the time, all newly created agents will fail until another agent is created and deleted.
See this sample code connectivity-bind-address.c.gz.
The former test_connectivity_with_bind_address("8.8.8.8") will fail of course since 8.8.8.8 is an invalid local address(for most computers).
But then the latter test_connectivity_with_bind_address(NULL) will also fail. And if this is executed before 8.8.8.8 case, it will succeed.
This is because the connections thread has already exited, but the registry is not re-created in subsequent conn_create.
The patch fixes this by releasing registry when init_func fails.
The second one is to fix crash when registry_init_func fails when concurrency_mode is set to MUX or THREAD.
You can easily test this by adding
config1.concurrency_mode = JUICE_CONCURRENCY_MODE_MUX
to attached example.The patch fixes this by returning explicit error value from acquire_registry and checking it.