From 3f5899f60a3049229da195c3acde6443c3ba0a04 Mon Sep 17 00:00:00 2001 From: Ulises Gascon Date: Wed, 23 Apr 2025 08:21:49 +0200 Subject: [PATCH 01/16] Working on v22.15.1 PR-URL: https://github.com/nodejs/node/pull/57840 --- src/node_version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_version.h b/src/node_version.h index 1984a0094f..fbbe8160af 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -24,12 +24,12 @@ #define NODE_MAJOR_VERSION 22 #define NODE_MINOR_VERSION 15 -#define NODE_PATCH_VERSION 0 +#define NODE_PATCH_VERSION 1 #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Jod" -#define NODE_VERSION_IS_RELEASE 1 +#define NODE_VERSION_IS_RELEASE 0 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) From 9f403e98ef45faa25f4e41af7f3a791a70af4a15 Mon Sep 17 00:00:00 2001 From: Justin Nietzel Date: Wed, 9 Apr 2025 16:51:27 -0400 Subject: [PATCH 02/16] fs: add missing call to uv_fs_req_cleanup Always call uv_fs_req_cleanup after calling uv_fs_open instead of just when uv_fs_open returns a negative result. I referenced ReadFileSync from node:js2c when making this change. https://github.com/bnoordhuis made the same suggestion based on the PR https://github.com/nodejs/node/pull/49691. Fixes: https://github.com/nodejs/node/issues/57800 PR-URL: https://github.com/nodejs/node/pull/57811 Reviewed-By: Matteo Collina Reviewed-By: James M Snell CVE-ID: CVE-2025-23165 --- src/node_file.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_file.cc b/src/node_file.cc index a492b3aa11..49816349d8 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -2594,10 +2594,10 @@ static void ReadFileUtf8(const FunctionCallbackInfo& args) { FS_SYNC_TRACE_END(open); if (req.result < 0) { uv_fs_req_cleanup(&req); - // req will be cleaned up by scope leave. return env->ThrowUVException( static_cast(req.result), "open", nullptr, path.out()); } + uv_fs_req_cleanup(&req); } auto defer_close = OnScopeLeave([file, is_fd, &req]() { From edaf54da00af42b349b59dccb043dfee31eb623b Mon Sep 17 00:00:00 2001 From: Justin Nietzel Date: Fri, 11 Apr 2025 11:09:51 -0400 Subject: [PATCH 03/16] fs: added test for missing call to uv_fs_req_cleanup Added a unit test for testing the memory usage of readFileSync. Test is looking specifically for the the issue caused by failing to free the filepath buffer in fs::ReadFileUtf8(), but it will also catch other significant memory leaks in readFileSync() as well. Refs: https://github.com/nodejs/node/issues/57800 PR-URL: https://github.com/nodejs/node/pull/57811 Fixes: https://github.com/nodejs/node/issues/57800 Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- .../test-fs-read-file-sync-utf8-memory.js | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/pummel/test-fs-read-file-sync-utf8-memory.js diff --git a/test/pummel/test-fs-read-file-sync-utf8-memory.js b/test/pummel/test-fs-read-file-sync-utf8-memory.js new file mode 100644 index 0000000000..2e902d08a0 --- /dev/null +++ b/test/pummel/test-fs-read-file-sync-utf8-memory.js @@ -0,0 +1,54 @@ +'use strict'; +const common = require('../common'); +if (common.isIBMi) + common.skip('On IBMi, the rss memory always returns zero'); + +// This test verifies that readFileSync does not leak memory when reading +// UTF8 files. See: https://github.com/nodejs/node/issues/57800 for details. + +const assert = require('node:assert'); +const fs = require('node:fs'); +const util = require('node:util'); +const tmpdir = require('../common/tmpdir'); + +// The memory leak being tested here was from a buffer with the absolute URI to +// a file. For each file read, 2-4 bytes were (usually) leaked per character in +// the URI. The length of the file path can be used to estimate the approximate +// amount of memory that will be leaked if this issue is reintroduced. A longer +// total path length will make the issue easier to test for. Some operating +// systems like Windows have shorter default path length limits. If the path +// is approaching that limit, the length of the path should be long enough to +// effectively test for this memory leak. +tmpdir.refresh(); +let testFile = tmpdir.resolve( + 'a-file-with-a-longer-than-usual-file-name-for-testing-a-memory-leak-related-to-path-length.txt', +); +if (testFile.length > process.env.MAX_PATH) { + testFile = tmpdir.resolve('reasonable-length.txt'); +} + +// The buffer being checked is WCHAR buffer. The size is going to be at least 2 +// bytes per character but can be more. Windows: 2; Mac: 2; Linux: 4 (usually); +const iterations = 100_000; +const minExpectedMemoryLeak = (testFile.length * 2) * iterations; + +// This memory leak was exclusive to UTF8 encoded files. +// Create our test file. The contents of the file don't matter. +const options = { encoding: 'utf8' }; +fs.writeFileSync(testFile, '', options); + +// Doing an initial big batch of file reads gives a more stable baseline memory +// usage. Doing the same total iterations as the actual test isn't necessary. +for (let i = 0; i < 100; i++) { + fs.readFileSync(testFile, options); +} +const startMemory = process.memoryUsage(); +for (let i = 0; i < iterations; i++) { + fs.readFileSync(testFile, options); +} +const endMemory = process.memoryUsage(); + +// Use 90% of the expected memory leak as the threshold just to be safe. +const memoryDifference = endMemory.rss - startMemory.rss; +assert.ok(memoryDifference < (minExpectedMemoryLeak * 0.9), + `Unexpected memory overhead: ${util.inspect([startMemory, endMemory])}`); From f4494d38f1e0cd04f17862bd5c6b7a6bc8b2a549 Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Mon, 12 May 2025 11:59:55 -0300 Subject: [PATCH 04/16] src: fix error handling on async crypto operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://hackerone.com/reports/2817648 Co-Authored-By: Filip Skokan Co-Authored-By: Tobias Nießen Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/688 CVE-ID: CVE-2025-23166 PR-URL: https://github.com/nodejs-private/node-private/pull/709 --- src/crypto/crypto_dh.cc | 8 +++--- src/crypto/crypto_dh.h | 8 +++--- src/crypto/crypto_ec.cc | 3 ++- src/crypto/crypto_ec.h | 8 +++--- src/crypto/crypto_hash.cc | 8 +++--- src/crypto/crypto_hash.h | 8 +++--- src/crypto/crypto_hkdf.cc | 8 +++--- src/crypto/crypto_hkdf.h | 8 +++--- src/crypto/crypto_hmac.cc | 8 +++--- src/crypto/crypto_hmac.h | 8 +++--- src/crypto/crypto_pbkdf2.cc | 3 ++- src/crypto/crypto_pbkdf2.h | 8 +++--- src/crypto/crypto_random.cc | 19 ++++++------- src/crypto/crypto_random.h | 24 ++++++++--------- src/crypto/crypto_scrypt.cc | 8 +++--- src/crypto/crypto_scrypt.h | 8 +++--- src/crypto/crypto_sig.cc | 25 +++++++++-------- src/crypto/crypto_sig.h | 8 +++--- src/crypto/crypto_util.h | 8 +++--- .../parallel/test-crypto-async-sign-verify.js | 27 +++++++++++++++++++ 20 files changed, 124 insertions(+), 89 deletions(-) diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc index 7041eb985d..c26a88b395 100644 --- a/src/crypto/crypto_dh.cc +++ b/src/crypto/crypto_dh.cc @@ -523,10 +523,10 @@ MaybeLocal DHBitsTraits::EncodeOutput(Environment* env, return out->ToArrayBuffer(env); } -bool DHBitsTraits::DeriveBits( - Environment* env, - const DHBitsConfig& params, - ByteSource* out) { +bool DHBitsTraits::DeriveBits(Environment* env, + const DHBitsConfig& params, + ByteSource* out, + CryptoJobMode mode) { *out = StatelessDiffieHellmanThreadsafe(params.private_key.GetAsymmetricKey(), params.public_key.GetAsymmetricKey()); return true; diff --git a/src/crypto/crypto_dh.h b/src/crypto/crypto_dh.h index 2af668035b..73eda985fc 100644 --- a/src/crypto/crypto_dh.h +++ b/src/crypto/crypto_dh.h @@ -103,10 +103,10 @@ struct DHBitsTraits final { unsigned int offset, DHBitsConfig* params); - static bool DeriveBits( - Environment* env, - const DHBitsConfig& params, - ByteSource* out_); + static bool DeriveBits(Environment* env, + const DHBitsConfig& params, + ByteSource* out_, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const DHBitsConfig& params, diff --git a/src/crypto/crypto_ec.cc b/src/crypto/crypto_ec.cc index c0432dd148..2a3107dbbf 100644 --- a/src/crypto/crypto_ec.cc +++ b/src/crypto/crypto_ec.cc @@ -450,7 +450,8 @@ Maybe ECDHBitsTraits::AdditionalConfig( bool ECDHBitsTraits::DeriveBits(Environment* env, const ECDHBitsConfig& params, - ByteSource* out) { + ByteSource* out, + CryptoJobMode mode) { size_t len = 0; const auto& m_privkey = params.private_.GetAsymmetricKey(); const auto& m_pubkey = params.public_.GetAsymmetricKey(); diff --git a/src/crypto/crypto_ec.h b/src/crypto/crypto_ec.h index 7aeeebbe30..a963f457b3 100644 --- a/src/crypto/crypto_ec.h +++ b/src/crypto/crypto_ec.h @@ -78,10 +78,10 @@ struct ECDHBitsTraits final { unsigned int offset, ECDHBitsConfig* params); - static bool DeriveBits( - Environment* env, - const ECDHBitsConfig& params, - ByteSource* out_); + static bool DeriveBits(Environment* env, + const ECDHBitsConfig& params, + ByteSource* out_, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const ECDHBitsConfig& params, diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc index bcd4c533b0..243aba0a09 100644 --- a/src/crypto/crypto_hash.cc +++ b/src/crypto/crypto_hash.cc @@ -502,10 +502,10 @@ Maybe HashTraits::AdditionalConfig( return JustVoid(); } -bool HashTraits::DeriveBits( - Environment* env, - const HashConfig& params, - ByteSource* out) { +bool HashTraits::DeriveBits(Environment* env, + const HashConfig& params, + ByteSource* out, + CryptoJobMode mode) { EVPMDCtxPointer ctx(EVP_MD_CTX_new()); if (!ctx || EVP_DigestInit_ex(ctx.get(), params.digest, nullptr) <= 0 || diff --git a/src/crypto/crypto_hash.h b/src/crypto/crypto_hash.h index 85da86dba9..ce865b6713 100644 --- a/src/crypto/crypto_hash.h +++ b/src/crypto/crypto_hash.h @@ -70,10 +70,10 @@ struct HashTraits final { unsigned int offset, HashConfig* params); - static bool DeriveBits( - Environment* env, - const HashConfig& params, - ByteSource* out); + static bool DeriveBits(Environment* env, + const HashConfig& params, + ByteSource* out, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const HashConfig& params, diff --git a/src/crypto/crypto_hkdf.cc b/src/crypto/crypto_hkdf.cc index 2a465c849d..614cb67a1c 100644 --- a/src/crypto/crypto_hkdf.cc +++ b/src/crypto/crypto_hkdf.cc @@ -96,10 +96,10 @@ Maybe HKDFTraits::AdditionalConfig( return JustVoid(); } -bool HKDFTraits::DeriveBits( - Environment* env, - const HKDFConfig& params, - ByteSource* out) { +bool HKDFTraits::DeriveBits(Environment* env, + const HKDFConfig& params, + ByteSource* out, + CryptoJobMode mode) { auto dp = ncrypto::hkdf(params.digest, ncrypto::Buffer{ .data = reinterpret_cast( diff --git a/src/crypto/crypto_hkdf.h b/src/crypto/crypto_hkdf.h index be6e823269..9456198cc5 100644 --- a/src/crypto/crypto_hkdf.h +++ b/src/crypto/crypto_hkdf.h @@ -42,10 +42,10 @@ struct HKDFTraits final { unsigned int offset, HKDFConfig* params); - static bool DeriveBits( - Environment* env, - const HKDFConfig& params, - ByteSource* out); + static bool DeriveBits(Environment* env, + const HKDFConfig& params, + ByteSource* out, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const HKDFConfig& params, diff --git a/src/crypto/crypto_hmac.cc b/src/crypto/crypto_hmac.cc index 25ccb1b9d0..50611c1430 100644 --- a/src/crypto/crypto_hmac.cc +++ b/src/crypto/crypto_hmac.cc @@ -221,10 +221,10 @@ Maybe HmacTraits::AdditionalConfig( return JustVoid(); } -bool HmacTraits::DeriveBits( - Environment* env, - const HmacConfig& params, - ByteSource* out) { +bool HmacTraits::DeriveBits(Environment* env, + const HmacConfig& params, + ByteSource* out, + CryptoJobMode mode) { HMACCtxPointer ctx(HMAC_CTX_new()); if (!ctx || !HMAC_Init_ex(ctx.get(), diff --git a/src/crypto/crypto_hmac.h b/src/crypto/crypto_hmac.h index e29ec231a1..fab9c1c848 100644 --- a/src/crypto/crypto_hmac.h +++ b/src/crypto/crypto_hmac.h @@ -73,10 +73,10 @@ struct HmacTraits final { unsigned int offset, HmacConfig* params); - static bool DeriveBits( - Environment* env, - const HmacConfig& params, - ByteSource* out); + static bool DeriveBits(Environment* env, + const HmacConfig& params, + ByteSource* out, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const HmacConfig& params, diff --git a/src/crypto/crypto_pbkdf2.cc b/src/crypto/crypto_pbkdf2.cc index dcaa430aac..99ad4c11ed 100644 --- a/src/crypto/crypto_pbkdf2.cc +++ b/src/crypto/crypto_pbkdf2.cc @@ -111,7 +111,8 @@ Maybe PBKDF2Traits::AdditionalConfig( bool PBKDF2Traits::DeriveBits(Environment* env, const PBKDF2Config& params, - ByteSource* out) { + ByteSource* out, + CryptoJobMode mode) { // Both pass and salt may be zero length here. auto dp = ncrypto::pbkdf2(params.digest, ncrypto::Buffer{ diff --git a/src/crypto/crypto_pbkdf2.h b/src/crypto/crypto_pbkdf2.h index 604736f308..8b3ac4e8f1 100644 --- a/src/crypto/crypto_pbkdf2.h +++ b/src/crypto/crypto_pbkdf2.h @@ -55,10 +55,10 @@ struct PBKDF2Traits final { unsigned int offset, PBKDF2Config* params); - static bool DeriveBits( - Environment* env, - const PBKDF2Config& params, - ByteSource* out); + static bool DeriveBits(Environment* env, + const PBKDF2Config& params, + ByteSource* out, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const PBKDF2Config& params, diff --git a/src/crypto/crypto_random.cc b/src/crypto/crypto_random.cc index cb96698aa6..78f2093d1d 100644 --- a/src/crypto/crypto_random.cc +++ b/src/crypto/crypto_random.cc @@ -64,10 +64,10 @@ Maybe RandomBytesTraits::AdditionalConfig( return JustVoid(); } -bool RandomBytesTraits::DeriveBits( - Environment* env, - const RandomBytesConfig& params, - ByteSource* unused) { +bool RandomBytesTraits::DeriveBits(Environment* env, + const RandomBytesConfig& params, + ByteSource* unused, + CryptoJobMode mode) { return ncrypto::CSPRNG(params.buffer, params.size); } @@ -154,7 +154,8 @@ Maybe RandomPrimeTraits::AdditionalConfig( bool RandomPrimeTraits::DeriveBits(Environment* env, const RandomPrimeConfig& params, - ByteSource* unused) { + ByteSource* unused, + CryptoJobMode mode) { return params.prime.generate( BignumPointer::PrimeConfig{ .bits = params.bits, @@ -190,10 +191,10 @@ Maybe CheckPrimeTraits::AdditionalConfig( return JustVoid(); } -bool CheckPrimeTraits::DeriveBits( - Environment* env, - const CheckPrimeConfig& params, - ByteSource* out) { +bool CheckPrimeTraits::DeriveBits(Environment* env, + const CheckPrimeConfig& params, + ByteSource* out, + CryptoJobMode mode) { int ret = params.candidate.isPrime(params.checks, getPrimeCheckCallback(env)); if (ret < 0) return false; ByteSource::Builder buf(1); diff --git a/src/crypto/crypto_random.h b/src/crypto/crypto_random.h index 8b3193c24f..60ddc6829f 100644 --- a/src/crypto/crypto_random.h +++ b/src/crypto/crypto_random.h @@ -32,10 +32,10 @@ struct RandomBytesTraits final { unsigned int offset, RandomBytesConfig* params); - static bool DeriveBits( - Environment* env, - const RandomBytesConfig& params, - ByteSource* out_); + static bool DeriveBits(Environment* env, + const RandomBytesConfig& params, + ByteSource* out_, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const RandomBytesConfig& params, @@ -67,10 +67,10 @@ struct RandomPrimeTraits final { unsigned int offset, RandomPrimeConfig* params); - static bool DeriveBits( - Environment* env, - const RandomPrimeConfig& params, - ByteSource* out_); + static bool DeriveBits(Environment* env, + const RandomPrimeConfig& params, + ByteSource* out_, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const RandomPrimeConfig& params, @@ -101,10 +101,10 @@ struct CheckPrimeTraits final { unsigned int offset, CheckPrimeConfig* params); - static bool DeriveBits( - Environment* env, - const CheckPrimeConfig& params, - ByteSource* out); + static bool DeriveBits(Environment* env, + const CheckPrimeConfig& params, + ByteSource* out, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const CheckPrimeConfig& params, diff --git a/src/crypto/crypto_scrypt.cc b/src/crypto/crypto_scrypt.cc index 1886543e6e..9a80556c06 100644 --- a/src/crypto/crypto_scrypt.cc +++ b/src/crypto/crypto_scrypt.cc @@ -113,10 +113,10 @@ Maybe ScryptTraits::AdditionalConfig( return JustVoid(); } -bool ScryptTraits::DeriveBits( - Environment* env, - const ScryptConfig& params, - ByteSource* out) { +bool ScryptTraits::DeriveBits(Environment* env, + const ScryptConfig& params, + ByteSource* out, + CryptoJobMode mode) { // If the params.length is zero-length, just return an empty buffer. // It's useless, yes, but allowed via the API. if (params.length == 0) { diff --git a/src/crypto/crypto_scrypt.h b/src/crypto/crypto_scrypt.h index 68a5169073..5e86de8619 100644 --- a/src/crypto/crypto_scrypt.h +++ b/src/crypto/crypto_scrypt.h @@ -57,10 +57,10 @@ struct ScryptTraits final { unsigned int offset, ScryptConfig* params); - static bool DeriveBits( - Environment* env, - const ScryptConfig& params, - ByteSource* out); + static bool DeriveBits(Environment* env, + const ScryptConfig& params, + ByteSource* out, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const ScryptConfig& params, diff --git a/src/crypto/crypto_sig.cc b/src/crypto/crypto_sig.cc index abb8a804c1..e330d64f10 100644 --- a/src/crypto/crypto_sig.cc +++ b/src/crypto/crypto_sig.cc @@ -703,11 +703,11 @@ Maybe SignTraits::AdditionalConfig( return JustVoid(); } -bool SignTraits::DeriveBits( - Environment* env, - const SignConfiguration& params, - ByteSource* out) { - ClearErrorOnReturn clear_error_on_return; +bool SignTraits::DeriveBits(Environment* env, + const SignConfiguration& params, + ByteSource* out, + CryptoJobMode mode) { + bool can_throw = mode == CryptoJobMode::kCryptoJobSync; EVPMDCtxPointer context(EVP_MD_CTX_new()); EVP_PKEY_CTX* ctx = nullptr; @@ -717,14 +717,14 @@ bool SignTraits::DeriveBits( case SignConfiguration::kSign: if (!EVP_DigestSignInit( context.get(), &ctx, params.digest, nullptr, key.get())) { - crypto::CheckThrow(env, SignBase::Error::kSignInit); + if (can_throw) crypto::CheckThrow(env, SignBase::Error::kSignInit); return false; } break; case SignConfiguration::kVerify: if (!EVP_DigestVerifyInit( context.get(), &ctx, params.digest, nullptr, key.get())) { - crypto::CheckThrow(env, SignBase::Error::kSignInit); + if (can_throw) crypto::CheckThrow(env, SignBase::Error::kSignInit); return false; } break; @@ -738,7 +738,7 @@ bool SignTraits::DeriveBits( ? Just(params.salt_length) : Nothing(); if (!ApplyRSAOptions(key, ctx, padding, salt_length)) { - crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); + if (can_throw) crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); return false; } @@ -752,7 +752,8 @@ bool SignTraits::DeriveBits( &len, params.data.data(), params.data.size())) { - crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); + if (can_throw) + crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); return false; } ByteSource::Builder buf(len); @@ -772,13 +773,15 @@ bool SignTraits::DeriveBits( params.data.data(), params.data.size()) || !EVP_DigestSignFinal(context.get(), nullptr, &len)) { - crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); + if (can_throw) + crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); return false; } ByteSource::Builder buf(len); if (!EVP_DigestSignFinal( context.get(), buf.data(), &len)) { - crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); + if (can_throw) + crypto::CheckThrow(env, SignBase::Error::kSignPrivateKey); return false; } diff --git a/src/crypto/crypto_sig.h b/src/crypto/crypto_sig.h index 3a3c27b4e8..720b03d415 100644 --- a/src/crypto/crypto_sig.h +++ b/src/crypto/crypto_sig.h @@ -146,10 +146,10 @@ struct SignTraits final { unsigned int offset, SignConfiguration* params); - static bool DeriveBits( - Environment* env, - const SignConfiguration& params, - ByteSource* out); + static bool DeriveBits(Environment* env, + const SignConfiguration& params, + ByteSource* out, + CryptoJobMode mode); static v8::MaybeLocal EncodeOutput(Environment* env, const SignConfiguration& params, diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h index b85c8daeb4..1592134716 100644 --- a/src/crypto/crypto_util.h +++ b/src/crypto/crypto_util.h @@ -467,9 +467,11 @@ class DeriveBitsJob final : public CryptoJob { std::move(params)) {} void DoThreadPoolWork() override { - if (!DeriveBitsTraits::DeriveBits( - AsyncWrap::env(), - *CryptoJob::params(), &out_)) { + ncrypto::ClearErrorOnReturn clear_error_on_return; + if (!DeriveBitsTraits::DeriveBits(AsyncWrap::env(), + *CryptoJob::params(), + &out_, + this->mode())) { CryptoErrorStore* errors = CryptoJob::errors(); errors->Capture(); if (errors->Empty()) diff --git a/test/parallel/test-crypto-async-sign-verify.js b/test/parallel/test-crypto-async-sign-verify.js index 4e3c32fdcd..b35dd08e6c 100644 --- a/test/parallel/test-crypto-async-sign-verify.js +++ b/test/parallel/test-crypto-async-sign-verify.js @@ -3,6 +3,7 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +const { hasOpenSSL3 } = require('../common/crypto'); const assert = require('assert'); const util = require('util'); const crypto = require('crypto'); @@ -141,3 +142,29 @@ test('dsa_public.pem', 'dsa_private.pem', 'sha256', false, }) .catch(common.mustNotCall()); } + +{ + const untrustedKey = `-----BEGIN PUBLIC KEY----- +MCowBQYDK2VuAyEA6pwGRbadNQAI/tYN8+/p/0/hbsdHfOEGr1ADiLVk/Gc= +-----END PUBLIC KEY-----`; + const data = crypto.randomBytes(32); + const signature = crypto.randomBytes(16); + + const expected = hasOpenSSL3 ? + /operation not supported for this keytype/ : /no default digest/; + + crypto.verify(undefined, data, untrustedKey, signature, common.mustCall((err) => { + assert.ok(err); + assert.match(err.message, expected); + })); +} + +{ + const { privateKey } = crypto.generateKeyPairSync('rsa', { + modulusLength: 512 + }); + crypto.sign('sha512', 'message', privateKey, common.mustCall((err) => { + assert.ok(err); + assert.match(err.message, /digest too big for rsa key/); + })); +} From 7039b12ae5e0913f7a14da4d9d58ad04d4a4a16e Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Wed, 7 May 2025 17:37:13 -0300 Subject: [PATCH 05/16] 2025-05-14, Version 22.15.1 'Jod' (LTS) This is a security release. Notable changes: src: * (CVE-2025-23166) fix error handling on async crypto operation fs: * (CVE-2025-23165) add missing call to uv\_fs\_req\_cleanup PR-URL: https://github.com/nodejs-private/node-private/pull/712 --- CHANGELOG.md | 3 ++- doc/changelogs/CHANGELOG_V22.md | 18 ++++++++++++++++++ src/node_version.h | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fcec1d080..73ca572eff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,8 @@ release. -22.15.0
+22.15.1
+22.15.0
22.14.0
22.13.1
22.13.0
diff --git a/doc/changelogs/CHANGELOG_V22.md b/doc/changelogs/CHANGELOG_V22.md index 4504f93944..6d6849108f 100644 --- a/doc/changelogs/CHANGELOG_V22.md +++ b/doc/changelogs/CHANGELOG_V22.md @@ -9,6 +9,7 @@ +22.15.1
22.15.0
22.14.0
22.13.1
@@ -58,6 +59,23 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + + +## 2025-05-14, Version 22.15.1 'Jod' (LTS), @RafaelGSS + +This is a security release. + +### Notable Changes + +* (CVE-2025-23166) fix error handling on async crypto operation +* (CVE-2025-23165) add missing call to uv\_fs\_req\_cleanup + +### Commits + +* \[[`edaf54da00`](https://github.com/nodejs/node/commit/edaf54da00)] - **fs**: added test for missing call to uv\_fs\_req\_cleanup (Justin Nietzel) [#57811](https://github.com/nodejs/node/pull/57811) +* \[[`9f403e98ef`](https://github.com/nodejs/node/commit/9f403e98ef)] - **(CVE-2025-23165)** **fs**: add missing call to uv\_fs\_req\_cleanup (Justin Nietzel) [#57811](https://github.com/nodejs/node/pull/57811) +* \[[`f4494d38f1`](https://github.com/nodejs/node/commit/f4494d38f1)] - **(CVE-2025-23166)** **src**: fix error handling on async crypto operations (RafaelGSS) [nodejs-private/node-private#709](https://github.com/nodejs-private/node-private/pull/709) + ## 2025-04-23, Version 22.15.0 'Jod' (LTS), @UlisesGascon prepared by @RafaelGSS diff --git a/src/node_version.h b/src/node_version.h index fbbe8160af..8b0c38dc33 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -29,7 +29,7 @@ #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Jod" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) From 67d210790f092b4ff2b86210e63eba9453a9513a Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:22 +0200 Subject: [PATCH 06/16] Revert "agents: support `contCpuProfile` command in the GRPC interface" This reverts commit 3cc36a4ce549e8b64ff8d72f2d1ed8b336bdd956. --- agents/grpc/proto/reconfigure.proto | 1 - agents/grpc/src/grpc_agent.cc | 8 --- agents/grpc/src/proto/reconfigure.pb.cc | 78 ++++++++----------------- agents/grpc/src/proto/reconfigure.pb.h | 43 -------------- test/agents/test-grpc-reconfigure.mjs | 1 - 5 files changed, 23 insertions(+), 108 deletions(-) diff --git a/agents/grpc/proto/reconfigure.proto b/agents/grpc/proto/reconfigure.proto index 838c8f10d2..71aae221be 100644 --- a/agents/grpc/proto/reconfigure.proto +++ b/agents/grpc/proto/reconfigure.proto @@ -16,7 +16,6 @@ message ReconfigureBody { repeated string tags = 9; optional bool tracingEnabled = 10; optional uint32 tracingModulesBlacklist = 11; - optional bool contCpuProfile = 12; } message ReconfigureEvent { diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 0eefbe7903..5b2d0f195e 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -386,10 +386,6 @@ void PopulateReconfigureEvent(grpcagent::ReconfigureEvent* reconfigure_event, if (it != config.end()) { body->set_tracingmodulesblacklist(*it); } - it = config.find("contCpuProfile"); - if (it != config.end()) { - body->set_contcpuprofile(*it); - } } void PopulateStartupTimesEvent(grpcagent::StartupTimesEvent* st_events, @@ -1720,10 +1716,6 @@ void GrpcAgent::reconfigure(const grpcagent::CommandRequest& request) { out["tracingModulesBlacklist"] = body.tracingmodulesblacklist(); } - if (body.has_contcpuprofile()) { - out["contCpuProfile"] = body.contcpuprofile(); - } - DebugJSON("Reconfigure out: \n%s\n", out); UpdateConfig(out.dump()); diff --git a/agents/grpc/src/proto/reconfigure.pb.cc b/agents/grpc/src/proto/reconfigure.pb.cc index 8d14bef794..2acd39bd64 100644 --- a/agents/grpc/src/proto/reconfigure.pb.cc +++ b/agents/grpc/src/proto/reconfigure.pb.cc @@ -35,8 +35,7 @@ PROTOBUF_CONSTEXPR ReconfigureBody::ReconfigureBody( , /*decltype(_impl_.promisetracking_)*/false , /*decltype(_impl_.redactsnapshots_)*/false , /*decltype(_impl_.tracingenabled_)*/false - , /*decltype(_impl_.tracingmodulesblacklist_)*/0u - , /*decltype(_impl_.contcpuprofile_)*/false} {} + , /*decltype(_impl_.tracingmodulesblacklist_)*/0u} {} struct ReconfigureBodyDefaultTypeInternal { PROTOBUF_CONSTEXPR ReconfigureBodyDefaultTypeInternal() : _instance(::_pbi::ConstantInitialized{}) {} @@ -83,7 +82,6 @@ const uint32_t TableStruct_reconfigure_2eproto::offsets[] PROTOBUF_SECTION_VARIA PROTOBUF_FIELD_OFFSET(::grpcagent::ReconfigureBody, _impl_.tags_), PROTOBUF_FIELD_OFFSET(::grpcagent::ReconfigureBody, _impl_.tracingenabled_), PROTOBUF_FIELD_OFFSET(::grpcagent::ReconfigureBody, _impl_.tracingmodulesblacklist_), - PROTOBUF_FIELD_OFFSET(::grpcagent::ReconfigureBody, _impl_.contcpuprofile_), 3, 4, 5, @@ -95,7 +93,6 @@ const uint32_t TableStruct_reconfigure_2eproto::offsets[] PROTOBUF_SECTION_VARIA ~0u, 8, 9, - 10, ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::grpcagent::ReconfigureEvent, _internal_metadata_), ~0u, // no _extensions_ @@ -106,8 +103,8 @@ const uint32_t TableStruct_reconfigure_2eproto::offsets[] PROTOBUF_SECTION_VARIA PROTOBUF_FIELD_OFFSET(::grpcagent::ReconfigureEvent, _impl_.body_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - { 0, 18, -1, sizeof(::grpcagent::ReconfigureBody)}, - { 30, -1, -1, sizeof(::grpcagent::ReconfigureEvent)}, + { 0, 17, -1, sizeof(::grpcagent::ReconfigureBody)}, + { 28, -1, -1, sizeof(::grpcagent::ReconfigureEvent)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -117,7 +114,7 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_reconfigure_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\021reconfigure.proto\022\tgrpcagent\032\014common.p" - "roto\"\245\004\n\017ReconfigureBody\022!\n\024blockedLoopT" + "roto\"\365\003\n\017ReconfigureBody\022!\n\024blockedLoopT" "hreshold\030\001 \001(\004H\000\210\001\001\022\025\n\010interval\030\002 \001(\004H\001\210" "\001\001\022\031\n\014pauseMetrics\030\003 \001(\010H\002\210\001\001\022\034\n\017promise" "Tracking\030\004 \001(\010H\003\210\001\001\022\034\n\017redactSnapshots\030\005" @@ -125,22 +122,21 @@ const char descriptor_table_protodef_reconfigure_2eproto[] PROTOBUF_SECTION_VARI "Bucket\030\007 \001(\tH\006\210\001\001\022\027\n\nstatsdTags\030\010 \001(\tH\007\210" "\001\001\022\014\n\004tags\030\t \003(\t\022\033\n\016tracingEnabled\030\n \001(\010" "H\010\210\001\001\022$\n\027tracingModulesBlacklist\030\013 \001(\rH\t" - "\210\001\001\022\033\n\016contCpuProfile\030\014 \001(\010H\n\210\001\001B\027\n\025_blo" - "ckedLoopThresholdB\013\n\t_intervalB\017\n\r_pause" - "MetricsB\022\n\020_promiseTrackingB\022\n\020_redactSn" - "apshotsB\t\n\007_statsdB\017\n\r_statsdBucketB\r\n\013_" - "statsdTagsB\021\n\017_tracingEnabledB\032\n\030_tracin" - "gModulesBlacklistB\021\n\017_contCpuProfile\"g\n\020" - "ReconfigureEvent\022)\n\006common\030\001 \001(\0132\031.grpca" - "gent.CommonResponse\022(\n\004body\030\002 \001(\0132\032.grpc" - "agent.ReconfigureBodyb\006proto3" + "\210\001\001B\027\n\025_blockedLoopThresholdB\013\n\t_interva" + "lB\017\n\r_pauseMetricsB\022\n\020_promiseTrackingB\022" + "\n\020_redactSnapshotsB\t\n\007_statsdB\017\n\r_statsd" + "BucketB\r\n\013_statsdTagsB\021\n\017_tracingEnabled" + "B\032\n\030_tracingModulesBlacklist\"g\n\020Reconfig" + "ureEvent\022)\n\006common\030\001 \001(\0132\031.grpcagent.Com" + "monResponse\022(\n\004body\030\002 \001(\0132\032.grpcagent.Re" + "configureBodyb\006proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_reconfigure_2eproto_deps[1] = { &::descriptor_table_common_2eproto, }; static ::_pbi::once_flag descriptor_table_reconfigure_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_reconfigure_2eproto = { - false, false, 709, descriptor_table_protodef_reconfigure_2eproto, + false, false, 661, descriptor_table_protodef_reconfigure_2eproto, "reconfigure.proto", &descriptor_table_reconfigure_2eproto_once, descriptor_table_reconfigure_2eproto_deps, 1, 2, schemas, file_default_instances, TableStruct_reconfigure_2eproto::offsets, @@ -190,9 +186,6 @@ class ReconfigureBody::_Internal { static void set_has_tracingmodulesblacklist(HasBits* has_bits) { (*has_bits)[0] |= 512u; } - static void set_has_contcpuprofile(HasBits* has_bits) { - (*has_bits)[0] |= 1024u; - } }; ReconfigureBody::ReconfigureBody(::PROTOBUF_NAMESPACE_ID::Arena* arena, @@ -217,8 +210,7 @@ ReconfigureBody::ReconfigureBody(const ReconfigureBody& from) , decltype(_impl_.promisetracking_){} , decltype(_impl_.redactsnapshots_){} , decltype(_impl_.tracingenabled_){} - , decltype(_impl_.tracingmodulesblacklist_){} - , decltype(_impl_.contcpuprofile_){}}; + , decltype(_impl_.tracingmodulesblacklist_){}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _impl_.statsd_.InitDefault(); @@ -246,8 +238,8 @@ ReconfigureBody::ReconfigureBody(const ReconfigureBody& from) _this->GetArenaForAllocation()); } ::memcpy(&_impl_.blockedloopthreshold_, &from._impl_.blockedloopthreshold_, - static_cast(reinterpret_cast(&_impl_.contcpuprofile_) - - reinterpret_cast(&_impl_.blockedloopthreshold_)) + sizeof(_impl_.contcpuprofile_)); + static_cast(reinterpret_cast(&_impl_.tracingmodulesblacklist_) - + reinterpret_cast(&_impl_.blockedloopthreshold_)) + sizeof(_impl_.tracingmodulesblacklist_)); // @@protoc_insertion_point(copy_constructor:grpcagent.ReconfigureBody) } @@ -269,7 +261,6 @@ inline void ReconfigureBody::SharedCtor( , decltype(_impl_.redactsnapshots_){false} , decltype(_impl_.tracingenabled_){false} , decltype(_impl_.tracingmodulesblacklist_){0u} - , decltype(_impl_.contcpuprofile_){false} }; _impl_.statsd_.InitDefault(); #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING @@ -330,10 +321,10 @@ void ReconfigureBody::Clear() { reinterpret_cast(&_impl_.redactsnapshots_) - reinterpret_cast(&_impl_.blockedloopthreshold_)) + sizeof(_impl_.redactsnapshots_)); } - if (cached_has_bits & 0x00000700u) { + if (cached_has_bits & 0x00000300u) { ::memset(&_impl_.tracingenabled_, 0, static_cast( - reinterpret_cast(&_impl_.contcpuprofile_) - - reinterpret_cast(&_impl_.tracingenabled_)) + sizeof(_impl_.contcpuprofile_)); + reinterpret_cast(&_impl_.tracingmodulesblacklist_) - + reinterpret_cast(&_impl_.tracingenabled_)) + sizeof(_impl_.tracingmodulesblacklist_)); } _impl_._has_bits_.Clear(); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); @@ -454,15 +445,6 @@ const char* ReconfigureBody::_InternalParse(const char* ptr, ::_pbi::ParseContex } else goto handle_unusual; continue; - // optional bool contCpuProfile = 12; - case 12: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 96)) { - _Internal::set_has_contcpuprofile(&has_bits); - _impl_.contcpuprofile_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); - CHK_(ptr); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -575,12 +557,6 @@ uint8_t* ReconfigureBody::_InternalSerialize( target = ::_pbi::WireFormatLite::WriteUInt32ToArray(11, this->_internal_tracingmodulesblacklist(), target); } - // optional bool contCpuProfile = 12; - if (_internal_has_contcpuprofile()) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteBoolToArray(12, this->_internal_contcpuprofile(), target); - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -654,7 +630,7 @@ size_t ReconfigureBody::ByteSizeLong() const { } } - if (cached_has_bits & 0x00000700u) { + if (cached_has_bits & 0x00000300u) { // optional bool tracingEnabled = 10; if (cached_has_bits & 0x00000100u) { total_size += 1 + 1; @@ -665,11 +641,6 @@ size_t ReconfigureBody::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::UInt32SizePlusOne(this->_internal_tracingmodulesblacklist()); } - // optional bool contCpuProfile = 12; - if (cached_has_bits & 0x00000400u) { - total_size += 1 + 1; - } - } return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); } @@ -718,16 +689,13 @@ void ReconfigureBody::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const } _this->_impl_._has_bits_[0] |= cached_has_bits; } - if (cached_has_bits & 0x00000700u) { + if (cached_has_bits & 0x00000300u) { if (cached_has_bits & 0x00000100u) { _this->_impl_.tracingenabled_ = from._impl_.tracingenabled_; } if (cached_has_bits & 0x00000200u) { _this->_impl_.tracingmodulesblacklist_ = from._impl_.tracingmodulesblacklist_; } - if (cached_has_bits & 0x00000400u) { - _this->_impl_.contcpuprofile_ = from._impl_.contcpuprofile_; - } _this->_impl_._has_bits_[0] |= cached_has_bits; } _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); @@ -764,8 +732,8 @@ void ReconfigureBody::InternalSwap(ReconfigureBody* other) { &other->_impl_.statsdtags_, rhs_arena ); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(ReconfigureBody, _impl_.contcpuprofile_) - + sizeof(ReconfigureBody::_impl_.contcpuprofile_) + PROTOBUF_FIELD_OFFSET(ReconfigureBody, _impl_.tracingmodulesblacklist_) + + sizeof(ReconfigureBody::_impl_.tracingmodulesblacklist_) - PROTOBUF_FIELD_OFFSET(ReconfigureBody, _impl_.blockedloopthreshold_)>( reinterpret_cast(&_impl_.blockedloopthreshold_), reinterpret_cast(&other->_impl_.blockedloopthreshold_)); diff --git a/agents/grpc/src/proto/reconfigure.pb.h b/agents/grpc/src/proto/reconfigure.pb.h index 9d834c72a8..1528da8bd2 100644 --- a/agents/grpc/src/proto/reconfigure.pb.h +++ b/agents/grpc/src/proto/reconfigure.pb.h @@ -193,7 +193,6 @@ class ReconfigureBody final : kRedactSnapshotsFieldNumber = 5, kTracingEnabledFieldNumber = 10, kTracingModulesBlacklistFieldNumber = 11, - kContCpuProfileFieldNumber = 12, }; // repeated string tags = 9; int tags_size() const; @@ -364,19 +363,6 @@ class ReconfigureBody final : void _internal_set_tracingmodulesblacklist(uint32_t value); public: - // optional bool contCpuProfile = 12; - bool has_contcpuprofile() const; - private: - bool _internal_has_contcpuprofile() const; - public: - void clear_contcpuprofile(); - bool contcpuprofile() const; - void set_contcpuprofile(bool value); - private: - bool _internal_contcpuprofile() const; - void _internal_set_contcpuprofile(bool value); - public: - // @@protoc_insertion_point(class_scope:grpcagent.ReconfigureBody) private: class _Internal; @@ -398,7 +384,6 @@ class ReconfigureBody final : bool redactsnapshots_; bool tracingenabled_; uint32_t tracingmodulesblacklist_; - bool contcpuprofile_; }; union { Impl_ _impl_; }; friend struct ::TableStruct_reconfigure_2eproto; @@ -1066,34 +1051,6 @@ inline void ReconfigureBody::set_tracingmodulesblacklist(uint32_t value) { // @@protoc_insertion_point(field_set:grpcagent.ReconfigureBody.tracingModulesBlacklist) } -// optional bool contCpuProfile = 12; -inline bool ReconfigureBody::_internal_has_contcpuprofile() const { - bool value = (_impl_._has_bits_[0] & 0x00000400u) != 0; - return value; -} -inline bool ReconfigureBody::has_contcpuprofile() const { - return _internal_has_contcpuprofile(); -} -inline void ReconfigureBody::clear_contcpuprofile() { - _impl_.contcpuprofile_ = false; - _impl_._has_bits_[0] &= ~0x00000400u; -} -inline bool ReconfigureBody::_internal_contcpuprofile() const { - return _impl_.contcpuprofile_; -} -inline bool ReconfigureBody::contcpuprofile() const { - // @@protoc_insertion_point(field_get:grpcagent.ReconfigureBody.contCpuProfile) - return _internal_contcpuprofile(); -} -inline void ReconfigureBody::_internal_set_contcpuprofile(bool value) { - _impl_._has_bits_[0] |= 0x00000400u; - _impl_.contcpuprofile_ = value; -} -inline void ReconfigureBody::set_contcpuprofile(bool value) { - _internal_set_contcpuprofile(value); - // @@protoc_insertion_point(field_set:grpcagent.ReconfigureBody.contCpuProfile) -} - // ------------------------------------------------------------------- // ReconfigureEvent diff --git a/test/agents/test-grpc-reconfigure.mjs b/test/agents/test-grpc-reconfigure.mjs index 31a6f3642c..0f26c6dd6f 100644 --- a/test/agents/test-grpc-reconfigure.mjs +++ b/test/agents/test-grpc-reconfigure.mjs @@ -113,7 +113,6 @@ const newConfigs = [ [ 'tags', [ 'tag1', 'tag2' ] ], [ 'tracingEnabled', true ], [ 'tracingModulesBlacklist', 1 ], - [ 'contCpuProfile', true ], ]; tests.push({ From 4a015a9466173b20ba7ba512b11abf866dc46269 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:27 +0200 Subject: [PATCH 07/16] Revert "agents: fix cont profiling timestamp calculation" This reverts commit c2bc3e451368e6efa440aedad4a05c11300d5938. --- agents/grpc/src/grpc_agent.cc | 8 +++----- test/agents/test-grpc-continuous-profile.mjs | 15 +-------------- test/common/nsolid-grpc-agent/server.mjs | 5 +---- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 5b2d0f195e..8c611f6118 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -1534,12 +1534,10 @@ void GrpcAgent::got_continuous_profile( // Check if the profile is complete bool profileStreamComplete = stor.profile.length() == 0; if (profileStreamComplete) { - uint64_t now = uv_hrtime() - performance::performance_process_start; - uint64_t start = start_timestamp - performance::performance_process_start; double start_ts = - performance_process_start_timestamp + start / 1e6; - double end_ts = performance_process_start_timestamp + now / 1e6; - uint64_t duration = (now - start) / 1e6; + performance_process_start_timestamp + start_timestamp / 1e6; + double end_ts = performance_process_start_timestamp + uv_hrtime() / 1e6; + uint64_t duration = (uv_hrtime() - start_timestamp) / 1e6; // Create complete profile grpcagent::Asset asset; PopulateCommon(asset.mutable_common(), diff --git a/test/agents/test-grpc-continuous-profile.mjs b/test/agents/test-grpc-continuous-profile.mjs index ea43321bc6..eb0bc226f3 100644 --- a/test/agents/test-grpc-continuous-profile.mjs +++ b/test/agents/test-grpc-continuous-profile.mjs @@ -9,12 +9,11 @@ import { const { validateArray, - validateNumber, validateObject, validateString, } = validators; -function checkContinuousProfileData(profile, metadata, agentId, options, interval = 100) { +function checkContinuousProfileData(profile, metadata, agentId, options) { console.dir(profile, { depth: null }); validateString(profile.common.requestId, 'requestId'); assert.ok(profile.common.requestId.length > 0); @@ -35,18 +34,6 @@ function checkContinuousProfileData(profile, metadata, agentId, options, interva const duration = BigInt(profile.duration); assert.ok(duration > 0); - validateNumber(profile.startTs, 'profile.startTs'); - validateNumber(profile.endTs, 'profile.endTs'); - // Make sure the start and end timestamps are correctly calculated - const diff = profile.endTs - profile.startTs; - assert.ok(diff > 0); - assert.ok(diff < 5 * interval); - const now = Date.now(); - assert.ok(now - profile.startTs > 0); - assert.ok(now - profile.startTs < 5000); - assert.ok(now - profile.endTs > 0); - assert.ok(now - profile.endTs < 5000); - validateString(profile.data, 'profile.data'); const profileData = JSON.parse(profile.data); validateObject(profileData, 'profileData'); diff --git a/test/common/nsolid-grpc-agent/server.mjs b/test/common/nsolid-grpc-agent/server.mjs index 0b91ee5a52..6604e39331 100644 --- a/test/common/nsolid-grpc-agent/server.mjs +++ b/test/common/nsolid-grpc-agent/server.mjs @@ -127,9 +127,8 @@ async function startServer(cb) { metadata: null, data: '', duration: null, - startTs: null, - endTs: null, }; + call._my_data = ''; call.on('data', (data) => { console.log('[ExportContinuousProfile] data', data.data.length); asset.common = data.common; @@ -138,8 +137,6 @@ async function startServer(cb) { asset.data += data.data; if (data.complete) { asset.duration = data.duration; - asset.startTs = data.startTs; - asset.endTs = data.endTs; } }); call.on('error', (err) => { From 9a01f03d53303f3932fe72bbead07ed5dadc2f0d Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:29 +0200 Subject: [PATCH 08/16] Revert "test: add gRPC continuous profiling tests" This reverts commit 24fe19d1010bac19a9df0f68e26e380cc5c246e7. --- test/agents/test-grpc-continuous-profile.mjs | 344 ------------------- test/common/nsolid-grpc-agent/server.mjs | 30 -- 2 files changed, 374 deletions(-) delete mode 100644 test/agents/test-grpc-continuous-profile.mjs diff --git a/test/agents/test-grpc-continuous-profile.mjs b/test/agents/test-grpc-continuous-profile.mjs deleted file mode 100644 index eb0bc226f3..0000000000 --- a/test/agents/test-grpc-continuous-profile.mjs +++ /dev/null @@ -1,344 +0,0 @@ -// Flags: --expose-internals -import { mustSucceed } from '../common/index.mjs'; -import assert from 'node:assert'; -import validators from 'internal/validators'; -import { - GRPCServer, - TestClient, -} from '../common/nsolid-grpc-agent/index.js'; - -const { - validateArray, - validateObject, - validateString, -} = validators; - -function checkContinuousProfileData(profile, metadata, agentId, options) { - console.dir(profile, { depth: null }); - validateString(profile.common.requestId, 'requestId'); - assert.ok(profile.common.requestId.length > 0); - - assert.strictEqual(profile.common.command, 'profile'); - validateObject(profile.common.recorded, 'recorded'); - const recSeconds = BigInt(profile.common.recorded.seconds); - assert.ok(recSeconds); - const recNanoSecs = BigInt(profile.common.recorded.nanoseconds); - assert.ok(recNanoSecs); - - assert.strictEqual(profile.threadId, `${options.threadId}`); - if (options.metadata) { - assert.deepStrictEqual(profile.metadata, options.metadata); - } - - validateString(profile.duration, 'profile.duration'); - const duration = BigInt(profile.duration); - assert.ok(duration > 0); - - validateString(profile.data, 'profile.data'); - const profileData = JSON.parse(profile.data); - validateObject(profileData, 'profileData'); - - validateArray(metadata['user-agent'], 'metadata.user-agent'); - validateString(metadata['user-agent'][0], 'metadata.user-agent[0]'); - assert.strictEqual(metadata['nsolid-agent-id'][0], agentId); -} - -function checkProfileError(profile, metadata, requestId, agentId, code, msg) { - console.dir(profile, { depth: null }); - assert.strictEqual(profile.common.requestId, requestId); - assert.strictEqual(profile.common.command, 'profile'); - // From here check at least that all the fields are present - validateObject(profile.common.recorded, 'recorded'); - const recSeconds = BigInt(profile.common.recorded.seconds); - assert.ok(recSeconds); - const recNanoSecs = BigInt(profile.common.recorded.nanoseconds); - assert.ok(recNanoSecs); - - validateObject(profile.common.error, 'error'); - assert.strictEqual(profile.common.error.code, code); - assert.strictEqual(profile.common.error.message, msg); - - validateArray(metadata['user-agent'], 'metadata.user-agent'); - validateString(metadata['user-agent'][0], 'metadata.user-agent[0]'); - assert.strictEqual(metadata['nsolid-agent-id'][0], agentId); -} - -const tests = []; - -tests.push({ - name: 'should start continuous CPU profiling when enabled', - test: async () => { - return new Promise((resolve) => { - const grpcServer = new GRPCServer(); - grpcServer.start(mustSucceed(async (port) => { - let times = 0; - grpcServer.on('profile', async (data) => { - checkContinuousProfileData(data.msg, data.metadata, agentId, options); - times++; - if (times === 2) { - const diff = process.hrtime(startTime); - console.log('diff', diff); - assert.strictEqual(diff[0], 0); - assert.ok(diff[1] > 200000000); - await child.shutdown(0); - grpcServer.close(); - resolve(); - } - }); - const env = { - NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', - NSOLID_GRPC_INSECURE: 1, - NSOLID_GRPC: `localhost:${port}`, - NSOLID_CONT_CPU_PROFILE: 'true', - NSOLID_CONT_CPU_PROFILE_INTERVAL: '100', // 100ms for faster testing - }; - - const opts = { - stdio: ['inherit', 'inherit', 'inherit', 'ipc'], - env, - }; - - let startTime = process.hrtime(); - const child = new TestClient([], opts); - const agentId = await child.id(); - const options = { - threadId: 0, - }; - })); - }); - }, -}); - -tests.push({ - name: 'should also work with worker threads', - test: async () => { - return new Promise((resolve) => { - const grpcServer = new GRPCServer(); - grpcServer.start(mustSucceed(async (port) => { - let timesMainThread = 0; - let timesWorker = 0; - grpcServer.on('profile', async (data) => { - if (data.msg.threadId === '0') { - timesMainThread++; - } else { - assert.strictEqual(data.msg.threadId, `${wid}`); - timesWorker++; - } - - const options = { - threadId: data.msg.threadId, - }; - - checkContinuousProfileData(data.msg, data.metadata, agentId, options); - if (timesMainThread === 2 && timesWorker === 2) { - const diff = process.hrtime(startTime); - console.log('diff', diff); - assert.strictEqual(diff[0], 0); - assert.ok(diff[1] > 200000000); - await child.shutdown(0); - grpcServer.close(); - resolve(); - } - }); - const env = { - NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', - NSOLID_GRPC_INSECURE: 1, - NSOLID_GRPC: `localhost:${port}`, - NSOLID_CONT_CPU_PROFILE: 'true', - NSOLID_CONT_CPU_PROFILE_INTERVAL: '100', // 100ms for faster testing - }; - - const opts = { - stdio: ['inherit', 'inherit', 'inherit', 'ipc'], - env, - }; - - let startTime = process.hrtime(); - const child = new TestClient([ '-w', 1 ], opts); - const agentId = await child.id(); - const workers = await child.workers(); - const wid = workers[0]; - })); - }); - }, -}); - -tests.push({ - name: 'should start continuous CPU profiling after enabling', - test: async () => { - return new Promise((resolve) => { - const grpcServer = new GRPCServer(); - grpcServer.start(mustSucceed(async (port) => { - let times = 0; - grpcServer.on('profile', async (data) => { - checkContinuousProfileData(data.msg, data.metadata, agentId, options); - times++; - if (times === 2) { - const diff = process.hrtime(startTime); - console.log('diff', diff); - assert.strictEqual(diff[0], 0); - assert.ok(diff[1] > 200000000); - await child.shutdown(0); - grpcServer.close(); - resolve(); - } - }); - const env = { - NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', - NSOLID_GRPC_INSECURE: 1, - NSOLID_GRPC: `localhost:${port}`, - }; - - const opts = { - stdio: ['inherit', 'inherit', 'inherit', 'ipc'], - env, - }; - - let startTime = process.hrtime(); - const child = new TestClient([], opts); - const agentId = await child.id(); - await child.config({ - contCpuProfile: true, - contCpuProfileInterval: 100, // 100ms for faster testing - }); - const options = { - threadId: 0, - }; - })); - }); - }, -}); - -tests.push({ - name: 'should enable continuous profiling during an active CPU profile', - test: async () => { - return new Promise((resolve) => { - const grpcServer = new GRPCServer(); - grpcServer.start(mustSucceed(async (port) => { - let continuousProfilesReceived = 0; - - // Start TestClient without continuous profiling - const env = { - NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', - NSOLID_GRPC_INSECURE: 1, - NSOLID_GRPC: `localhost:${port}`, - }; - - const opts = { - stdio: ['inherit', 'inherit', 'inherit', 'ipc'], - env, - }; - - const child = new TestClient([], opts); - const agentId = await child.id(); - - // Start a CPU profile with a longer duration to give us time to enable continuous profiling - console.log('Starting CPU profile'); - const options = { - duration: 1000, - threadId: 0, - }; - - await grpcServer.cpuProfile(agentId, options); - - grpcServer.on('profile', async (data) => { - // This is a continuous profile - continuousProfilesReceived++; - console.log(`Received continuous profile #${continuousProfilesReceived}`); - checkContinuousProfileData(data.msg, data.metadata, agentId, options); - if (continuousProfilesReceived >= 2) { - // We've received both the requested profile and at least 2 continuous profiles - await child.shutdown(0); - grpcServer.close(); - resolve(); - } - }); - - // Wait a short time to ensure the profile has started - setTimeout(async () => { - console.log('Enabling continuous profiling during CPU profile'); - // Enable continuous profiling by updating the configuration - await child.config({ - contCpuProfile: true, - contCpuProfileInterval: 100, // 100ms for faster testing - }); - }, 200); - })); - }); - }, -}); - -tests.push({ - name: 'should not allow manual CPU profiling when continuous CPU profiling is enabled', - test: async () => { - return new Promise((resolve) => { - const grpcServer = new GRPCServer(); - grpcServer.start(mustSucceed(async (port) => { - // Set up continuous profile handler - let continuousProfilesReceived = 0; - grpcServer.on('profile', async (data) => { - if (data.continuous) { - continuousProfilesReceived++; - console.log(`Received continuous profile #${continuousProfilesReceived}`); - const options = { - threadId: 0, - }; - - checkContinuousProfileData(data.msg, data.metadata, agentId, options); - if (continuousProfilesReceived >= 2 && profileErrorTested) { - await child.shutdown(0); - grpcServer.close(); - resolve(); - } - } - }); - - // Start TestClient with continuous profiling enabled - const env = { - NODE_DEBUG_NATIVE: 'nsolid_grpc_agent', - NSOLID_GRPC_INSECURE: 1, - NSOLID_GRPC: `localhost:${port}`, - NSOLID_CONT_CPU_PROFILE: 'true', - NSOLID_CONT_CPU_PROFILE_INTERVAL: '100', // 100ms for faster testing - }; - - const opts = { - stdio: ['inherit', 'inherit', 'inherit', 'ipc'], - env, - }; - - const child = new TestClient([], opts); - const agentId = await child.id(); - let profileErrorTested = false; - - // Wait for continuous profiling to start - setTimeout(async () => { - console.log('Attempting manual CPU profile while continuous profiling is active'); - // Try to perform a manual CPU profile - this should fail with EInProgressError - const options = { - duration: 100, - threadId: 0, - }; - const { data, requestId } = await grpcServer.cpuProfile(agentId, options); - // Verify the error response - checkProfileError( - data.msg, - data.metadata, - requestId, - agentId, - 409, // 409 Conflict - Operation already in progress - 'Operation already in progress(1001)', - ); - - console.log('Received expected error for manual CPU profile'); - profileErrorTested = true; - }, 400); - })); - }); - }, -}); - -for (const { name, test } of tests) { - console.log(`[continuous profile] ${name}`); - await test(); -} diff --git a/test/common/nsolid-grpc-agent/server.mjs b/test/common/nsolid-grpc-agent/server.mjs index 6604e39331..977e767f6e 100644 --- a/test/common/nsolid-grpc-agent/server.mjs +++ b/test/common/nsolid-grpc-agent/server.mjs @@ -118,36 +118,6 @@ async function startServer(cb) { console.dir(call.metadata, { depth: null }); callback(null, {}); }, - ExportContinuousProfile: async (call) => { - console.log('ExportContinuousProfile'); - console.dir(call.metadata, { depth: null }); - const asset = { - common: null, - threadId: null, - metadata: null, - data: '', - duration: null, - }; - call._my_data = ''; - call.on('data', (data) => { - console.log('[ExportContinuousProfile] data', data.data.length); - asset.common = data.common; - asset.threadId = data.threadId; - asset.metadata = data.metadata; - asset.data += data.data; - if (data.complete) { - asset.duration = data.duration; - } - }); - call.on('error', (err) => { - console.error('[ExportContinuousProfile] error', err); - }); - call.on('end', () => { - call.end(); - process.send({ type: asset.common.command, - data: { msg: asset, metadata: call.metadata, continuous: true } }); - }); - }, ExportExit: (call, callback) => { // Extract data from the request object console.dir(call.request, { depth: null }); From 9d2cfe3116225955b6b891bd8ffb70b10a00829b Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:31 +0200 Subject: [PATCH 09/16] Revert "agents: add continuous profiling to gRPC agent" This reverts commit 6566a019d006c051709dad1bed589bb5b05ca5ca. --- agents/grpc/src/grpc_agent.cc | 177 ++-------------------------------- agents/grpc/src/grpc_agent.h | 11 +-- 2 files changed, 8 insertions(+), 180 deletions(-) diff --git a/agents/grpc/src/grpc_agent.cc b/agents/grpc/src/grpc_agent.cc index 8c611f6118..663551bdd0 100644 --- a/agents/grpc/src/grpc_agent.cc +++ b/agents/grpc/src/grpc_agent.cc @@ -572,16 +572,12 @@ int GrpcAgent::stop(bool profile_stopped) { } else { Debug("Stopping gRPC Agent(2): %d\n", profile_stopped); if (profile_stopped) { - auto it = config_.find("contCpuProfile"); - if (it == config_.end() || it->get() == false) { - profile_on_exit_ = profile_stopped; - } - + profile_on_exit_ = profile_stopped; // Wait here until the are no remaining profiles to be completed uv_mutex_lock(&stop_lock_); - while (pending_profiles()) { + do { uv_cond_wait(&stop_cond_, &stop_lock_); - } + } while (pending_profiles()); uv_mutex_unlock(&stop_lock_); } @@ -805,17 +801,6 @@ int GrpcAgent::start_heap_snapshot_from_js( } } -/*static*/ void GrpcAgent::cont_profiler_cb( - const ProfileCollector::ProfileQStor& profile_data, - WeakGrpcAgent agent_wp) { - SharedGrpcAgent agent = agent_wp.lock(); - if (agent == nullptr) { - return; - } - - agent->cont_profile_queue_->enqueue(profile_data); -} - void GrpcAgent::env_creation_cb_(SharedEnvInst envinst, WeakGrpcAgent agent_wp) { SharedGrpcAgent agent = agent_wp.lock(); @@ -1241,22 +1226,6 @@ void GrpcAgent::do_start() { }, weak_from_this()); - cont_profile_queue_ = - AsyncTSQueue::create( - &loop_, - +[](ProfileCollector::ProfileQStor&& stor, WeakGrpcAgent agent_wp) { - SharedGrpcAgent agent = agent_wp.lock(); - if (agent == nullptr) { - return; - } - - agent->got_continuous_profile(std::move(stor)); - }, - weak_from_this()); - - EnvList::Inst()->GetContinuousProfiler()->RegisterHook(cont_profiler_cb, - weak_from_this()); - ready_ = true; if (hooks_init_ == false) { @@ -1297,7 +1266,6 @@ void GrpcAgent::do_stop() { env_msg_.close(); shutdown_.close(); start_profiling_msg_.close(); - cont_profile_queue_.reset(); } void GrpcAgent::got_spans(const UniqRecordables& recordables) { @@ -1375,11 +1343,9 @@ void GrpcAgent::got_proc_metrics() { void GrpcAgent::got_profile(const ProfileCollector::ProfileQStor& stor) { google::protobuf::Struct metadata; uint64_t thread_id; - uint64_t start_timestamp; - std::visit([&metadata, &thread_id, &start_timestamp](auto& opt) { + std::visit([&metadata, &thread_id](auto& opt) { thread_id = opt.thread_id; metadata = opt.metadata_pb; - start_timestamp = opt.start_timestamp; }, stor.options); nsuv::ns_mutex::scoped_lock lock(profile_state_lock_); @@ -1426,7 +1392,6 @@ void GrpcAgent::got_profile(const ProfileCollector::ProfileQStor& stor) { return; } - const uint64_t duration = (uv_hrtime() - start_timestamp) / 1e6; grpcagent::Asset asset; PopulateCommon(asset.mutable_common(), ProfileTypeStr[stor.type], @@ -1434,7 +1399,7 @@ void GrpcAgent::got_profile(const ProfileCollector::ProfileQStor& stor) { asset.set_thread_id(thread_id); asset.mutable_metadata()->CopyFrom(metadata); asset.set_complete(true); - asset.set_duration(duration); + asset.set_duration(uv_now(&loop_) - prof_stor.timestamp); prof_stor.stream->Write(std::move(asset)); prof_stor.stream->WritesDone(); } else { @@ -1485,123 +1450,6 @@ void GrpcAgent::got_profile(const ProfileCollector::ProfileQStor& stor) { } } -void GrpcAgent::got_continuous_profile( - const ProfileCollector::ProfileQStor& stor) { - static double performance_process_start_timestamp = - performance::performance_process_start_timestamp / 1e3; - google::protobuf::Struct metadata; - uint64_t thread_id; - uint64_t start_timestamp; - std::visit([&metadata, &thread_id, &start_timestamp](auto& opt) { - thread_id = opt.thread_id; - metadata = opt.metadata_pb; - start_timestamp = opt.start_timestamp; - }, stor.options); - - Debug("got_continuous_profile. len: %ld, status: %d. thread_id: %ld\n", - stor.profile.length(), - stor.status, - thread_id); - - if (stor.status < 0) { - // Log error but don't send error message back for continuous profiles - auto error = translate_error(stor.status); - Debug("Continuous profile error: %d\n", static_cast(error)); - return; - } - - // Look if entry in cont_profile_stor_map_. If not create one - auto it = cont_profile_stor_map_.find(thread_id); - if (it == cont_profile_stor_map_.end()) { - // Create a new stream for the continuous profile - AssetStream* stream = new AssetStream(nsolid_service_stub_.get(), - AssetStor{stor.type, thread_id}, - weak_from_this(), - agent_id_, - saas(), - EXPORT_CONTINUOUS_PROFILE); - it = cont_profile_stor_map_.emplace(thread_id, ProfileStor{ - utils::generate_unique_id(), - stream, - stor.options - }).first; - } - - const ProfileStor& profile_stor = it->second; - const std::string& req_id = profile_stor.req_id; - AssetStream* stream = profile_stor.stream; - - // Check if the profile is complete - bool profileStreamComplete = stor.profile.length() == 0; - if (profileStreamComplete) { - double start_ts = - performance_process_start_timestamp + start_timestamp / 1e6; - double end_ts = performance_process_start_timestamp + uv_hrtime() / 1e6; - uint64_t duration = (uv_hrtime() - start_timestamp) / 1e6; - // Create complete profile - grpcagent::Asset asset; - PopulateCommon(asset.mutable_common(), - ProfileTypeStr[stor.type], - req_id.c_str()); - asset.set_thread_id(thread_id); - asset.mutable_metadata()->CopyFrom(metadata); - asset.set_complete(true); - asset.set_duration(duration); - asset.set_start_ts(start_ts); - asset.set_end_ts(end_ts); - - // Remove the entry from the map - cont_profile_stor_map_.erase(it); - - // Send the complete profile - stream->Write(std::move(asset)); - stream->WritesDone(); - return; - } - - // Send profile chunks - grpcagent::Asset asset; - PopulateCommon(asset.mutable_common(), - ProfileTypeStr[stor.type], - req_id.c_str()); - asset.set_thread_id(thread_id); - asset.mutable_metadata()->CopyFrom(metadata); - asset.set_data(stor.profile); - - size_t asset_size = asset.ByteSizeLong(); - if (asset_size > GRPC_MAX_SIZE) { - // Split the data into chunks - Debug("Continuous profile size larger than supported (%ld > %ld): " - "splitting profile into chunks\n", asset_size, GRPC_MAX_SIZE); - size_t prof_size = stor.profile.size(); - size_t rest = asset_size - prof_size; - size_t offset = 0; - size_t chunk_size = GRPC_MAX_SIZE - rest - 100; - - while (offset < prof_size) { - grpcagent::Asset chunk_asset; - PopulateCommon(chunk_asset.mutable_common(), - ProfileTypeStr[stor.type], - req_id.c_str()); - chunk_asset.set_thread_id(thread_id); - chunk_asset.mutable_metadata()->CopyFrom(metadata); - - if (offset + chunk_size > prof_size) { - chunk_size = prof_size - offset; - } - - chunk_asset.set_data(stor.profile.substr(offset, chunk_size)); - - Debug("Sending continuous profile chunk of size: %ld\n", - chunk_asset.ByteSizeLong()); - stream->Write(std::move(chunk_asset)); - offset += chunk_size; - } - } else { - stream->Write(std::move(asset)); - } -} - void GrpcAgent::handle_command_request(CommandRequestStor&& req) { const grpcagent::CommandRequest& request = req.request; Debug("Command Received: %s\n", request.DebugString().c_str()); @@ -2055,16 +1903,6 @@ ErrorType GrpcAgent::do_start_prof_init( uint64_t thread_id = args.thread_id(); uint64_t duration = args.duration(); StartProfiling start_profiling = nullptr; - - // Check if continuous profiling is enabled for this profile type - if (type == ProfileType::kCpu) { - auto it = config_.find("contCpuProfile"); - if (it != config_.end() && it->get() == true) { - // Continuous CPU profiling is enabled, don't allow manual CPU profiles - return ErrorType::EInProgressError; - } - } - switch (type) { case ProfileType::kCpu: start_profiling = &GrpcAgent::do_start_cpu_prof; @@ -2087,12 +1925,12 @@ ErrorType GrpcAgent::do_start_prof_init( opt.thread_id = thread_id; opt.duration = duration; opt.metadata_pb = std::move(args.metadata()); - opt.start_timestamp = uv_hrtime(); }, options); nsuv::ns_mutex::scoped_lock lock(profile_state_lock_); ProfileState& profile_state = profile_state_[type]; ProfileStor stor{ req.requestid(), + uv_now(&loop_), nullptr, options }; auto iter = profile_state.pending_profiles_map.emplace(thread_id, @@ -2124,8 +1962,7 @@ ErrorType GrpcAgent::do_start_prof_end(ErrorType err, AssetStor{type, thread_id}, weak_from_this(), agent_id_, - saas(), - EXPORT_ASSET); + saas()); if (err != ErrorType::ESuccess) { send_asset_error(type, req_id, std::move(opts), stream, err); return err; diff --git a/agents/grpc/src/grpc_agent.h b/agents/grpc/src/grpc_agent.h index dd43346bf8..0b422fe3eb 100644 --- a/agents/grpc/src/grpc_agent.h +++ b/agents/grpc/src/grpc_agent.h @@ -118,6 +118,7 @@ class GrpcAgent: public std::enable_shared_from_this, struct ProfileStor { std::string req_id; + uint64_t timestamp; AssetStream* stream; ProfileOptions options; bool done = false; @@ -165,9 +166,6 @@ class GrpcAgent: public std::enable_shared_from_this, static void config_msg_cb_(nsuv::ns_async*, WeakGrpcAgent); - static void cont_profiler_cb(const ProfileCollector::ProfileQStor&, - WeakGrpcAgent); - static void env_creation_cb_(SharedEnvInst, WeakGrpcAgent); static void env_deletion_cb_(SharedEnvInst, WeakGrpcAgent); @@ -248,8 +246,6 @@ class GrpcAgent: public std::enable_shared_from_this, void got_profile(const ProfileCollector::ProfileQStor& stor); - void got_continuous_profile(const ProfileCollector::ProfileQStor& stor); - void got_spans(const UniqRecordables& spans); void handle_command_request(CommandRequestStor&& req); @@ -355,11 +351,6 @@ class GrpcAgent: public std::enable_shared_from_this, nsuv::ns_async start_profiling_msg_; TSQueue start_profiling_msg_q_; - // Continuous Profiling - ProfileStorMap cont_profile_stor_map_; - std::shared_ptr> - cont_profile_queue_; - // For the grpc client std::unique_ptr nsolid_service_stub_; std::unique_ptr command_stream_; From 9bb461b42437d74a685404c8f7bfaf1ab6a2a607 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:33 +0200 Subject: [PATCH 10/16] Revert "agents: grow AssetStream to support cont profiling" This reverts commit 4488fb5d87f896b15b40e282dacb16d20a80faf0. --- agents/grpc/src/asset_stream.cc | 15 +++------------ agents/grpc/src/asset_stream.h | 9 +-------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/agents/grpc/src/asset_stream.cc b/agents/grpc/src/asset_stream.cc index a9136e7e25..d3f6af9947 100644 --- a/agents/grpc/src/asset_stream.cc +++ b/agents/grpc/src/asset_stream.cc @@ -20,22 +20,14 @@ AssetStream::AssetStream( AssetStor&& stor, std::weak_ptr observer, const std::string& agent_id, - const std::string& saas, - AssetStreamRpcType rpc_type): observer_(observer), - stor_(std::move(stor)) { + const std::string& saas): observer_(observer), + stor_(std::move(stor)) { ASSERT_EQ(0, lock_.init(true)); context_.AddMetadata("nsolid-agent-id", agent_id); if (!saas.empty()) { context_.AddMetadata("nsolid-saas-token", saas); } - - // Call the appropriate RPC method based on the rpc_type parameter - if (rpc_type == EXPORT_CONTINUOUS_PROFILE) { - stub->async()->ExportContinuousProfile(&context_, &event_response_, this); - } else { - stub->async()->ExportAsset(&context_, &event_response_, this); - } - + stub->async()->ExportAsset(&context_, &event_response_, this); AddHold(); StartCall(); } @@ -94,7 +86,6 @@ void AssetStream::Write(grpcagent::Asset&& asset) { void AssetStream::WritesDone(bool) { nsuv::ns_mutex::scoped_lock lock(lock_); - ASSERT(write_state_.write_done_called == false); write_state_.write_done_called = true; NextWrite(); } diff --git a/agents/grpc/src/asset_stream.h b/agents/grpc/src/asset_stream.h index d561fc2d2e..cde83e661c 100644 --- a/agents/grpc/src/asset_stream.h +++ b/agents/grpc/src/asset_stream.h @@ -15,12 +15,6 @@ namespace grpc { // Predeclarations class AssetStream; -// RPC type enum for specifying which RPC method to use -enum AssetStreamRpcType { - EXPORT_ASSET, - EXPORT_CONTINUOUS_PROFILE -}; - struct AssetStor { ProfileType type; uint64_t thread_id; @@ -47,8 +41,7 @@ class AssetStream: public ::grpc::ClientWriteReactor { AssetStor&& stor, std::weak_ptr observer, const std::string& agent_id, - const std::string& saas, - AssetStreamRpcType rpc_type = EXPORT_ASSET); + const std::string& saas); ~AssetStream(); From a82c77d463969f7c9aa4c1ec8b990916cfa4a1f0 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:35 +0200 Subject: [PATCH 11/16] Revert "agents: add ExportContinuousProfile rpc" This reverts commit 6f4153cbfeaa68ff8c43e905a1e445b4fa8d7c08. --- agents/grpc/proto/asset.proto | 4 +- agents/grpc/proto/nsolid_service.proto | 1 - agents/grpc/src/proto/asset.pb.cc | 84 +---- agents/grpc/src/proto/asset.pb.h | 62 ---- .../grpc/src/proto/nsolid_service.grpc.pb.cc | 69 +--- .../grpc/src/proto/nsolid_service.grpc.pb.h | 295 +++++------------- agents/grpc/src/proto/nsolid_service.pb.cc | 42 ++- 7 files changed, 125 insertions(+), 432 deletions(-) diff --git a/agents/grpc/proto/asset.proto b/agents/grpc/proto/asset.proto index 1b7747d786..2dfe6a6513 100644 --- a/agents/grpc/proto/asset.proto +++ b/agents/grpc/proto/asset.proto @@ -11,7 +11,5 @@ message Asset { google.protobuf.Struct metadata = 3; string data = 4; bool complete = 5; - uint64 duration = 6; // Duration of the profile in milliseconds - double start_ts = 7; // Timestamp when the profile was taken in milliseconds from epoch - double end_ts = 8; // Timestamp when the profile was completed in milliseconds from epoch + uint64 duration = 6; } \ No newline at end of file diff --git a/agents/grpc/proto/nsolid_service.proto b/agents/grpc/proto/nsolid_service.proto index d391380234..5a850fe953 100644 --- a/agents/grpc/proto/nsolid_service.proto +++ b/agents/grpc/proto/nsolid_service.proto @@ -16,7 +16,6 @@ package grpcagent; service NSolidService { rpc Command (stream CommandResponse) returns (stream CommandRequest) {} rpc ExportAsset (stream Asset) returns (EventResponse) {} - rpc ExportContinuousProfile (stream Asset) returns (EventResponse) {} rpc ExportExit (ExitEvent) returns (EventResponse) {} rpc ExportInfo (InfoEvent) returns (EventResponse) {} rpc ExportMetrics (MetricsEvent) returns (EventResponse) {} diff --git a/agents/grpc/src/proto/asset.pb.cc b/agents/grpc/src/proto/asset.pb.cc index 03d9ef9f8b..0cb41bc1da 100644 --- a/agents/grpc/src/proto/asset.pb.cc +++ b/agents/grpc/src/proto/asset.pb.cc @@ -28,8 +28,6 @@ PROTOBUF_CONSTEXPR Asset::Asset( , /*decltype(_impl_.metadata_)*/nullptr , /*decltype(_impl_.thread_id_)*/uint64_t{0u} , /*decltype(_impl_.duration_)*/uint64_t{0u} - , /*decltype(_impl_.start_ts_)*/0 - , /*decltype(_impl_.end_ts_)*/0 , /*decltype(_impl_.complete_)*/false , /*decltype(_impl_._cached_size_)*/{}} {} struct AssetDefaultTypeInternal { @@ -59,8 +57,6 @@ const uint32_t TableStruct_asset_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(pr PROTOBUF_FIELD_OFFSET(::grpcagent::Asset, _impl_.data_), PROTOBUF_FIELD_OFFSET(::grpcagent::Asset, _impl_.complete_), PROTOBUF_FIELD_OFFSET(::grpcagent::Asset, _impl_.duration_), - PROTOBUF_FIELD_OFFSET(::grpcagent::Asset, _impl_.start_ts_), - PROTOBUF_FIELD_OFFSET(::grpcagent::Asset, _impl_.end_ts_), }; static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, -1, sizeof(::grpcagent::Asset)}, @@ -72,12 +68,12 @@ static const ::_pb::Message* const file_default_instances[] = { const char descriptor_table_protodef_asset_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = "\n\013asset.proto\022\tgrpcagent\032\014common.proto\032\034" - "google/protobuf/struct.proto\"\304\001\n\005Asset\022)" + "google/protobuf/struct.proto\"\242\001\n\005Asset\022)" "\n\006common\030\001 \001(\0132\031.grpcagent.CommonRespons" "e\022\021\n\tthread_id\030\002 \001(\004\022)\n\010metadata\030\003 \001(\0132\027" ".google.protobuf.Struct\022\014\n\004data\030\004 \001(\t\022\020\n" - "\010complete\030\005 \001(\010\022\020\n\010duration\030\006 \001(\004\022\020\n\010sta" - "rt_ts\030\007 \001(\001\022\016\n\006end_ts\030\010 \001(\001b\006proto3" + "\010complete\030\005 \001(\010\022\020\n\010duration\030\006 \001(\004b\006proto" + "3" ; static const ::_pbi::DescriptorTable* const descriptor_table_asset_2eproto_deps[2] = { &::descriptor_table_common_2eproto, @@ -85,7 +81,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_asset_2eproto_deps[ }; static ::_pbi::once_flag descriptor_table_asset_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_asset_2eproto = { - false, false, 275, descriptor_table_protodef_asset_2eproto, + false, false, 241, descriptor_table_protodef_asset_2eproto, "asset.proto", &descriptor_table_asset_2eproto_once, descriptor_table_asset_2eproto_deps, 2, 1, schemas, file_default_instances, TableStruct_asset_2eproto::offsets, @@ -143,8 +139,6 @@ Asset::Asset(const Asset& from) , decltype(_impl_.metadata_){nullptr} , decltype(_impl_.thread_id_){} , decltype(_impl_.duration_){} - , decltype(_impl_.start_ts_){} - , decltype(_impl_.end_ts_){} , decltype(_impl_.complete_){} , /*decltype(_impl_._cached_size_)*/{}}; @@ -179,8 +173,6 @@ inline void Asset::SharedCtor( , decltype(_impl_.metadata_){nullptr} , decltype(_impl_.thread_id_){uint64_t{0u}} , decltype(_impl_.duration_){uint64_t{0u}} - , decltype(_impl_.start_ts_){0} - , decltype(_impl_.end_ts_){0} , decltype(_impl_.complete_){false} , /*decltype(_impl_._cached_size_)*/{} }; @@ -287,22 +279,6 @@ const char* Asset::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) { } else goto handle_unusual; continue; - // double start_ts = 7; - case 7: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 57)) { - _impl_.start_ts_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); - ptr += sizeof(double); - } else - goto handle_unusual; - continue; - // double end_ts = 8; - case 8: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 65)) { - _impl_.end_ts_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad(ptr); - ptr += sizeof(double); - } else - goto handle_unusual; - continue; default: goto handle_unusual; } // switch @@ -374,26 +350,6 @@ uint8_t* Asset::_InternalSerialize( target = ::_pbi::WireFormatLite::WriteUInt64ToArray(6, this->_internal_duration(), target); } - // double start_ts = 7; - static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); - double tmp_start_ts = this->_internal_start_ts(); - uint64_t raw_start_ts; - memcpy(&raw_start_ts, &tmp_start_ts, sizeof(tmp_start_ts)); - if (raw_start_ts != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteDoubleToArray(7, this->_internal_start_ts(), target); - } - - // double end_ts = 8; - static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); - double tmp_end_ts = this->_internal_end_ts(); - uint64_t raw_end_ts; - memcpy(&raw_end_ts, &tmp_end_ts, sizeof(tmp_end_ts)); - if (raw_end_ts != 0) { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteDoubleToArray(8, this->_internal_end_ts(), target); - } - if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -441,24 +397,6 @@ size_t Asset::ByteSizeLong() const { total_size += ::_pbi::WireFormatLite::UInt64SizePlusOne(this->_internal_duration()); } - // double start_ts = 7; - static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); - double tmp_start_ts = this->_internal_start_ts(); - uint64_t raw_start_ts; - memcpy(&raw_start_ts, &tmp_start_ts, sizeof(tmp_start_ts)); - if (raw_start_ts != 0) { - total_size += 1 + 8; - } - - // double end_ts = 8; - static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); - double tmp_end_ts = this->_internal_end_ts(); - uint64_t raw_end_ts; - memcpy(&raw_end_ts, &tmp_end_ts, sizeof(tmp_end_ts)); - if (raw_end_ts != 0) { - total_size += 1 + 8; - } - // bool complete = 5; if (this->_internal_complete() != 0) { total_size += 1 + 1; @@ -499,20 +437,6 @@ void Asset::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF if (from._internal_duration() != 0) { _this->_internal_set_duration(from._internal_duration()); } - static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); - double tmp_start_ts = from._internal_start_ts(); - uint64_t raw_start_ts; - memcpy(&raw_start_ts, &tmp_start_ts, sizeof(tmp_start_ts)); - if (raw_start_ts != 0) { - _this->_internal_set_start_ts(from._internal_start_ts()); - } - static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); - double tmp_end_ts = from._internal_end_ts(); - uint64_t raw_end_ts; - memcpy(&raw_end_ts, &tmp_end_ts, sizeof(tmp_end_ts)); - if (raw_end_ts != 0) { - _this->_internal_set_end_ts(from._internal_end_ts()); - } if (from._internal_complete() != 0) { _this->_internal_set_complete(from._internal_complete()); } diff --git a/agents/grpc/src/proto/asset.pb.h b/agents/grpc/src/proto/asset.pb.h index 58fd77e11a..5aa2a529fa 100644 --- a/agents/grpc/src/proto/asset.pb.h +++ b/agents/grpc/src/proto/asset.pb.h @@ -184,8 +184,6 @@ class Asset final : kMetadataFieldNumber = 3, kThreadIdFieldNumber = 2, kDurationFieldNumber = 6, - kStartTsFieldNumber = 7, - kEndTsFieldNumber = 8, kCompleteFieldNumber = 5, }; // string data = 4; @@ -256,24 +254,6 @@ class Asset final : void _internal_set_duration(uint64_t value); public: - // double start_ts = 7; - void clear_start_ts(); - double start_ts() const; - void set_start_ts(double value); - private: - double _internal_start_ts() const; - void _internal_set_start_ts(double value); - public: - - // double end_ts = 8; - void clear_end_ts(); - double end_ts() const; - void set_end_ts(double value); - private: - double _internal_end_ts() const; - void _internal_set_end_ts(double value); - public: - // bool complete = 5; void clear_complete(); bool complete() const; @@ -296,8 +276,6 @@ class Asset final : ::PROTOBUF_NAMESPACE_ID::Struct* metadata_; uint64_t thread_id_; uint64_t duration_; - double start_ts_; - double end_ts_; bool complete_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; @@ -595,46 +573,6 @@ inline void Asset::set_duration(uint64_t value) { // @@protoc_insertion_point(field_set:grpcagent.Asset.duration) } -// double start_ts = 7; -inline void Asset::clear_start_ts() { - _impl_.start_ts_ = 0; -} -inline double Asset::_internal_start_ts() const { - return _impl_.start_ts_; -} -inline double Asset::start_ts() const { - // @@protoc_insertion_point(field_get:grpcagent.Asset.start_ts) - return _internal_start_ts(); -} -inline void Asset::_internal_set_start_ts(double value) { - - _impl_.start_ts_ = value; -} -inline void Asset::set_start_ts(double value) { - _internal_set_start_ts(value); - // @@protoc_insertion_point(field_set:grpcagent.Asset.start_ts) -} - -// double end_ts = 8; -inline void Asset::clear_end_ts() { - _impl_.end_ts_ = 0; -} -inline double Asset::_internal_end_ts() const { - return _impl_.end_ts_; -} -inline double Asset::end_ts() const { - // @@protoc_insertion_point(field_get:grpcagent.Asset.end_ts) - return _internal_end_ts(); -} -inline void Asset::_internal_set_end_ts(double value) { - - _impl_.end_ts_ = value; -} -inline void Asset::set_end_ts(double value) { - _internal_set_end_ts(value); - // @@protoc_insertion_point(field_set:grpcagent.Asset.end_ts) -} - #ifdef __GNUC__ #pragma GCC diagnostic pop #endif // __GNUC__ diff --git a/agents/grpc/src/proto/nsolid_service.grpc.pb.cc b/agents/grpc/src/proto/nsolid_service.grpc.pb.cc index c7a7119a59..ede9326f8e 100644 --- a/agents/grpc/src/proto/nsolid_service.grpc.pb.cc +++ b/agents/grpc/src/proto/nsolid_service.grpc.pb.cc @@ -24,7 +24,6 @@ namespace grpcagent { static const char* NSolidService_method_names[] = { "/grpcagent.NSolidService/Command", "/grpcagent.NSolidService/ExportAsset", - "/grpcagent.NSolidService/ExportContinuousProfile", "/grpcagent.NSolidService/ExportExit", "/grpcagent.NSolidService/ExportInfo", "/grpcagent.NSolidService/ExportMetrics", @@ -45,16 +44,15 @@ std::unique_ptr< NSolidService::Stub> NSolidService::NewStub(const std::shared_p NSolidService::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) : channel_(channel), rpcmethod_Command_(NSolidService_method_names[0], options.suffix_for_stats(),::grpc::internal::RpcMethod::BIDI_STREAMING, channel) , rpcmethod_ExportAsset_(NSolidService_method_names[1], options.suffix_for_stats(),::grpc::internal::RpcMethod::CLIENT_STREAMING, channel) - , rpcmethod_ExportContinuousProfile_(NSolidService_method_names[2], options.suffix_for_stats(),::grpc::internal::RpcMethod::CLIENT_STREAMING, channel) - , rpcmethod_ExportExit_(NSolidService_method_names[3], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportInfo_(NSolidService_method_names[4], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportMetrics_(NSolidService_method_names[5], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportPackages_(NSolidService_method_names[6], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportBlockedLoop_(NSolidService_method_names[7], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportUnblockedLoop_(NSolidService_method_names[8], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportReconfigure_(NSolidService_method_names[9], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportSourceCode_(NSolidService_method_names[10], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) - , rpcmethod_ExportStartupTimes_(NSolidService_method_names[11], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportExit_(NSolidService_method_names[2], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportInfo_(NSolidService_method_names[3], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportMetrics_(NSolidService_method_names[4], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportPackages_(NSolidService_method_names[5], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportBlockedLoop_(NSolidService_method_names[6], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportUnblockedLoop_(NSolidService_method_names[7], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportReconfigure_(NSolidService_method_names[8], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportSourceCode_(NSolidService_method_names[9], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) + , rpcmethod_ExportStartupTimes_(NSolidService_method_names[10], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel) {} ::grpc::ClientReaderWriter< ::grpcagent::CommandResponse, ::grpcagent::CommandRequest>* NSolidService::Stub::CommandRaw(::grpc::ClientContext* context) { @@ -89,22 +87,6 @@ ::grpc::ClientAsyncWriter< ::grpcagent::Asset>* NSolidService::Stub::PrepareAsyn return ::grpc::internal::ClientAsyncWriterFactory< ::grpcagent::Asset>::Create(channel_.get(), cq, rpcmethod_ExportAsset_, context, response, false, nullptr); } -::grpc::ClientWriter< ::grpcagent::Asset>* NSolidService::Stub::ExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response) { - return ::grpc::internal::ClientWriterFactory< ::grpcagent::Asset>::Create(channel_.get(), rpcmethod_ExportContinuousProfile_, context, response); -} - -void NSolidService::Stub::async::ExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::ClientWriteReactor< ::grpcagent::Asset>* reactor) { - ::grpc::internal::ClientCallbackWriterFactory< ::grpcagent::Asset>::Create(stub_->channel_.get(), stub_->rpcmethod_ExportContinuousProfile_, context, response, reactor); -} - -::grpc::ClientAsyncWriter< ::grpcagent::Asset>* NSolidService::Stub::AsyncExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq, void* tag) { - return ::grpc::internal::ClientAsyncWriterFactory< ::grpcagent::Asset>::Create(channel_.get(), cq, rpcmethod_ExportContinuousProfile_, context, response, true, tag); -} - -::grpc::ClientAsyncWriter< ::grpcagent::Asset>* NSolidService::Stub::PrepareAsyncExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) { - return ::grpc::internal::ClientAsyncWriterFactory< ::grpcagent::Asset>::Create(channel_.get(), cq, rpcmethod_ExportContinuousProfile_, context, response, false, nullptr); -} - ::grpc::Status NSolidService::Stub::ExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpcagent::EventResponse* response) { return ::grpc::internal::BlockingUnaryCall< ::grpcagent::ExitEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_ExportExit_, context, request, response); } @@ -335,16 +317,6 @@ NSolidService::Service::Service() { }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( NSolidService_method_names[2], - ::grpc::internal::RpcMethod::CLIENT_STREAMING, - new ::grpc::internal::ClientStreamingHandler< NSolidService::Service, ::grpcagent::Asset, ::grpcagent::EventResponse>( - [](NSolidService::Service* service, - ::grpc::ServerContext* ctx, - ::grpc::ServerReader<::grpcagent::Asset>* reader, - ::grpcagent::EventResponse* resp) { - return service->ExportContinuousProfile(ctx, reader, resp); - }, this))); - AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[3], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::ExitEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -354,7 +326,7 @@ NSolidService::Service::Service() { return service->ExportExit(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[4], + NSolidService_method_names[3], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::InfoEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -364,7 +336,7 @@ NSolidService::Service::Service() { return service->ExportInfo(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[5], + NSolidService_method_names[4], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::MetricsEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -374,7 +346,7 @@ NSolidService::Service::Service() { return service->ExportMetrics(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[6], + NSolidService_method_names[5], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::PackagesEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -384,7 +356,7 @@ NSolidService::Service::Service() { return service->ExportPackages(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[7], + NSolidService_method_names[6], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::BlockedLoopEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -394,7 +366,7 @@ NSolidService::Service::Service() { return service->ExportBlockedLoop(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[8], + NSolidService_method_names[7], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::UnblockedLoopEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -404,7 +376,7 @@ NSolidService::Service::Service() { return service->ExportUnblockedLoop(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[9], + NSolidService_method_names[8], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::ReconfigureEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -414,7 +386,7 @@ NSolidService::Service::Service() { return service->ExportReconfigure(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[10], + NSolidService_method_names[9], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -424,7 +396,7 @@ NSolidService::Service::Service() { return service->ExportSourceCode(ctx, req, resp); }, this))); AddMethod(new ::grpc::internal::RpcServiceMethod( - NSolidService_method_names[11], + NSolidService_method_names[10], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< NSolidService::Service, ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( [](NSolidService::Service* service, @@ -451,13 +423,6 @@ ::grpc::Status NSolidService::Service::ExportAsset(::grpc::ServerContext* contex return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } -::grpc::Status NSolidService::Service::ExportContinuousProfile(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpcagent::Asset>* reader, ::grpcagent::EventResponse* response) { - (void) context; - (void) reader; - (void) response; - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); -} - ::grpc::Status NSolidService::Service::ExportExit(::grpc::ServerContext* context, const ::grpcagent::ExitEvent* request, ::grpcagent::EventResponse* response) { (void) context; (void) request; diff --git a/agents/grpc/src/proto/nsolid_service.grpc.pb.h b/agents/grpc/src/proto/nsolid_service.grpc.pb.h index bfb0caa4fc..aee2f39dbb 100644 --- a/agents/grpc/src/proto/nsolid_service.grpc.pb.h +++ b/agents/grpc/src/proto/nsolid_service.grpc.pb.h @@ -53,15 +53,6 @@ class NSolidService final { std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>> PrepareAsyncExportAsset(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>>(PrepareAsyncExportAssetRaw(context, response, cq)); } - std::unique_ptr< ::grpc::ClientWriterInterface< ::grpcagent::Asset>> ExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response) { - return std::unique_ptr< ::grpc::ClientWriterInterface< ::grpcagent::Asset>>(ExportContinuousProfileRaw(context, response)); - } - std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>> AsyncExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>>(AsyncExportContinuousProfileRaw(context, response, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>> PrepareAsyncExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>>(PrepareAsyncExportContinuousProfileRaw(context, response, cq)); - } virtual ::grpc::Status ExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpcagent::EventResponse* response) = 0; std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>> AsyncExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>>(AsyncExportExitRaw(context, request, cq)); @@ -130,7 +121,6 @@ class NSolidService final { virtual ~async_interface() {} virtual void Command(::grpc::ClientContext* context, ::grpc::ClientBidiReactor< ::grpcagent::CommandResponse,::grpcagent::CommandRequest>* reactor) = 0; virtual void ExportAsset(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::ClientWriteReactor< ::grpcagent::Asset>* reactor) = 0; - virtual void ExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::ClientWriteReactor< ::grpcagent::Asset>* reactor) = 0; virtual void ExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; virtual void ExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) = 0; virtual void ExportInfo(::grpc::ClientContext* context, const ::grpcagent::InfoEvent* request, ::grpcagent::EventResponse* response, std::function) = 0; @@ -160,9 +150,6 @@ class NSolidService final { virtual ::grpc::ClientWriterInterface< ::grpcagent::Asset>* ExportAssetRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response) = 0; virtual ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>* AsyncExportAssetRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq, void* tag) = 0; virtual ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>* PrepareAsyncExportAssetRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) = 0; - virtual ::grpc::ClientWriterInterface< ::grpcagent::Asset>* ExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response) = 0; - virtual ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>* AsyncExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq, void* tag) = 0; - virtual ::grpc::ClientAsyncWriterInterface< ::grpcagent::Asset>* PrepareAsyncExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportExitRaw(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* PrepareAsyncExportExitRaw(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpc::CompletionQueue* cq) = 0; virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpcagent::EventResponse>* AsyncExportInfoRaw(::grpc::ClientContext* context, const ::grpcagent::InfoEvent& request, ::grpc::CompletionQueue* cq) = 0; @@ -203,15 +190,6 @@ class NSolidService final { std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpcagent::Asset>> PrepareAsyncExportAsset(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpcagent::Asset>>(PrepareAsyncExportAssetRaw(context, response, cq)); } - std::unique_ptr< ::grpc::ClientWriter< ::grpcagent::Asset>> ExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response) { - return std::unique_ptr< ::grpc::ClientWriter< ::grpcagent::Asset>>(ExportContinuousProfileRaw(context, response)); - } - std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpcagent::Asset>> AsyncExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpcagent::Asset>>(AsyncExportContinuousProfileRaw(context, response, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpcagent::Asset>> PrepareAsyncExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpcagent::Asset>>(PrepareAsyncExportContinuousProfileRaw(context, response, cq)); - } ::grpc::Status ExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpcagent::EventResponse* response) override; std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>> AsyncExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpc::CompletionQueue* cq) { return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>>(AsyncExportExitRaw(context, request, cq)); @@ -280,7 +258,6 @@ class NSolidService final { public: void Command(::grpc::ClientContext* context, ::grpc::ClientBidiReactor< ::grpcagent::CommandResponse,::grpcagent::CommandRequest>* reactor) override; void ExportAsset(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::ClientWriteReactor< ::grpcagent::Asset>* reactor) override; - void ExportContinuousProfile(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::ClientWriteReactor< ::grpcagent::Asset>* reactor) override; void ExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent* request, ::grpcagent::EventResponse* response, std::function) override; void ExportExit(::grpc::ClientContext* context, const ::grpcagent::ExitEvent* request, ::grpcagent::EventResponse* response, ::grpc::ClientUnaryReactor* reactor) override; void ExportInfo(::grpc::ClientContext* context, const ::grpcagent::InfoEvent* request, ::grpcagent::EventResponse* response, std::function) override; @@ -316,9 +293,6 @@ class NSolidService final { ::grpc::ClientWriter< ::grpcagent::Asset>* ExportAssetRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response) override; ::grpc::ClientAsyncWriter< ::grpcagent::Asset>* AsyncExportAssetRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq, void* tag) override; ::grpc::ClientAsyncWriter< ::grpcagent::Asset>* PrepareAsyncExportAssetRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) override; - ::grpc::ClientWriter< ::grpcagent::Asset>* ExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response) override; - ::grpc::ClientAsyncWriter< ::grpcagent::Asset>* AsyncExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq, void* tag) override; - ::grpc::ClientAsyncWriter< ::grpcagent::Asset>* PrepareAsyncExportContinuousProfileRaw(::grpc::ClientContext* context, ::grpcagent::EventResponse* response, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportExitRaw(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportExitRaw(::grpc::ClientContext* context, const ::grpcagent::ExitEvent& request, ::grpc::CompletionQueue* cq) override; ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* AsyncExportInfoRaw(::grpc::ClientContext* context, const ::grpcagent::InfoEvent& request, ::grpc::CompletionQueue* cq) override; @@ -339,7 +313,6 @@ class NSolidService final { ::grpc::ClientAsyncResponseReader< ::grpcagent::EventResponse>* PrepareAsyncExportStartupTimesRaw(::grpc::ClientContext* context, const ::grpcagent::StartupTimesEvent& request, ::grpc::CompletionQueue* cq) override; const ::grpc::internal::RpcMethod rpcmethod_Command_; const ::grpc::internal::RpcMethod rpcmethod_ExportAsset_; - const ::grpc::internal::RpcMethod rpcmethod_ExportContinuousProfile_; const ::grpc::internal::RpcMethod rpcmethod_ExportExit_; const ::grpc::internal::RpcMethod rpcmethod_ExportInfo_; const ::grpc::internal::RpcMethod rpcmethod_ExportMetrics_; @@ -358,7 +331,6 @@ class NSolidService final { virtual ~Service(); virtual ::grpc::Status Command(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpcagent::CommandRequest, ::grpcagent::CommandResponse>* stream); virtual ::grpc::Status ExportAsset(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpcagent::Asset>* reader, ::grpcagent::EventResponse* response); - virtual ::grpc::Status ExportContinuousProfile(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpcagent::Asset>* reader, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportExit(::grpc::ServerContext* context, const ::grpcagent::ExitEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportInfo(::grpc::ServerContext* context, const ::grpcagent::InfoEvent* request, ::grpcagent::EventResponse* response); virtual ::grpc::Status ExportMetrics(::grpc::ServerContext* context, const ::grpcagent::MetricsEvent* request, ::grpcagent::EventResponse* response); @@ -410,32 +382,12 @@ class NSolidService final { } }; template - class WithAsyncMethod_ExportContinuousProfile : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} - public: - WithAsyncMethod_ExportContinuousProfile() { - ::grpc::Service::MarkMethodAsync(2); - } - ~WithAsyncMethod_ExportContinuousProfile() override { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status ExportContinuousProfile(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpcagent::Asset>* /*reader*/, ::grpcagent::EventResponse* /*response*/) override { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - void RequestExportContinuousProfile(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::grpcagent::EventResponse, ::grpcagent::Asset>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag); - } - }; - template class WithAsyncMethod_ExportExit : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportExit() { - ::grpc::Service::MarkMethodAsync(3); + ::grpc::Service::MarkMethodAsync(2); } ~WithAsyncMethod_ExportExit() override { BaseClassMustBeDerivedFromService(this); @@ -446,7 +398,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportExit(::grpc::ServerContext* context, ::grpcagent::ExitEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(3, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(2, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -455,7 +407,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportInfo() { - ::grpc::Service::MarkMethodAsync(4); + ::grpc::Service::MarkMethodAsync(3); } ~WithAsyncMethod_ExportInfo() override { BaseClassMustBeDerivedFromService(this); @@ -466,7 +418,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportInfo(::grpc::ServerContext* context, ::grpcagent::InfoEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(4, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(3, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -475,7 +427,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportMetrics() { - ::grpc::Service::MarkMethodAsync(5); + ::grpc::Service::MarkMethodAsync(4); } ~WithAsyncMethod_ExportMetrics() override { BaseClassMustBeDerivedFromService(this); @@ -486,7 +438,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportMetrics(::grpc::ServerContext* context, ::grpcagent::MetricsEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(5, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(4, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -495,7 +447,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportPackages() { - ::grpc::Service::MarkMethodAsync(6); + ::grpc::Service::MarkMethodAsync(5); } ~WithAsyncMethod_ExportPackages() override { BaseClassMustBeDerivedFromService(this); @@ -506,7 +458,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportPackages(::grpc::ServerContext* context, ::grpcagent::PackagesEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(5, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -515,7 +467,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportBlockedLoop() { - ::grpc::Service::MarkMethodAsync(7); + ::grpc::Service::MarkMethodAsync(6); } ~WithAsyncMethod_ExportBlockedLoop() override { BaseClassMustBeDerivedFromService(this); @@ -526,7 +478,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportBlockedLoop(::grpc::ServerContext* context, ::grpcagent::BlockedLoopEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(7, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -535,7 +487,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportUnblockedLoop() { - ::grpc::Service::MarkMethodAsync(8); + ::grpc::Service::MarkMethodAsync(7); } ~WithAsyncMethod_ExportUnblockedLoop() override { BaseClassMustBeDerivedFromService(this); @@ -546,7 +498,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportUnblockedLoop(::grpc::ServerContext* context, ::grpcagent::UnblockedLoopEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(8, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(7, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -555,7 +507,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportReconfigure() { - ::grpc::Service::MarkMethodAsync(9); + ::grpc::Service::MarkMethodAsync(8); } ~WithAsyncMethod_ExportReconfigure() override { BaseClassMustBeDerivedFromService(this); @@ -566,7 +518,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportReconfigure(::grpc::ServerContext* context, ::grpcagent::ReconfigureEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(8, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -575,7 +527,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportSourceCode() { - ::grpc::Service::MarkMethodAsync(10); + ::grpc::Service::MarkMethodAsync(9); } ~WithAsyncMethod_ExportSourceCode() override { BaseClassMustBeDerivedFromService(this); @@ -586,7 +538,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportSourceCode(::grpc::ServerContext* context, ::grpcagent::SourceCodeEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -595,7 +547,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithAsyncMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodAsync(11); + ::grpc::Service::MarkMethodAsync(10); } ~WithAsyncMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -606,10 +558,10 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportStartupTimes(::grpc::ServerContext* context, ::grpcagent::StartupTimesEvent* request, ::grpc::ServerAsyncResponseWriter< ::grpcagent::EventResponse>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(11, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); } }; - typedef WithAsyncMethod_Command > > > > > > > > > > > AsyncService; + typedef WithAsyncMethod_Command > > > > > > > > > > AsyncService; template class WithCallbackMethod_Command : public BaseClass { private: @@ -656,40 +608,18 @@ class NSolidService final { ::grpc::CallbackServerContext* /*context*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } }; template - class WithCallbackMethod_ExportContinuousProfile : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} - public: - WithCallbackMethod_ExportContinuousProfile() { - ::grpc::Service::MarkMethodCallback(2, - new ::grpc::internal::CallbackClientStreamingHandler< ::grpcagent::Asset, ::grpcagent::EventResponse>( - [this]( - ::grpc::CallbackServerContext* context, ::grpcagent::EventResponse* response) { return this->ExportContinuousProfile(context, response); })); - } - ~WithCallbackMethod_ExportContinuousProfile() override { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status ExportContinuousProfile(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpcagent::Asset>* /*reader*/, ::grpcagent::EventResponse* /*response*/) override { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - virtual ::grpc::ServerReadReactor< ::grpcagent::Asset>* ExportContinuousProfile( - ::grpc::CallbackServerContext* /*context*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } - }; - template class WithCallbackMethod_ExportExit : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportExit() { - ::grpc::Service::MarkMethodCallback(3, + ::grpc::Service::MarkMethodCallback(2, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::ExitEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::ExitEvent* request, ::grpcagent::EventResponse* response) { return this->ExportExit(context, request, response); }));} void SetMessageAllocatorFor_ExportExit( ::grpc::MessageAllocator< ::grpcagent::ExitEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(3); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(2); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::ExitEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -710,13 +640,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportInfo() { - ::grpc::Service::MarkMethodCallback(4, + ::grpc::Service::MarkMethodCallback(3, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::InfoEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::InfoEvent* request, ::grpcagent::EventResponse* response) { return this->ExportInfo(context, request, response); }));} void SetMessageAllocatorFor_ExportInfo( ::grpc::MessageAllocator< ::grpcagent::InfoEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(4); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(3); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::InfoEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -737,13 +667,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportMetrics() { - ::grpc::Service::MarkMethodCallback(5, + ::grpc::Service::MarkMethodCallback(4, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::MetricsEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::MetricsEvent* request, ::grpcagent::EventResponse* response) { return this->ExportMetrics(context, request, response); }));} void SetMessageAllocatorFor_ExportMetrics( ::grpc::MessageAllocator< ::grpcagent::MetricsEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(5); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(4); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::MetricsEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -764,13 +694,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportPackages() { - ::grpc::Service::MarkMethodCallback(6, + ::grpc::Service::MarkMethodCallback(5, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::PackagesEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::PackagesEvent* request, ::grpcagent::EventResponse* response) { return this->ExportPackages(context, request, response); }));} void SetMessageAllocatorFor_ExportPackages( ::grpc::MessageAllocator< ::grpcagent::PackagesEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(6); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(5); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::PackagesEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -791,13 +721,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportBlockedLoop() { - ::grpc::Service::MarkMethodCallback(7, + ::grpc::Service::MarkMethodCallback(6, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::BlockedLoopEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::BlockedLoopEvent* request, ::grpcagent::EventResponse* response) { return this->ExportBlockedLoop(context, request, response); }));} void SetMessageAllocatorFor_ExportBlockedLoop( ::grpc::MessageAllocator< ::grpcagent::BlockedLoopEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(7); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(6); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::BlockedLoopEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -818,13 +748,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportUnblockedLoop() { - ::grpc::Service::MarkMethodCallback(8, + ::grpc::Service::MarkMethodCallback(7, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::UnblockedLoopEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::UnblockedLoopEvent* request, ::grpcagent::EventResponse* response) { return this->ExportUnblockedLoop(context, request, response); }));} void SetMessageAllocatorFor_ExportUnblockedLoop( ::grpc::MessageAllocator< ::grpcagent::UnblockedLoopEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(8); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(7); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::UnblockedLoopEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -845,13 +775,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportReconfigure() { - ::grpc::Service::MarkMethodCallback(9, + ::grpc::Service::MarkMethodCallback(8, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::ReconfigureEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::ReconfigureEvent* request, ::grpcagent::EventResponse* response) { return this->ExportReconfigure(context, request, response); }));} void SetMessageAllocatorFor_ExportReconfigure( ::grpc::MessageAllocator< ::grpcagent::ReconfigureEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(9); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(8); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::ReconfigureEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -872,13 +802,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportSourceCode() { - ::grpc::Service::MarkMethodCallback(10, + ::grpc::Service::MarkMethodCallback(9, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::SourceCodeEvent* request, ::grpcagent::EventResponse* response) { return this->ExportSourceCode(context, request, response); }));} void SetMessageAllocatorFor_ExportSourceCode( ::grpc::MessageAllocator< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(10); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(9); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -899,13 +829,13 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithCallbackMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodCallback(11, + ::grpc::Service::MarkMethodCallback(10, new ::grpc::internal::CallbackUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>( [this]( ::grpc::CallbackServerContext* context, const ::grpcagent::StartupTimesEvent* request, ::grpcagent::EventResponse* response) { return this->ExportStartupTimes(context, request, response); }));} void SetMessageAllocatorFor_ExportStartupTimes( ::grpc::MessageAllocator< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>* allocator) { - ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(11); + ::grpc::internal::MethodHandler* const handler = ::grpc::Service::GetHandler(10); static_cast<::grpc::internal::CallbackUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>*>(handler) ->SetMessageAllocator(allocator); } @@ -920,7 +850,7 @@ class NSolidService final { virtual ::grpc::ServerUnaryReactor* ExportStartupTimes( ::grpc::CallbackServerContext* /*context*/, const ::grpcagent::StartupTimesEvent* /*request*/, ::grpcagent::EventResponse* /*response*/) { return nullptr; } }; - typedef WithCallbackMethod_Command > > > > > > > > > > > CallbackService; + typedef WithCallbackMethod_Command > > > > > > > > > > CallbackService; typedef CallbackService ExperimentalCallbackService; template class WithGenericMethod_Command : public BaseClass { @@ -957,29 +887,12 @@ class NSolidService final { } }; template - class WithGenericMethod_ExportContinuousProfile : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} - public: - WithGenericMethod_ExportContinuousProfile() { - ::grpc::Service::MarkMethodGeneric(2); - } - ~WithGenericMethod_ExportContinuousProfile() override { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status ExportContinuousProfile(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpcagent::Asset>* /*reader*/, ::grpcagent::EventResponse* /*response*/) override { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - }; - template class WithGenericMethod_ExportExit : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportExit() { - ::grpc::Service::MarkMethodGeneric(3); + ::grpc::Service::MarkMethodGeneric(2); } ~WithGenericMethod_ExportExit() override { BaseClassMustBeDerivedFromService(this); @@ -996,7 +909,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportInfo() { - ::grpc::Service::MarkMethodGeneric(4); + ::grpc::Service::MarkMethodGeneric(3); } ~WithGenericMethod_ExportInfo() override { BaseClassMustBeDerivedFromService(this); @@ -1013,7 +926,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportMetrics() { - ::grpc::Service::MarkMethodGeneric(5); + ::grpc::Service::MarkMethodGeneric(4); } ~WithGenericMethod_ExportMetrics() override { BaseClassMustBeDerivedFromService(this); @@ -1030,7 +943,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportPackages() { - ::grpc::Service::MarkMethodGeneric(6); + ::grpc::Service::MarkMethodGeneric(5); } ~WithGenericMethod_ExportPackages() override { BaseClassMustBeDerivedFromService(this); @@ -1047,7 +960,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportBlockedLoop() { - ::grpc::Service::MarkMethodGeneric(7); + ::grpc::Service::MarkMethodGeneric(6); } ~WithGenericMethod_ExportBlockedLoop() override { BaseClassMustBeDerivedFromService(this); @@ -1064,7 +977,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportUnblockedLoop() { - ::grpc::Service::MarkMethodGeneric(8); + ::grpc::Service::MarkMethodGeneric(7); } ~WithGenericMethod_ExportUnblockedLoop() override { BaseClassMustBeDerivedFromService(this); @@ -1081,7 +994,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportReconfigure() { - ::grpc::Service::MarkMethodGeneric(9); + ::grpc::Service::MarkMethodGeneric(8); } ~WithGenericMethod_ExportReconfigure() override { BaseClassMustBeDerivedFromService(this); @@ -1098,7 +1011,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportSourceCode() { - ::grpc::Service::MarkMethodGeneric(10); + ::grpc::Service::MarkMethodGeneric(9); } ~WithGenericMethod_ExportSourceCode() override { BaseClassMustBeDerivedFromService(this); @@ -1115,7 +1028,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithGenericMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodGeneric(11); + ::grpc::Service::MarkMethodGeneric(10); } ~WithGenericMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -1167,32 +1080,12 @@ class NSolidService final { } }; template - class WithRawMethod_ExportContinuousProfile : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} - public: - WithRawMethod_ExportContinuousProfile() { - ::grpc::Service::MarkMethodRaw(2); - } - ~WithRawMethod_ExportContinuousProfile() override { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status ExportContinuousProfile(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpcagent::Asset>* /*reader*/, ::grpcagent::EventResponse* /*response*/) override { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - void RequestExportContinuousProfile(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncClientStreaming(2, context, reader, new_call_cq, notification_cq, tag); - } - }; - template class WithRawMethod_ExportExit : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportExit() { - ::grpc::Service::MarkMethodRaw(3); + ::grpc::Service::MarkMethodRaw(2); } ~WithRawMethod_ExportExit() override { BaseClassMustBeDerivedFromService(this); @@ -1203,7 +1096,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportExit(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(3, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(2, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1212,7 +1105,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportInfo() { - ::grpc::Service::MarkMethodRaw(4); + ::grpc::Service::MarkMethodRaw(3); } ~WithRawMethod_ExportInfo() override { BaseClassMustBeDerivedFromService(this); @@ -1223,7 +1116,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportInfo(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(4, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(3, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1232,7 +1125,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportMetrics() { - ::grpc::Service::MarkMethodRaw(5); + ::grpc::Service::MarkMethodRaw(4); } ~WithRawMethod_ExportMetrics() override { BaseClassMustBeDerivedFromService(this); @@ -1243,7 +1136,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportMetrics(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(5, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(4, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1252,7 +1145,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportPackages() { - ::grpc::Service::MarkMethodRaw(6); + ::grpc::Service::MarkMethodRaw(5); } ~WithRawMethod_ExportPackages() override { BaseClassMustBeDerivedFromService(this); @@ -1263,7 +1156,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportPackages(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(5, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1272,7 +1165,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportBlockedLoop() { - ::grpc::Service::MarkMethodRaw(7); + ::grpc::Service::MarkMethodRaw(6); } ~WithRawMethod_ExportBlockedLoop() override { BaseClassMustBeDerivedFromService(this); @@ -1283,7 +1176,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportBlockedLoop(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(7, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(6, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1292,7 +1185,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportUnblockedLoop() { - ::grpc::Service::MarkMethodRaw(8); + ::grpc::Service::MarkMethodRaw(7); } ~WithRawMethod_ExportUnblockedLoop() override { BaseClassMustBeDerivedFromService(this); @@ -1303,7 +1196,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportUnblockedLoop(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(8, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(7, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1312,7 +1205,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportReconfigure() { - ::grpc::Service::MarkMethodRaw(9); + ::grpc::Service::MarkMethodRaw(8); } ~WithRawMethod_ExportReconfigure() override { BaseClassMustBeDerivedFromService(this); @@ -1323,7 +1216,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportReconfigure(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(8, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1332,7 +1225,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportSourceCode() { - ::grpc::Service::MarkMethodRaw(10); + ::grpc::Service::MarkMethodRaw(9); } ~WithRawMethod_ExportSourceCode() override { BaseClassMustBeDerivedFromService(this); @@ -1343,7 +1236,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportSourceCode(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(9, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1352,7 +1245,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodRaw(11); + ::grpc::Service::MarkMethodRaw(10); } ~WithRawMethod_ExportStartupTimes() override { BaseClassMustBeDerivedFromService(this); @@ -1363,7 +1256,7 @@ class NSolidService final { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } void RequestExportStartupTimes(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(11, context, request, response, new_call_cq, notification_cq, tag); + ::grpc::Service::RequestAsyncUnary(10, context, request, response, new_call_cq, notification_cq, tag); } }; template @@ -1412,34 +1305,12 @@ class NSolidService final { ::grpc::CallbackServerContext* /*context*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; } }; template - class WithRawCallbackMethod_ExportContinuousProfile : public BaseClass { - private: - void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} - public: - WithRawCallbackMethod_ExportContinuousProfile() { - ::grpc::Service::MarkMethodRawCallback(2, - new ::grpc::internal::CallbackClientStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( - [this]( - ::grpc::CallbackServerContext* context, ::grpc::ByteBuffer* response) { return this->ExportContinuousProfile(context, response); })); - } - ~WithRawCallbackMethod_ExportContinuousProfile() override { - BaseClassMustBeDerivedFromService(this); - } - // disable synchronous version of this method - ::grpc::Status ExportContinuousProfile(::grpc::ServerContext* /*context*/, ::grpc::ServerReader< ::grpcagent::Asset>* /*reader*/, ::grpcagent::EventResponse* /*response*/) override { - abort(); - return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); - } - virtual ::grpc::ServerReadReactor< ::grpc::ByteBuffer>* ExportContinuousProfile( - ::grpc::CallbackServerContext* /*context*/, ::grpc::ByteBuffer* /*response*/) { return nullptr; } - }; - template class WithRawCallbackMethod_ExportExit : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportExit() { - ::grpc::Service::MarkMethodRawCallback(3, + ::grpc::Service::MarkMethodRawCallback(2, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportExit(context, request, response); })); @@ -1461,7 +1332,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportInfo() { - ::grpc::Service::MarkMethodRawCallback(4, + ::grpc::Service::MarkMethodRawCallback(3, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportInfo(context, request, response); })); @@ -1483,7 +1354,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportMetrics() { - ::grpc::Service::MarkMethodRawCallback(5, + ::grpc::Service::MarkMethodRawCallback(4, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportMetrics(context, request, response); })); @@ -1505,7 +1376,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportPackages() { - ::grpc::Service::MarkMethodRawCallback(6, + ::grpc::Service::MarkMethodRawCallback(5, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportPackages(context, request, response); })); @@ -1527,7 +1398,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportBlockedLoop() { - ::grpc::Service::MarkMethodRawCallback(7, + ::grpc::Service::MarkMethodRawCallback(6, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportBlockedLoop(context, request, response); })); @@ -1549,7 +1420,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportUnblockedLoop() { - ::grpc::Service::MarkMethodRawCallback(8, + ::grpc::Service::MarkMethodRawCallback(7, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportUnblockedLoop(context, request, response); })); @@ -1571,7 +1442,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportReconfigure() { - ::grpc::Service::MarkMethodRawCallback(9, + ::grpc::Service::MarkMethodRawCallback(8, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportReconfigure(context, request, response); })); @@ -1593,7 +1464,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportSourceCode() { - ::grpc::Service::MarkMethodRawCallback(10, + ::grpc::Service::MarkMethodRawCallback(9, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportSourceCode(context, request, response); })); @@ -1615,7 +1486,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithRawCallbackMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodRawCallback(11, + ::grpc::Service::MarkMethodRawCallback(10, new ::grpc::internal::CallbackUnaryHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>( [this]( ::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response) { return this->ExportStartupTimes(context, request, response); })); @@ -1637,7 +1508,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportExit() { - ::grpc::Service::MarkMethodStreamed(3, + ::grpc::Service::MarkMethodStreamed(2, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::ExitEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1664,7 +1535,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportInfo() { - ::grpc::Service::MarkMethodStreamed(4, + ::grpc::Service::MarkMethodStreamed(3, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::InfoEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1691,7 +1562,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportMetrics() { - ::grpc::Service::MarkMethodStreamed(5, + ::grpc::Service::MarkMethodStreamed(4, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::MetricsEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1718,7 +1589,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportPackages() { - ::grpc::Service::MarkMethodStreamed(6, + ::grpc::Service::MarkMethodStreamed(5, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::PackagesEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1745,7 +1616,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportBlockedLoop() { - ::grpc::Service::MarkMethodStreamed(7, + ::grpc::Service::MarkMethodStreamed(6, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::BlockedLoopEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1772,7 +1643,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportUnblockedLoop() { - ::grpc::Service::MarkMethodStreamed(8, + ::grpc::Service::MarkMethodStreamed(7, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::UnblockedLoopEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1799,7 +1670,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportReconfigure() { - ::grpc::Service::MarkMethodStreamed(9, + ::grpc::Service::MarkMethodStreamed(8, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::ReconfigureEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1826,7 +1697,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportSourceCode() { - ::grpc::Service::MarkMethodStreamed(10, + ::grpc::Service::MarkMethodStreamed(9, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::SourceCodeEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, @@ -1853,7 +1724,7 @@ class NSolidService final { void BaseClassMustBeDerivedFromService(const Service* /*service*/) {} public: WithStreamedUnaryMethod_ExportStartupTimes() { - ::grpc::Service::MarkMethodStreamed(11, + ::grpc::Service::MarkMethodStreamed(10, new ::grpc::internal::StreamedUnaryHandler< ::grpcagent::StartupTimesEvent, ::grpcagent::EventResponse>( [this](::grpc::ServerContext* context, diff --git a/agents/grpc/src/proto/nsolid_service.pb.cc b/agents/grpc/src/proto/nsolid_service.pb.cc index 3dd278ead2..ed4780ba7b 100644 --- a/agents/grpc/src/proto/nsolid_service.pb.cc +++ b/agents/grpc/src/proto/nsolid_service.pb.cc @@ -62,30 +62,28 @@ const char descriptor_table_protodef_nsolid_5fservice_2eproto[] PROTOBUF_SECTION "o\032\nexit.proto\032\ninfo.proto\032\rmetrics.proto" "\032\016packages.proto\032\021reconfigure.proto\032\021sou" "rce_code.proto\032\023startup_times.proto\"&\n\rE" - "ventResponse\022\025\n\rerror_message\030\001 \001(\t2\371\006\n\r" + "ventResponse\022\025\n\rerror_message\030\001 \001(\t2\256\006\n\r" "NSolidService\022F\n\007Command\022\032.grpcagent.Com" "mandResponse\032\031.grpcagent.CommandRequest\"" "\000(\0010\001\022=\n\013ExportAsset\022\020.grpcagent.Asset\032\030" - ".grpcagent.EventResponse\"\000(\001\022I\n\027ExportCo" - "ntinuousProfile\022\020.grpcagent.Asset\032\030.grpc" - "agent.EventResponse\"\000(\001\022>\n\nExportExit\022\024." - "grpcagent.ExitEvent\032\030.grpcagent.EventRes" - "ponse\"\000\022>\n\nExportInfo\022\024.grpcagent.InfoEv" - "ent\032\030.grpcagent.EventResponse\"\000\022D\n\rExpor" - "tMetrics\022\027.grpcagent.MetricsEvent\032\030.grpc" - "agent.EventResponse\"\000\022F\n\016ExportPackages\022" - "\030.grpcagent.PackagesEvent\032\030.grpcagent.Ev" - "entResponse\"\000\022L\n\021ExportBlockedLoop\022\033.grp" - "cagent.BlockedLoopEvent\032\030.grpcagent.Even" - "tResponse\"\000\022P\n\023ExportUnblockedLoop\022\035.grp" - "cagent.UnblockedLoopEvent\032\030.grpcagent.Ev" - "entResponse\"\000\022L\n\021ExportReconfigure\022\033.grp" - "cagent.ReconfigureEvent\032\030.grpcagent.Even" - "tResponse\"\000\022J\n\020ExportSourceCode\022\032.grpcag" - "ent.SourceCodeEvent\032\030.grpcagent.EventRes" - "ponse\"\000\022N\n\022ExportStartupTimes\022\034.grpcagen" - "t.StartupTimesEvent\032\030.grpcagent.EventRes" - "ponse\"\000b\006proto3" + ".grpcagent.EventResponse\"\000(\001\022>\n\nExportEx" + "it\022\024.grpcagent.ExitEvent\032\030.grpcagent.Eve" + "ntResponse\"\000\022>\n\nExportInfo\022\024.grpcagent.I" + "nfoEvent\032\030.grpcagent.EventResponse\"\000\022D\n\r" + "ExportMetrics\022\027.grpcagent.MetricsEvent\032\030" + ".grpcagent.EventResponse\"\000\022F\n\016ExportPack" + "ages\022\030.grpcagent.PackagesEvent\032\030.grpcage" + "nt.EventResponse\"\000\022L\n\021ExportBlockedLoop\022" + "\033.grpcagent.BlockedLoopEvent\032\030.grpcagent" + ".EventResponse\"\000\022P\n\023ExportUnblockedLoop\022" + "\035.grpcagent.UnblockedLoopEvent\032\030.grpcage" + "nt.EventResponse\"\000\022L\n\021ExportReconfigure\022" + "\033.grpcagent.ReconfigureEvent\032\030.grpcagent" + ".EventResponse\"\000\022J\n\020ExportSourceCode\022\032.g" + "rpcagent.SourceCodeEvent\032\030.grpcagent.Eve" + "ntResponse\"\000\022N\n\022ExportStartupTimes\022\034.grp" + "cagent.StartupTimesEvent\032\030.grpcagent.Eve" + "ntResponse\"\000b\006proto3" ; static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2eproto_deps[10] = { &::descriptor_table_asset_2eproto, @@ -101,7 +99,7 @@ static const ::_pbi::DescriptorTable* const descriptor_table_nsolid_5fservice_2e }; static ::_pbi::once_flag descriptor_table_nsolid_5fservice_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_nsolid_5fservice_2eproto = { - false, false, 1135, descriptor_table_protodef_nsolid_5fservice_2eproto, + false, false, 1060, descriptor_table_protodef_nsolid_5fservice_2eproto, "nsolid_service.proto", &descriptor_table_nsolid_5fservice_2eproto_once, descriptor_table_nsolid_5fservice_2eproto_deps, 10, 1, schemas, file_default_instances, TableStruct_nsolid_5fservice_2eproto::offsets, From e5287ac5539d1bea2fc42384a0a28d8d02cac6bc Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:36 +0200 Subject: [PATCH 12/16] Revert "test: add continuous profiling configuration tests" This reverts commit 62a40a6b4ae89885ef75c1cf7607b57e3973c20f. --- ...-config-continuous-profiling-env-script.js | 18 ----- ...-nsolid-config-continuous-profiling-env.js | 70 ------------------- ...test-nsolid-config-continuous-profiling.js | 53 -------------- 3 files changed, 141 deletions(-) delete mode 100644 test/fixtures/test-nsolid-config-continuous-profiling-env-script.js delete mode 100644 test/parallel/test-nsolid-config-continuous-profiling-env.js delete mode 100644 test/parallel/test-nsolid-config-continuous-profiling.js diff --git a/test/fixtures/test-nsolid-config-continuous-profiling-env-script.js b/test/fixtures/test-nsolid-config-continuous-profiling-env-script.js deleted file mode 100644 index abf1a6ad3d..0000000000 --- a/test/fixtures/test-nsolid-config-continuous-profiling-env-script.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -// This script is used by test-nsolid-config-continuous-profiling-env.js -// to test environment variable configuration - -require('../common'); -const nsolid = require('nsolid'); - -// Start N-Solid with default configuration -nsolid.start(); - -// Output the configuration as JSON -console.log(JSON.stringify({ - contCpuProfile: nsolid.config.contCpuProfile, - contCpuProfileInterval: nsolid.config.contCpuProfileInterval, - contHeapProfile: nsolid.config.contHeapProfile, - contHeapProfileInterval: nsolid.config.contHeapProfileInterval -})); diff --git a/test/parallel/test-nsolid-config-continuous-profiling-env.js b/test/parallel/test-nsolid-config-continuous-profiling-env.js deleted file mode 100644 index e229d2add4..0000000000 --- a/test/parallel/test-nsolid-config-continuous-profiling-env.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -// This test verifies that continuous profiling configuration works -// correctly when set via environment variables - -require('../common'); -const assert = require('assert'); -const { spawnSync } = require('child_process'); -const path = require('path'); - -// Helper to run a small script with specific environment variables -function runWithEnv(envVars) { - const script = path.join(__dirname, '../fixtures/test-nsolid-config-continuous-profiling-env-script.js'); - - const result = spawnSync(process.execPath, [script], { - env: { - ...process.env, - ...envVars - }, - encoding: 'utf8' - }); - - if (result.status !== 0) { - console.error(result.stderr); - throw new Error(`Script execution failed with status ${result.status}`); - } - - return JSON.parse(result.stdout.trim()); -} - -// Test default values (when no environment variables are set) -{ - const config = runWithEnv({}); - assert.strictEqual(config.contCpuProfile, false); - assert.strictEqual(config.contCpuProfileInterval, 30000); // Default is 30 seconds -} - -// Test CPU continuous profiling configuration via environment variables -{ - const config = runWithEnv({ - NSOLID_CONT_CPU_PROFILE: 'true', - NSOLID_CONT_CPU_PROFILE_INTERVAL: '60000' - }); - assert.strictEqual(config.contCpuProfile, true); - assert.strictEqual(config.contCpuProfileInterval, 60000); -} - - -// Test boolean coercion for environment variables -{ - const config = runWithEnv({ - NSOLID_CONT_CPU_PROFILE: '1', - }); - assert.strictEqual(config.contCpuProfile, true); -} - -{ - const config = runWithEnv({ - NSOLID_CONT_CPU_PROFILE: 'yes' - }); - assert.strictEqual(config.contCpuProfile, true); -} - -// Test disabling via environment variables -{ - const config = runWithEnv({ - NSOLID_CONT_CPU_PROFILE: 'false', - }); - assert.strictEqual(config.contCpuProfile, false); -} diff --git a/test/parallel/test-nsolid-config-continuous-profiling.js b/test/parallel/test-nsolid-config-continuous-profiling.js deleted file mode 100644 index 25459b0b2d..0000000000 --- a/test/parallel/test-nsolid-config-continuous-profiling.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -require('../common'); -const assert = require('assert'); -const nsolid = require('nsolid'); - -// Test CPU continuous profiling configuration -nsolid.start({ - command: 9001, - contCpuProfile: true, - contCpuProfileInterval: 60000 -}); - -assert.strictEqual(nsolid.config.contCpuProfile, true); -assert.strictEqual(nsolid.config.contCpuProfileInterval, 60000); - -// Test changing CPU continuous profiling configuration -nsolid.start({ - contCpuProfile: false, - contCpuProfileInterval: 120000 -}); - -assert.strictEqual(nsolid.config.contCpuProfile, false); -assert.strictEqual(nsolid.config.contCpuProfileInterval, 120000); - -// Test enabling CPU continuous profiling -nsolid.start({ - contCpuProfile: true -}); - -assert.strictEqual(nsolid.config.contCpuProfile, true); -assert.strictEqual(nsolid.config.contCpuProfileInterval, 120000); - -// Test type coercion for boolean values -nsolid.start({ - contCpuProfile: 'true', -}); - -assert.strictEqual(nsolid.config.contCpuProfile, true); - -// Test type coercion for interval values -nsolid.start({ - contCpuProfileInterval: '45000', -}); - -assert.strictEqual(nsolid.config.contCpuProfileInterval, 45000); - -// Test disabling CPU profiling -nsolid.start({ - contCpuProfile: false, -}); - -assert.strictEqual(nsolid.config.contCpuProfile, false); From f6a70b036a1d73627099674a3fb42cbd44c497b0 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:38 +0200 Subject: [PATCH 13/16] Revert "src: integrate ContinuousProfiler with EnvList" This reverts commit 1ac895bc69883dba39030ba9e4d3f2eb387d2319. --- src/nsolid/nsolid_api.cc | 37 +------------------- src/nsolid/nsolid_api.h | 12 ------- test/addons/nsolid-dispatchqueue/binding.gyp | 1 - test/addons/nsolid-eventloop-cmd/binding.gyp | 1 - test/addons/nsolid-log-hooks/binding.gyp | 1 - test/addons/nsolid-statsdagent/binding.gyp | 1 - 6 files changed, 1 insertion(+), 52 deletions(-) diff --git a/src/nsolid/nsolid_api.cc b/src/nsolid/nsolid_api.cc index 7f13143492..7ebabe2766 100644 --- a/src/nsolid/nsolid_api.cc +++ b/src/nsolid/nsolid_api.cc @@ -3,7 +3,6 @@ #include "nsolid_bindings.h" #include "node_buffer.h" #include "nsolid_cpu_profiler.h" -#include "nsolid/continuous_profiler.h" #include "grpc/src/grpc_agent.h" #include "otlp/src/otlp_agent.h" #include "statsd/src/statsd_agent.h" @@ -864,7 +863,6 @@ EnvList::EnvList(): info_(nlohmann::json()) { CHECK_EQ(er, 0); er = thread_.create(env_list_routine_, this); CHECK_EQ(er, 0); - continuous_profiler_ = std::make_shared(&thread_loop_); } @@ -1142,9 +1140,8 @@ void EnvList::UpdateConfig(const nlohmann::json& config) { curr = current_config_; } - auto diff = nlohmann::json::diff(old, curr); // If the actual configuration hasn't changed, don't call the hook - if (!diff.empty()) { + if (!nlohmann::json::diff(old, curr).empty()) { current_config_version_++; auto it = config.find("promiseTracking"); if (it != config.end()) { @@ -1152,26 +1149,6 @@ void EnvList::UpdateConfig(const nlohmann::json& config) { PromiseTracking(tracking); } - if (old.empty() || - utils::find_any_fields_in_diff(diff, { "/contCpuProfile", - "/contCpuProfileInterval" })) { - bool contCpuProfile = false; - uint64_t contCpuProfileInterval = 60000; // Default: 1 minute - - it = curr.find("contCpuProfile"); - if (it != curr.end() && !it->is_null()) { - contCpuProfile = it->get(); - } - - it = curr.find("contCpuProfileInterval"); - if (it != curr.end() && !it->is_null()) { - contCpuProfileInterval = it->get(); - } - - // Update the continuous profiler with the new configuration - update_continuous_profiler(contCpuProfile, contCpuProfileInterval); - } - it = config.find("otlp"); if (it != config.end() && !it->is_null()) { otlp::OTLPAgent::Inst()->start(); @@ -1365,14 +1342,6 @@ void EnvList::UpdateTracingFlags(uint32_t flags) { } } -void EnvList::update_continuous_profiler(bool enabled, uint64_t interval) { - if (enabled) { - continuous_profiler_->Enable(interval); - } else { - continuous_profiler_->Disable(); - } -} - void EnvList::getAllEnvInst(std::function cb) { ns_mutex::scoped_lock lock(map_lock_); @@ -1613,9 +1582,6 @@ void EnvList::log_written_cb_(ns_async*, EnvList* envlist) { // registered users will need to receive their last set of metrics and a // notification that it'll be their last. void EnvList::removed_env_cb_(ns_async*, EnvList* envlist) { - if (envlist->continuous_profiler_) { - envlist->continuous_profiler_.reset(); - } envlist->removed_env_msg_.close(); envlist->process_callbacks_msg_.close(); envlist->log_written_msg_.close(); @@ -1652,7 +1618,6 @@ void EnvList::env_list_routine_(ns_thread*, EnvList* envlist) { CHECK_EQ(er, 0); }); CHECK_EQ(er, 0); - envlist->continuous_profiler_->Initialize(); er = uv_run(&envlist->thread_loop_, UV_RUN_DEFAULT); CHECK_EQ(er, 0); } diff --git a/src/nsolid/nsolid_api.h b/src/nsolid/nsolid_api.h index 3ef4af8238..0822d72d91 100644 --- a/src/nsolid/nsolid_api.h +++ b/src/nsolid/nsolid_api.h @@ -18,7 +18,6 @@ #include "node_snapshotable.h" #include "nsolid.h" #include "nsuv-inl.h" -#include "continuous_profiler.h" #include "nsolid_heap_snapshot.h" #include "nsolid_trace.h" #include "nsolid_util.h" @@ -55,7 +54,6 @@ namespace nsolid { class EnvInst; class EnvList; -class ContinuousProfiler; template @@ -603,11 +601,6 @@ class EnvList { NSolidHeapSnapshot* HeapSnapshot() { return &heap_snapshot_; } - // Get the ContinuousProfiler instance - std::shared_ptr GetContinuousProfiler() { - return continuous_profiler_; - } - private: friend class EnvInst; friend class Metrics; @@ -631,8 +624,6 @@ class EnvList { void fill_trace_id_q(); - void update_continuous_profiler(bool enabled, uint64_t interval); - #ifdef __POSIX__ static void signal_handler_(int signum, siginfo_t* info, void* ucontext); void setup_signal_handler(int signum); @@ -727,9 +718,6 @@ class EnvList { DispatchQueue span_item_q_; NSolidHeapSnapshot heap_snapshot_; - - // ContinuousProfiler instance - std::shared_ptr continuous_profiler_; }; diff --git a/test/addons/nsolid-dispatchqueue/binding.gyp b/test/addons/nsolid-dispatchqueue/binding.gyp index 79f1cee7e0..81f4b80796 100644 --- a/test/addons/nsolid-dispatchqueue/binding.gyp +++ b/test/addons/nsolid-dispatchqueue/binding.gyp @@ -7,7 +7,6 @@ 'defines': [ 'NODE_WANT_INTERNALS=1' ], 'include_dirs': [ '../../../deps/nsuv/include', - '../../../deps/protobuf/src', '../../../src/', ], 'cflags_cc': [ '-std=c++20' ], diff --git a/test/addons/nsolid-eventloop-cmd/binding.gyp b/test/addons/nsolid-eventloop-cmd/binding.gyp index 79f1cee7e0..81f4b80796 100644 --- a/test/addons/nsolid-eventloop-cmd/binding.gyp +++ b/test/addons/nsolid-eventloop-cmd/binding.gyp @@ -7,7 +7,6 @@ 'defines': [ 'NODE_WANT_INTERNALS=1' ], 'include_dirs': [ '../../../deps/nsuv/include', - '../../../deps/protobuf/src', '../../../src/', ], 'cflags_cc': [ '-std=c++20' ], diff --git a/test/addons/nsolid-log-hooks/binding.gyp b/test/addons/nsolid-log-hooks/binding.gyp index 79f1cee7e0..81f4b80796 100644 --- a/test/addons/nsolid-log-hooks/binding.gyp +++ b/test/addons/nsolid-log-hooks/binding.gyp @@ -7,7 +7,6 @@ 'defines': [ 'NODE_WANT_INTERNALS=1' ], 'include_dirs': [ '../../../deps/nsuv/include', - '../../../deps/protobuf/src', '../../../src/', ], 'cflags_cc': [ '-std=c++20' ], diff --git a/test/addons/nsolid-statsdagent/binding.gyp b/test/addons/nsolid-statsdagent/binding.gyp index caf15a7a81..7f91d5d608 100644 --- a/test/addons/nsolid-statsdagent/binding.gyp +++ b/test/addons/nsolid-statsdagent/binding.gyp @@ -7,7 +7,6 @@ 'include_dirs': [ '../../../src/', '../../../deps/nsuv/include/', - '../../../deps/protobuf/src', '../../../agents/statsd/src/', ], 'cflags_cc': [ '-std=c++20' ], From 761b4a479fd05c43b294895e317018914dab1c3b Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:39 +0200 Subject: [PATCH 14/16] Revert "lib: add continuous CPU profiling configuration" This reverts commit de4bf79d4bb6ae0e06e70c60dbaaa8cc9707498e. --- lib/nsolid.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/nsolid.js b/lib/nsolid.js index a673a97fbf..3e5e33c20a 100644 --- a/lib/nsolid.js +++ b/lib/nsolid.js @@ -697,10 +697,6 @@ function updateConfig(config = {}) { } else if (key === 'otlpConfig' && nsolidConfig.otlp) { nsolidConfig.otlpConfig = parseOTLPConfig(config.otlpConfig, nsolidConfig.otlp); - } else if (key === 'contCpuProfile') { - nsolidConfig.contCpuProfile = envToBool(config.contCpuProfile); - } else if (key === 'contCpuProfileInterval') { - nsolidConfig.contCpuProfileInterval = +config.contCpuProfileInterval; } else { nsolidConfig[key] = config[key]; } @@ -908,17 +904,6 @@ function initializeConfig(nsolidConfig) { envToBool(process.env.NSOLID_TRACK_GLOBAL_PACKAGES) || !!pkgConfig.nsolid.trackGlobalPackages; - // Continuous CPU Profiling - nsolidConfig.contCpuProfile = - envToBool(process.env.NSOLID_CONT_CPU_PROFILE) || - pkgConfig.nsolid.contCpuProfile || - false; - - nsolidConfig.contCpuProfileInterval = - +process.env.NSOLID_CONT_CPU_PROFILE_INTERVAL || - pkgConfig.nsolid.contCpuProfileInterval || - 30000; // Default: 30 seconds - // OTLP Agent configuration if (nsolidConfig.otlp) { const cfg = process.env.NSOLID_OTLP_CONFIG || pkgConfig.nsolid.otlpConfig; From c7981955374d827d197dabb2927091ade727086e Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:28:41 +0200 Subject: [PATCH 15/16] Revert "src: implement ContinuousProfiler class" This reverts commit 74bb08505bf67267fc84d96d892ee3c414628dd8. --- agents/src/profile_collector.h | 1 - node.gyp | 4 +- src/nsolid/continuous_profiler.cc | 268 ------------------------------ src/nsolid/continuous_profiler.h | 143 ---------------- 4 files changed, 1 insertion(+), 415 deletions(-) delete mode 100644 src/nsolid/continuous_profiler.cc delete mode 100644 src/nsolid/continuous_profiler.h diff --git a/agents/src/profile_collector.h b/agents/src/profile_collector.h index aa2989d5a1..f465d87cf8 100644 --- a/agents/src/profile_collector.h +++ b/agents/src/profile_collector.h @@ -32,7 +32,6 @@ extern const char* ProfileTypeStopStr[kNumberOfProfileTypes]; struct ProfileOptionsBase { uint64_t thread_id; uint64_t duration; - uint64_t start_timestamp; nlohmann::json metadata; google::protobuf::Struct metadata_pb; }; diff --git a/node.gyp b/node.gyp index 8715539a78..81aae53d63 100644 --- a/node.gyp +++ b/node.gyp @@ -512,13 +512,11 @@ 'agents/zmq/src/zmq_endpoint.h', 'agents/zmq/src/zmq_errors.h', 'src/nsolid.cc', - 'src/nsolid/continuous_profiler.cc', 'src/nsolid/nsolid_api.cc', 'src/nsolid/nsolid_trace.cc', 'src/nsolid/nsolid_cpu_profiler.cc', 'src/nsolid/nsolid_heap_snapshot.cc', - 'src/nsolid.h', - 'src/nsolid/continuous_profiler.h', + 'src/nsolid.h' 'src/nsolid/nsolid_api.h', 'src/nsolid/nsolid_output_stream.h', 'src/nsolid/nsolid_trace.h', diff --git a/src/nsolid/continuous_profiler.cc b/src/nsolid/continuous_profiler.cc deleted file mode 100644 index 93646a969a..0000000000 --- a/src/nsolid/continuous_profiler.cc +++ /dev/null @@ -1,268 +0,0 @@ -#include "continuous_profiler.h" -#include "asserts-cpp/asserts.h" - -namespace node { -namespace nsolid { - -ContinuousProfiler::ContinuousProfiler(uv_loop_t* loop): - loop_(loop), - enabled_(false), - prepare_(new nsuv::ns_prepare()), - next_callback_id_(1) { - ASSERT_EQ(0, thread_mutex_.init(true)); - ASSERT_EQ(0, callback_mutex_.init(true)); - ASSERT_EQ(0, prepare_->init(loop_)); -} - -ContinuousProfiler::~ContinuousProfiler() { - prepare_->close_and_delete(); -} - -void ContinuousProfiler::Initialize() { - // Create the profile collector - profile_collector_ = std::make_shared( - loop_, - [](const ProfileCollector::ProfileQStor& data, WeakContinuousProfiler wp) { - if (auto sp = wp.lock()) { - // Process the profile data - sp->on_profile_data(data); - - // Check if this is a profile completion (duration-based profile) - uint64_t thread_id = 0; - std::visit([&thread_id](auto& opt) { - thread_id = opt.thread_id; - }, data.options); - - // If the profile has completed (empty profile data indicates end of - // serialization) - if (data.profile.length() == 0 && data.status == 0) { - // Notify that the profile has completed for this thread - sp->on_profile_completed(thread_id); - } - } - }, - weak_from_this()); - - // Initialize thread hooks - ASSERT_EQ(0, ThreadAddedHook(thread_added_callback, weak_from_this())); - ASSERT_EQ(0, ThreadRemovedHook(thread_removed_callback, weak_from_this())); -} - -void ContinuousProfiler::Disable() { - nsuv::ns_mutex::scoped_lock lock(callback_mutex_); - enabled_ = false; - stop_if_needed(); -} - -void ContinuousProfiler::Enable(uint64_t interval_ms) { - nsuv::ns_mutex::scoped_lock lock(callback_mutex_); - enabled_ = true; - interval_ = interval_ms > 0 ? interval_ms : 60000; - start_if_needed(); -} - -bool ContinuousProfiler::IsEnabled() { - nsuv::ns_mutex::scoped_lock lock(callback_mutex_); - return enabled_ && !callbacks_.empty(); -} - -uint64_t ContinuousProfiler::register_hook_impl(ProfileHookCallback callback) { - if (callback == nullptr) { - return 0; // Invalid callback ID - } - - uint64_t id; - { - // Store the callback - nsuv::ns_mutex::scoped_lock lock(callback_mutex_); - - // Generate a unique ID for this callback inside the critical section - id = next_callback_id_++; - callbacks_[id] = std::move(callback); - - // Start profiling if enabled - start_if_needed(); - } - - return id; -} - -bool ContinuousProfiler::UnregisterHook(uint64_t hook_id) { - nsuv::ns_mutex::scoped_lock lock(callback_mutex_); - - // Erase the callback and return whether it was found - bool removed = callbacks_.erase(hook_id) > 0; - - // Stop profiling if needed - if (removed) { - stop_if_needed(); - } - - return removed; -} - -void ContinuousProfiler::start_if_needed() { - // This method should only be called while holding callback_mutex_ - - // Start profiling directly if we have callbacks and profiling is enabled - if (!callbacks_.empty() && enabled_) { - // Start profiling immediately - start_cpu_profiling(); - } -} - -void ContinuousProfiler::stop_if_needed() { - // This method should only be called while holding callback_mutex_ - - // Nothing to do here since we're not using a timer anymore - // Profiling will naturally stop when current profiles complete -} - -/*static*/ -void ContinuousProfiler::thread_added_callback(SharedEnvInst envinst, - WeakContinuousProfiler wp) { - if (auto sp = wp.lock()) { - sp->on_thread_added(envinst); - } -} - -/*static*/ -void ContinuousProfiler::thread_removed_callback(SharedEnvInst envinst, - WeakContinuousProfiler wp) { - if (auto sp = wp.lock()) { - sp->on_thread_removed(envinst); - } -} - -/*static*/ -void ContinuousProfiler::prepare_cb(nsuv::ns_prepare*, - WeakContinuousProfiler wp) { - if (auto sp = wp.lock()) { - sp->on_prepare(); - } -} - -void ContinuousProfiler::on_prepare() { - for (auto it = pending_threads_.begin(); it != pending_threads_.end(); ) { - uint64_t thread_id = *it; - int result = start_cpu_profiling_for_thread(thread_id); - if (result == 0) { - it = pending_threads_.erase(it); - } else { - ++it; - } - } - - if (pending_threads_.empty()) { - ASSERT_EQ(0, prepare_->stop()); - } -} - -void ContinuousProfiler::on_thread_added(SharedEnvInst envinst) { - uint64_t thread_id = GetThreadId(envinst); - { - nsuv::ns_mutex::scoped_lock lock(thread_mutex_); - thread_ids_.insert(thread_id); - } - - // If profiling is enabled, start profiling for this thread immediately - if (IsEnabled()) { - start_cpu_profiling_for_thread(thread_id); - } -} - -void ContinuousProfiler::on_thread_removed(SharedEnvInst envinst) { - nsuv::ns_mutex::scoped_lock lock(thread_mutex_); - uint64_t thread_id = GetThreadId(envinst); - thread_ids_.erase(thread_id); - currently_profiling_threads_.erase(thread_id); -} - -void ContinuousProfiler::on_profile_data( - const ProfileCollector::ProfileQStor& data) { - uint64_t thread_id = 0; - std::visit([&thread_id](auto& opt) { - thread_id = opt.thread_id; - }, data.options); - - // Make a copy of the callbacks map while holding the lock - std::unordered_map callbacks; - { - nsuv::ns_mutex::scoped_lock lock(callback_mutex_); - callbacks = callbacks_; - } - - // Deliver the profile data to all registered callbacks (outside the lock) - for (const auto& entry : callbacks) { - entry.second(data); - } -} - -void ContinuousProfiler::start_cpu_profiling() { - // Get a snapshot of the current thread IDs - std::unordered_set thread_ids; - std::unordered_set currently_profiling; - { - nsuv::ns_mutex::scoped_lock lock(thread_mutex_); - thread_ids = thread_ids_; - currently_profiling = currently_profiling_threads_; - } - - // Start CPU profiling for each thread that's not already being profiled - for (uint64_t thread_id : thread_ids) { - // Skip threads that are already being profiled - if (currently_profiling.find(thread_id) != currently_profiling.end()) { - continue; - } - - start_cpu_profiling_for_thread(thread_id); - } -} - -int ContinuousProfiler::start_cpu_profiling_for_thread(uint64_t thread_id) { - // Create CPU profile options - CPUProfileOptions options; - options.thread_id = thread_id; - options.duration = interval_; // Use the interval as the duration - options.start_timestamp = uv_hrtime(); - - // Start CPU profiling for this thread - int result = profile_collector_->StartCPUProfile(options); - - // If profiling started successfully, add to the currently profiling set - if (result == 0) { - nsuv::ns_mutex::scoped_lock lock(thread_mutex_); - currently_profiling_threads_.insert(thread_id); - } else { - // add thread_id to pending_threads - pending_threads_.insert(thread_id); - if (pending_threads_.size() == 1) { - ASSERT_EQ(0, prepare_->start(prepare_cb, weak_from_this())); - } - } - - return result; -} - -void ContinuousProfiler::on_profile_completed(uint64_t thread_id) { - // Remove thread from currently profiling set - bool thread_exists = false; - { - nsuv::ns_mutex::scoped_lock lock(thread_mutex_); - currently_profiling_threads_.erase(thread_id); - thread_exists = thread_ids_.find(thread_id) != thread_ids_.end(); - } - - // If the thread no longer exists, don't restart profiling - if (!thread_exists) { - return; - } - - // If profiling is still enabled, start a new profile for this thread - if (IsEnabled()) { - start_cpu_profiling_for_thread(thread_id); - } -} - -} // namespace nsolid -} // namespace node diff --git a/src/nsolid/continuous_profiler.h b/src/nsolid/continuous_profiler.h deleted file mode 100644 index 6cb7aaef53..0000000000 --- a/src/nsolid/continuous_profiler.h +++ /dev/null @@ -1,143 +0,0 @@ -#ifndef SRC_NSOLID_CONTINUOUS_PROFILER_H_ -#define SRC_NSOLID_CONTINUOUS_PROFILER_H_ - -#include "nsolid_api.h" -#include -#include -#include "../../agents/src/profile_collector.h" -#include "nsuv-inl.h" -#include -#include -#include -#include -#include - -namespace node { -namespace nsolid { - -class ContinuousProfiler; - -using SharedContinuousProfiler = std::shared_ptr; -using WeakContinuousProfiler = std::weak_ptr; - -/** - * ContinuousProfiler is a class that periodically collects - * CPU profiles for all active JS threads and sends them via registered - * callbacks. - * - * The profiler is disabled by default and must be enabled via - * SetProfilingEnabled(). It will only collect profiles when both: - * 1. Profiling is enabled via SetProfilingEnabled() - * 2. There is at least one registered hook - */ -class ContinuousProfiler : - public std::enable_shared_from_this { - public: - // Profile data callback type - using ProfileHookCallback = std::function; - - // Constructor - explicit ContinuousProfiler(uv_loop_t* loop); - - // Initialize the profiler - void Initialize(); - - // Enable/disable profiling (disabled by default) - void Disable(); - void Enable(uint64_t interval_ms = 60000); - bool IsEnabled(); - - // Register a hook for profile data - // Returns a unique ID that can be used to unregister the hook - template - uint64_t RegisterHook(Cb&& cb, Data&&... data) { - // Create the bound callback with additional parameters - auto bound_cb = std::bind( - std::forward(cb), - std::placeholders::_1, - std::forward(data)...); - - // Convert to ProfileHookCallback type and register - return register_hook_impl( - [bound_cb](const ProfileCollector::ProfileQStor& profile_data) { - bound_cb(profile_data); - }); - } - - // Unregister a hook by its ID - // Returns true if the hook was found and removed - bool UnregisterHook(uint64_t hook_id); - - // Destructor - ~ContinuousProfiler(); - - private: - // Prevent copying, assignment, and move - ContinuousProfiler(const ContinuousProfiler&) = delete; - ContinuousProfiler& operator=(const ContinuousProfiler&) = delete; - ContinuousProfiler(ContinuousProfiler&&) = delete; - ContinuousProfiler& operator=(ContinuousProfiler&&) = delete; - - // Start the profiler if there are callbacks registered and profiling is - // enabled - void start_if_needed(); - - // Stop the profiler if there are no callbacks or profiling is disabled - void stop_if_needed(); - - // Thread hooks - static void thread_added_callback(SharedEnvInst envinst, - WeakContinuousProfiler wp); - static void thread_removed_callback(SharedEnvInst envinst, - WeakContinuousProfiler wp); - - static void prepare_cb(nsuv::ns_prepare* prepare, WeakContinuousProfiler wp); - - // Thread event handlers - void on_thread_added(SharedEnvInst envinst); - void on_thread_removed(SharedEnvInst envinst); - - void on_prepare(); - - // Profile collector callback - void on_profile_data(const ProfileCollector::ProfileQStor& data); - - // Start profiling for all threads - void start_cpu_profiling(); - - // Start profiling for a specific thread - int start_cpu_profiling_for_thread(uint64_t thread_id); - - // Handle profile completion and start a new one if needed - void on_profile_completed(uint64_t thread_id); - - // Implementation of RegisterHook - uint64_t register_hook_impl(ProfileHookCallback callback); - - // Loop - uv_loop_t* loop_ = nullptr; - uint64_t interval_ = 60000; // Default: 1 minute per configuration - bool enabled_ = false; // Disabled by default per config - - // Thread management - nsuv::ns_mutex thread_mutex_; - std::unordered_set thread_ids_; - std::unordered_set currently_profiling_threads_; - std::unordered_set pending_threads_; - - nsuv::ns_prepare* prepare_; - - // Callback management - nsuv::ns_mutex callback_mutex_; - std::unordered_map callbacks_; - uint64_t next_callback_id_ = 1; - - // Profile collector - std::shared_ptr profile_collector_; -}; - -} // namespace nsolid -} // namespace node - -#endif // SRC_NSOLID_CONTINUOUS_PROFILER_H_ From 20658693b707b36ea016249a2340b937be681b41 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Thu, 15 May 2025 16:30:23 +0200 Subject: [PATCH 16/16] 2025-05-15, Version 22.15.1-nsolid-v5.7.2 'Jod' --- doc/changelogs/NSOLID_CHANGELOG_V5_NODE_V22.md | 6 ++++++ src/node_version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/changelogs/NSOLID_CHANGELOG_V5_NODE_V22.md b/doc/changelogs/NSOLID_CHANGELOG_V5_NODE_V22.md index 304ce8af56..3f2dd3254c 100644 --- a/doc/changelogs/NSOLID_CHANGELOG_V5_NODE_V22.md +++ b/doc/changelogs/NSOLID_CHANGELOG_V5_NODE_V22.md @@ -2,6 +2,12 @@ +## 2025-05-15, Version 22.15.1-nsolid-v5.7.2 'Jod' + +### Commits + +* \[[`255e93ff55`](https://github.com/nodesource/nsolid/commit/255e93ff55)] - Merge tag 'v22.15.1' into node-v22.x-nsolid-v5.x (Santiago Gimeno) + ## 2025-05-07, Version 22.15.0-nsolid-v5.7.1 'Jod' ### Commits diff --git a/src/node_version.h b/src/node_version.h index 0cbc0acae8..4669b465b5 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -36,7 +36,7 @@ #define NSOLID_MINOR_VERSION 7 #define NSOLID_PATCH_VERSION 2 -#define NSOLID_VERSION_IS_RELEASE 0 +#define NSOLID_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)