Skip to content

Enable http2 support by default - #333

Merged
TheOneRing merged 2 commits into
mainfrom
work/http2
Jun 25, 2025
Merged

TheOneRing merged 2 commits into
mainfrom
work/http2

Conversation

@TheOneRing

Copy link
Copy Markdown
Contributor

Fixes: #27

@TheOneRing TheOneRing added this to the 3.0.0 milestone Jun 24, 2025
@TheOneRing
TheOneRing requested a review from Copilot June 24, 2025 15:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how the parallel network job limit is configured to use a callable, enables HTTP/2 by default (with an opt-out via environment), and enriches logging with the local path context.

  • Changed SyncOptions::_parallelNetworkJobs from an integer to a std::function<int()> and updated all call sites and tests accordingly
  • Defaulted HTTP/2 support to true in Account, and reversed the Env-var logic in AccessManager to disable rather than enable HTTP/2
  • Enhanced SyncEngine logging to include the local path of the sync run

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/testpermissions.cpp Updated test setup to assign a lambda for _parallelNetworkJobs
src/libsync/syncoptions.h Switched _parallelNetworkJobs to std::function<int()>
src/libsync/syncengine.cpp Added _localPath to sync duration log
src/libsync/owncloudpropagator.cpp Updated calls to use the callable for job limits (and logic bug)
src/libsync/discoveryphase.cpp Updated to call the new _parallelNetworkJobs() function
src/libsync/account.h Declared isHttp2Supported()/setHttp2Supported() and defaulted to true
src/libsync/account.cpp Implemented the new HTTP/2 support accessors
src/libsync/accessmanager.cpp Inverted Env-var config to disable HTTP/2 by default
src/gui/folder.cpp Captured account pointer in lambda for parallel job config
Comments suppressed due to low confidence (4)

src/libsync/accessmanager.cpp:84

  • The new behavior around HTTP/2 default enablement and the DISABLED env var should have corresponding unit tests to verify both default-allowed and env-var-disabled paths.
    static const bool http2DisabledEnv = qEnvironmentVariableIntValue("OPENCLOUD_HTTP2_DISABLED") == 1;

src/libsync/syncoptions.h:47

  • [nitpick] The doc comment for _parallelNetworkJobs should be updated to explain that it is now a callable returning the job limit, not a fixed integer.
    std::function<int()> _parallelNetworkJobs = [] { return 6; };

src/libsync/syncoptions.h:47

  • Changing the type of a public sync option from int to std::function<int()> is an API/ABI breaking change; consider providing a compatibility shim or bumping the library version.
    std::function<int()> _parallelNetworkJobs = [] { return 6; };

src/libsync/owncloudpropagator.cpp:79

  • The original logic used qMin to cap the number of active transfers at 3; switching to std::max inverts this and now enforces a minimum of 3. Consider using std::min(3, ...) to preserve the intended upper limit.
    return std::max(3, qCeil(_syncOptions._parallelNetworkJobs() / 2.));

@TheOneRing
TheOneRing force-pushed the work/http2 branch 2 times, most recently from 845ff11 to fa356c9 Compare June 24, 2025 15:18
return 1;
}
return qMin(3, qCeil(_syncOptions._parallelNetworkJobs / 2.));
return std::max(3, qCeil(_syncOptions._parallelNetworkJobs() / 2.));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dragotin the min must have been an error because it would basically always set it to 3... besides the unit tests where _parallelNetworkJobs is set to 1 🙈

Comment thread src/libsync/account.h
QPointer<ResourcesCache> _resourcesCache;
QScopedPointer<AbstractCredentials> _credentials;
bool _http2Supported = false;
bool _http2Supported = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the goal not to initialize with false and then have https://github.com/opencloud-eu/desktop/pull/333/files#diff-12d910d5c97c3d9989a6731c12f2a81fb9a1153063bfe76f560afcc82b6420b4L67 set it to true?

supported = we tried it and it was actually used?
allowed = we attempt to try it at all

So basically only set 20 parallel if it worked once as http2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note: I don't know how often Folder::loadSyncOptions() gets called, because then the opt._parallelNetworkJobs would need to be re-evaluated after we know if works (if it gets called only once)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's why I replaced it with a std::function, the alternative would be to update it once _http2Supported changed.
The value here shouldn't really matter, as we will definitely have checked for http2 support once a sync starts.

Comment thread src/libsync/syncoptions.h

/** The maximum number of active jobs in parallel */
int _parallelNetworkJobs = 6;
std::function<int()> _parallelNetworkJobs = [] { return 6; };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hm, to make it more easy to understand, i'd add a comment here: // will be overwriten later in loadSyncOptions()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable support for HTTP2

3 participants