-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[fix](brpc) Make secondary package aliases non-owning #65777
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2144,37 +2144,26 @@ build_lance_c() { | |
| exit 1 | ||
| fi | ||
|
|
||
| local required_rust_version="1.91.0" | ||
| local cargo_env=( | ||
| "CARGO_BUILD_JOBS=${PARALLEL}" | ||
| "CARGO_TARGET_DIR=${PWD}/${BUILD_DIR}" | ||
| "PROTOC=${TP_INSTALL_DIR}/bin/protoc" | ||
| ) | ||
| if command -v rustup >/dev/null 2>&1 && [[ -z "${RUSTUP_TOOLCHAIN}" ]]; then | ||
| if rustup toolchain list | grep -q '^1.91.0'; then | ||
| cargo_env+=("RUSTUP_TOOLCHAIN=1.91.0") | ||
| if ! rustup toolchain list | grep -Eq '^1\.91\.0([[:space:]-]|$)'; then | ||
| rustup toolchain install "${required_rust_version}" --profile minimal | ||
| fi | ||
| cargo_env+=("RUSTUP_TOOLCHAIN=${required_rust_version}") | ||
| fi | ||
|
|
||
| local required_rust_version="1.91.0" | ||
| local cargo_version | ||
| if ! cargo_version="$(env "${cargo_env[@]}" "${cargo_bin}" --version | awk '{print $2}')"; then | ||
| echo "failed to get cargo version for lance-c. Install Rust ${required_rust_version} or set LANCE_C_CARGO/RUSTUP_TOOLCHAIN." | ||
| exit 1 | ||
| fi | ||
| if ! awk -v required="${required_rust_version}" -v actual="${cargo_version}" 'BEGIN { | ||
| split(required, r, "."); | ||
| split(actual, a, "."); | ||
| for (i = 1; i <= 3; i++) { | ||
| if ((a[i] + 0) > (r[i] + 0)) { | ||
| exit 0; | ||
| } | ||
| if ((a[i] + 0) < (r[i] + 0)) { | ||
| exit 1; | ||
| } | ||
| } | ||
| exit 0; | ||
| }'; then | ||
| echo "lance-c requires Rust/Cargo ${required_rust_version} or newer, but found ${cargo_version}." | ||
| if [[ "${cargo_version}" != "${required_rust_version}" ]]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Pin the compiler that triggers this failure The reported |
||
| echo "lance-c requires Rust/Cargo ${required_rust_version}, but found ${cargo_version}." | ||
| echo "Install Rust ${required_rust_version} or set LANCE_C_CARGO/RUSTUP_TOOLCHAIN." | ||
| exit 1 | ||
| fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ index 2087cbcf..7aede561 100644 | |
| Tabbed* tabbed = dynamic_cast<Tabbed*>(service); | ||
| for (int i = 0; i < sd->method_count(); ++i) { | ||
| const google::protobuf::MethodDescriptor* md = sd->method(i); | ||
| @@ -1282,6 +1290,14 @@ int Server::AddServiceInternal(google::protobuf::Service* service, | ||
| @@ -1282,6 +1290,16 @@ int Server::AddServiceInternal(google::protobuf::Service* service, | ||
| mp.method = md; | ||
| mp.status = new MethodStatus; | ||
| _method_map[md->full_name()] = mp; | ||
|
|
@@ -27,17 +27,21 @@ index 2087cbcf..7aede561 100644 | |
| + secondary_method_name.append(secondary_full_name); | ||
| + secondary_method_name.push_back('.'); | ||
| + secondary_method_name.append(md->name()); | ||
| + _method_map[secondary_method_name] = mp; | ||
| + MethodProperty secondary_mp = mp; | ||
|
gavinchou marked this conversation as resolved.
|
||
| + secondary_mp.own_method_status = false; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Preserve ownership when the alias equals the primary package
|
||
| + _method_map[secondary_method_name] = secondary_mp; | ||
| + } | ||
| if (is_idl_support && sd->name() != sd->full_name()/*has ns*/) { | ||
| MethodProperty mp2 = mp; | ||
| mp2.own_method_status = false; | ||
| @@ -1306,6 +1322,9 @@ int Server::AddServiceInternal(google::protobuf::Service* service, | ||
| @@ -1306,6 +1324,11 @@ int Server::AddServiceInternal(google::protobuf::Service* service, | ||
| is_builtin_service, svc_opt.ownership, service, NULL }; | ||
| _fullname_service_map[sd->full_name()] = ss; | ||
| _service_map[sd->name()] = ss; | ||
| + if (!secondary_full_name.empty()) { | ||
| + _fullname_service_map[secondary_full_name] = ss; | ||
| + ServiceProperty secondary_ss = ss; | ||
| + secondary_ss.ownership = SERVER_DOESNT_OWN_SERVICE; | ||
| + _fullname_service_map[secondary_full_name] = secondary_ss; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Erase these aliases when removing the service Making the alias non-owning avoids the destructor double free, but BRPC 1.4.0 |
||
| + } | ||
| if (is_builtin_service) { | ||
| ++_builtin_service_count; | ||
|
|
||
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.
[P2] Respect an explicitly selected Cargo before invoking rustup
cargo_binmay come fromLANCE_C_CARGO/CARGO, but this branch runs whenever any unrelatedrustupis onPATH. A network-restricted builder with an exact/opt/rust-1.91/bin/cargo(and matchingRUSTC) plus rustup containing onlystablenow attemptsrustup toolchain install 1.91.0and exits underset -ebefore checking the valid custom toolchain;LANCE_C_CARGO_OFFLINE=ONis only applied later. Please auto-manage rustup only for the default/rustup Cargo path and validate explicit tool overrides directly.