Copilot commented on code in PR #3516:
URL: https://github.com/apache/brpc/pull/3516#discussion_r3950278473


##########
test/fuzzing/fuzz_rtmp.cpp:
##########
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "brpc/policy/rtmp_protocol.h"
+#include "brpc/rtmp.h"
+#include "brpc/server.h"
+#include "butil/iobuf.h"
+#include "fuzz_common.h"
+
+#define kMinInputLength 5
+#define kMaxInputLength 4096
+
+namespace {
+
+class FuzzRtmpService : public brpc::RtmpService {
+public:
+    brpc::RtmpServerStream* NewStream(const brpc::RtmpConnectRequest&) 
override {
+        return nullptr;
+    }
+};
+
+brpc::Server* get_fuzz_server() {
+    static brpc::Server* started = []() -> brpc::Server* {
+        static FuzzRtmpService rtmp_service;
+        static brpc::Server server;
+        brpc::ServerOptions options;
+        options.rtmp_service = &rtmp_service;
+        if (server.Start(brpc::PortRange(20000, 29999), &options) != 0) {
+            // Fall back to a context with no service

Review Comment:
   `get_fuzz_server()` starts a full brpc::Server with default options and a 
fixed port range. For fuzzing this adds unnecessary startup overhead (builtin 
services + many worker threads) and increases the chance that the start fails 
due to port-range exhaustion, which would reduce coverage.
   
   Consider using an ephemeral port (0) and minimizing server options since the 
fuzzer only needs `ServerOptions.rtmp_service` to be populated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to