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

[fix] Add the curl wrapper to avoid inconsistent curl options #313

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

BewareMyPower
Copy link
Contributor

Motivation

When libcurl is used in AuthOauth2, the CURLOPT_NOSIGNAL option is not set, i.e. it will be the default value so that the Curl_resolv_timeout function might crash in multi-threading environment.

#2 0xf630 in _L_unlock_13 from /lib64/libpthread.so.0 (0x34)
#3 0x2e6c7f in Curl_failf from /usr/local/bin/***/libpulsar.so (0x6f)
#4 0x30a285 in Curl_resolv_timeout from /usr/local/bin/***/libpulsar.so (0x95)

Since there are many duplicated code when calling curl C APIs, it's hard to notice that CURLOPT_NOSIGNAL is not configured in AuthOauth2.

Modifications

Introduce a CurlWrapper class that sets the same options to reduce the duplicated code and adapting consistent behaviors unless a few options.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

### Motivation

When libcurl is used in `AuthOauth2`, the `CURLOPT_NOSIGNAL` option is
not set, i.e. it will be the default value so that the
`Curl_resolv_timeout` function might crash in multi-threading
environment.

```
#2 0xf630 in _L_unlock_13 from /lib64/libpthread.so.0 (0x34)
#3 0x2e6c7f in Curl_failf from /usr/local/bin/***/libpulsar.so (0x6f)
#4 0x30a285 in Curl_resolv_timeout from /usr/local/bin/***/libpulsar.so (0x95)
```

Since there are many duplicated code when calling curl C APIs, it's hard to
notice that `CURLOPT_NOSIGNAL` is not configured in `AuthOauth2`.

### Modifications

Introduce a `CurlWrapper` class that sets the same options to reduce the
duplicated code and adapting consistent behaviors unless a few options.
@BewareMyPower BewareMyPower added the bug Something isn't working label Sep 11, 2023
@BewareMyPower BewareMyPower added this to the 3.4.0 milestone Sep 11, 2023
@BewareMyPower BewareMyPower self-assigned this Sep 11, 2023
@BewareMyPower
Copy link
Contributor Author

The CI for wireshark build on macOS is broken. Let's ignore it for now. I have opened an issue: #314

@shibd
Copy link
Member

shibd commented Sep 12, 2023

The CI for wireshark build on macOS is broken. Let's ignore it for now. I have opened an issue: #314

Let's fix these CI first. Ignoring failed ci is not a good idea.

@BewareMyPower
Copy link
Contributor Author

Let's fix these CI first. Ignoring failed ci is not a good idea.

They are not caused by the code issue. It should not block any fix.

@BewareMyPower BewareMyPower merged commit 787bfd0 into apache:main Sep 13, 2023
7 of 11 checks passed
@BewareMyPower BewareMyPower deleted the bewaremypower/unify-curl branch September 13, 2023 02:53
BewareMyPower added a commit to streamnative/pulsar-client-cpp that referenced this pull request Sep 14, 2023
…#313)

### Motivation

When libcurl is used in `AuthOauth2`, the `CURLOPT_NOSIGNAL` option is
not set, i.e. it will be the default value so that the
`Curl_resolv_timeout` function might crash in multi-threading
environment.

```
apache#2 0xf630 in _L_unlock_13 from /lib64/libpthread.so.0 (0x34)
apache#3 0x2e6c7f in Curl_failf from /usr/local/bin/***/libpulsar.so (0x6f)
apache#4 0x30a285 in Curl_resolv_timeout from /usr/local/bin/***/libpulsar.so (0x95)
```

Since there are many duplicated code when calling curl C APIs, it's hard to
notice that `CURLOPT_NOSIGNAL` is not configured in `AuthOauth2`.

### Modifications

Introduce a `CurlWrapper` class that sets the same options to reduce the
duplicated code and adapting consistent behaviors unless a few options.

(cherry picked from commit 787bfd0)
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Dec 5, 2023
### Motivation

apache#313 has reverted the
fix of apache#190, which
applies the `tlsTrustCertsFilePath` config for OAuth2 authentication.

The macOS pre-built libraries are affected most because the bundled CA
path is empty.

### Modification

Apply the `tlsTrustCertsFilePath` for OAuth2.

### TODO

Add the workflow to verify `tlsTrustCertsFilePath` is applied for
OAuth2.
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Dec 5, 2023
### Motivation

apache#313 has reverted the
fix of apache#190, which
applies the `tlsTrustCertsFilePath` config for OAuth2 authentication.

The macOS pre-built libraries are affected most because the bundled CA
path is empty.

### Modification

Apply the `tlsTrustCertsFilePath` for OAuth2.
BewareMyPower added a commit that referenced this pull request Dec 6, 2023
### Motivation

#313 has reverted the
fix of #190, which
applies the `tlsTrustCertsFilePath` config for OAuth2 authentication.

The macOS pre-built libraries are affected most because the bundled CA
path is empty.

### Modification

Apply the `tlsTrustCertsFilePath` for OAuth2.
BewareMyPower added a commit that referenced this pull request Dec 6, 2023
### Motivation

#313 has reverted the
fix of #190, which
applies the `tlsTrustCertsFilePath` config for OAuth2 authentication.

The macOS pre-built libraries are affected most because the bundled CA
path is empty.

### Modification

Apply the `tlsTrustCertsFilePath` for OAuth2.

(cherry picked from commit 27cba3e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants