Skip to content

multi.h: change CURLMNWC_CLEAR_DNS#20968

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/CURLMNWC_CLEAR_DNS
Closed

multi.h: change CURLMNWC_CLEAR_DNS#20968
bagder wants to merge 1 commit intomasterfrom
bagder/CURLMNWC_CLEAR_DNS

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Mar 17, 2026

The two bitmask constants for *CLEAR_DNS and *CLEAR_CONNS are duplicates, so they cannot be distinguished and both actions fire.

This shipped in public releases since 8.16.0 to and include 8.19.0.

This update unfortunately subtly changes the public API, but I see no alternative.

Follow-up to 55c045c

Found by Codex Security

@bagder bagder requested a review from icing March 17, 2026 23:10
Copy link
Copy Markdown
Contributor

@icing icing left a comment

Choose a reason for hiding this comment

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

Oops.

@bagder bagder marked this pull request as ready for review March 18, 2026 09:28
@bagder
Copy link
Copy Markdown
Member Author

bagder commented Mar 18, 2026

@icing can you think of any way to do the fix differently to reduce friction for users ?

@icing
Copy link
Copy Markdown
Contributor

icing commented Mar 18, 2026

@icing can you think of any way to do the fix differently to reduce friction for users ?

For link compatibility, we would define a new CURLMNWC_CLEAR_ALL as 1, CURLMNWC_CLEAR_CONNS as 2 and CURLMNWC_CLEAR_DNS as 4.

@bagder
Copy link
Copy Markdown
Member Author

bagder commented Mar 18, 2026

For link compatibility, we would define a new CURLMNWC_CLEAR_ALL as 1, CURLMNWC_CLEAR_CONNS as 2 and CURLMNWC_CLEAR_DNS as 4.

Oh, I like that. Will adjust.

@bagder bagder added the feature-window A merge of this requires an open feature window label Mar 18, 2026
bagder added a commit that referenced this pull request Mar 21, 2026
The two bitmask constants for *CLEAR_DNS and *CLEAR_CONNS were
duplicates (both set to 1), so they cannot be distinguished and both
actions fire.

This shipped in public releases since 8.16.0 to and include 8.19.0.

This fix adds CURLMNWC_CLEAR_ALL to be the new 1, and it now implies all
bits. The DNS and CONNS defines get two new bits (2, 4).

Follow-up to 55c045c

Found by Codex Security
Closes #20968
@bagder bagder force-pushed the bagder/CURLMNWC_CLEAR_DNS branch from 81a9ba1 to 45bdbb3 Compare March 21, 2026 22:08
@bagder bagder requested a review from Copilot March 21, 2026 22:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an API/behavior issue in CURLMOPT_NETWORK_CHANGED where the CURLMNWC_CLEAR_CONNS and CURLMNWC_CLEAR_DNS bitmasks were identical, making them indistinguishable and causing both actions to trigger.

Changes:

  • Introduces CURLMNWC_CLEAR_ALL and assigns distinct bit values to CURLMNWC_CLEAR_CONNS and CURLMNWC_CLEAR_DNS.
  • Updates curl_multi_setopt(CURLMOPT_NETWORK_CHANGED, ...) handling to preserve legacy behavior where the old value 1 implied “clear all”.
  • Documents the new symbol/version in symbols-in-versions and updates the option documentation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lib/multi.c Adds CURLMNWC_CLEAR_ALL handling to map legacy 1 to “clear DNS + conns”.
include/curl/multi.h Defines CURLMNWC_CLEAR_ALL and assigns unique bits to CONNS/DNS.
docs/libcurl/symbols-in-versions Records CURLMNWC_CLEAR_ALL as added in 8.20.0.
docs/libcurl/opts/CURLMOPT_NETWORK_CHANGED.md Documents CURLMNWC_CLEAR_ALL and refreshes formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread include/curl/multi.h Outdated
Comment thread lib/multi.c
Comment thread lib/multi.c
The two bitmask constants for *CLEAR_DNS and *CLEAR_CONNS were
duplicates (both set to 1), so they cannot be distinguished and both
actions fire.

This shipped in public releases since 8.16.0 to and include 8.19.0.

This fix adds CURLMNWC_CLEAR_ALL to be the new 1, and it now implies all
bits. The DNS and CONNS defines get two new bits (2, 4).

Follow-up to 55c045c

Found by Codex Security
Closes #20968
@bagder bagder force-pushed the bagder/CURLMNWC_CLEAR_DNS branch from 18c9560 to 7e4380d Compare March 21, 2026 22:19
@bagder bagder closed this in 57a94fe Mar 22, 2026
@bagder bagder deleted the bagder/CURLMNWC_CLEAR_DNS branch March 22, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature-window A merge of this requires an open feature window libcurl API

Development

Successfully merging this pull request may close these issues.

3 participants