Coverage Report

Created: 2026-12-01 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl_fuzzer/proto_fuzzer/pingpong_mock_server.cc
Line
Count
Source
1
/*
2
 * Copyright (C) Max Dymond, <cmeister2@gmail.com>, et al.
3
 *
4
 * SPDX-License-Identifier: curl
5
 */
6
7
/// @file
8
/// @brief Implementation of the shared line-oriented pingpong peer.
9
10
#include "proto_fuzzer/pingpong_mock_server.h"
11
12
#include <algorithm>
13
#include <cstddef>
14
#include <cstdint>
15
#include <limits>
16
#include <memory>
17
#include <string>
18
#include <string_view>
19
20
#include "proto_fuzzer/mock_server.h"
21
22
namespace proto_fuzzer {
23
24
/// Construct the shared transport state without a borrowed protobuf or open
25
/// socketpair. RunLoop borrows a Scenario only for the synchronous
26
/// DriveScenario call in which socket callbacks can run.
27
/// @param drive_policy Multi-loop policy inherited from MockServerBase.
28
PingpongMockServer::PingpongMockServer(MultiDrivePolicy drive_policy)
29
29.1k
    : MockServerBase(drive_policy),
30
29.1k
      scenario_(nullptr),
31
29.1k
      control_reply_count_(0),
32
29.1k
      next_control_reply_(0),
33
29.1k
      active_pollset_probe_count_(0),
34
29.1k
      writable_pollset_probe_count_(0),
35
29.1k
      body_length_remaining_(0),
36
29.1k
      body_terminator_remaining_(0),
37
29.1k
      body_mode_(BodyMode::kCommand),
38
29.1k
      control_socket_(CURL_SOCKET_BAD),
39
29.1k
      control_opened_(false) {}
40
41
/// Release the server-owned socketpair half after curl has returned its client
42
/// descriptor. The out-of-line destructor keeps MockConnection's complete type
43
/// local to this translation unit.
44
29.1k
PingpongMockServer::~PingpongMockServer() = default;
45
46
/// Expose the bounded command capture from the most recent drive so tests can
47
/// verify protocol states without coupling assertions to curl debug output.
48
/// @return A prefix of complete control commands, including line endings.
49
29.0k
const std::string& PingpongMockServer::control_transcript() const { return control_transcript_; }
50
51
/// Expose a bounded prefix of bytes drained during the most recent body phase
52
/// while continuing to drain every client byte, so test observability cannot
53
/// create backpressure.
54
/// @return Body bytes curl sent, or an empty string when the peer has no
55
///         upload direction.
56
20.0k
const std::string& PingpongMockServer::uploaded_data() const { return uploaded_data_; }
57
58
/// Report how many requested zero-timeout multi-poll probes ran during the
59
/// most recent drive. RunLoop increments this only after a successful perform
60
/// turn while curl still owns an active transfer and the control socket is
61
/// open, making the count a focused test assertion rather than a syscall
62
/// counter for default scenarios.
63
/// @return Number of active, connected pollset probes in the previous drive.
64
0
std::size_t PingpongMockServer::active_pollset_probe_count() const { return active_pollset_probe_count_; }
65
66
/// Report how often curl retained writable interest while the peer held an
67
/// incomplete control command. Send-pressure tests use this conjunction to
68
/// prove a protocol write remained pending rather than counting generic
69
/// perform turns or transient writable states.
70
/// @return Writable pollset observations in the previous drive.
71
0
std::size_t PingpongMockServer::writable_pollset_probe_count() const { return writable_pollset_probe_count_; }
72
73
/// Create the default plaintext transport. The SMTPS subclass overrides this
74
/// factory while retaining the command/reply parser.
75
/// @return A new socketpair-backed connection.
76
15.7k
std::unique_ptr<MockConnection> PingpongMockServer::CreateConnection() { return std::make_unique<MockConnection>(); }
77
78
/// Enter marker-terminated body mode. The marker and any body bytes before it
79
/// are captured together, matching SMTP's inclusion of its end-of-body CRLF.
80
/// @param terminator Byte sequence that ends the body phase.
81
968
void PingpongMockServer::BeginMarkerBody(std::string_view terminator) {
82
968
  body_mode_ = BodyMode::kMarker;
83
968
  body_marker_.assign(terminator.data(), terminator.size());
84
968
  body_length_remaining_ = 0;
85
968
  body_terminator_remaining_ = 0;
86
968
}
87
88
/// Enter length-announced literal body mode. Exactly `length` bytes are
89
/// captured; the CRLF that follows the literal is consumed but not captured.
90
/// A zero length is valid and waits directly for that terminator.
91
/// @param length Announced literal byte count.
92
1.05k
void PingpongMockServer::BeginLiteralBody(std::size_t length) {
93
1.05k
  body_mode_ = BodyMode::kLiteral;
94
1.05k
  body_marker_.clear();
95
1.05k
  body_length_remaining_ = length;
96
1.05k
  body_terminator_remaining_ = 2;
97
1.05k
}
98
99
/// Enter exact-length body mode. Exactly `length` bytes are captured and no
100
/// terminator is consumed, so the next byte after the body starts the next
101
/// command. A zero length completes immediately.
102
/// @param length Announced body byte count.
103
876
void PingpongMockServer::BeginExactBody(std::size_t length) {
104
876
  body_mode_ = BodyMode::kExact;
105
876
  body_marker_.clear();
106
876
  body_length_remaining_ = length;
107
876
  body_terminator_remaining_ = 0;
108
876
}
109
110
/// Enter an opaque drain after a transport upgrade. Every subsequent carrier
111
/// byte is consumed without command parsing or test-facing capture.
112
13
void PingpongMockServer::BeginOpaqueDrain() {
113
13
  body_mode_ = BodyMode::kOpaque;
114
13
  body_marker_.clear();
115
13
  body_length_remaining_ = 0;
116
13
  body_terminator_remaining_ = 0;
117
13
}
118
119
/// Append decoded application bytes to the pending parser buffer. The outer
120
/// service loop drains this buffer after every transport call, so it remains
121
/// bounded by the scenario's command and upload budgets.
122
/// @param data First decoded byte.
123
/// @param size Number of bytes available at `data`.
124
147k
void PingpongMockServer::ObserveIncomingData(const unsigned char* data, std::size_t size) {
125
147k
  if (data == nullptr || size == 0) {
126
0
    return;
127
0
  }
128
147k
  pending_control_bytes_.append(reinterpret_cast<const char*>(data), size);
129
147k
}
130
131
/// Create the single control socketpair and queue the server greeting. These
132
/// peers never open a second application socket, so any later request is
133
/// rejected rather than silently replacing the live peer.
134
/// @param purpose Socket role requested by curl.
135
/// @param address Unused stream destination metadata required by the callback
136
///                signature.
137
/// @return Client descriptor for the control channel, or CURL_SOCKET_BAD.
138
27.5k
curl_socket_t PingpongMockServer::HandleOpenSocket(curlsocktype purpose, struct curl_sockaddr* /*address*/) {
139
27.5k
  if (scenario_ == nullptr || purpose != CURLSOCKTYPE_IPCXN || control_opened_) {
140
0
    return CURL_SOCKET_BAD;
141
0
  }
142
143
27.5k
  connection_ = CreateConnection();
144
27.5k
  if (!connection_ || !connection_->ok()) {
145
0
    connection_.reset();
146
0
    return CURL_SOCKET_BAD;
147
0
  }
148
27.5k
  connection_->SetIncomingDataObserver(this);
149
150
27.5k
  ApplyScriptBackpressure(connection_.get(), scenario_->connection());
151
27.5k
  const std::string& greeting = scenario_->connection().initial_response();
152
27.5k
  if (!greeting.empty() &&
153
9.28k
      !connection_->WriteAll(reinterpret_cast<const unsigned char*>(greeting.data()), greeting.size())) {
154
0
    connection_.reset();
155
0
    return CURL_SOCKET_BAD;
156
0
  }
157
158
27.5k
  control_opened_ = true;
159
27.5k
  control_socket_ = connection_->take_client_fd();
160
27.5k
  return control_socket_;
161
27.5k
}
162
163
/// Reset every borrowed pointer, descriptor, parser cursor, and observable
164
/// capture before borrowing the next Scenario, then let the subclass clear its
165
/// own protocol state.
166
/// @param scenario Scenario whose Connection supplies the greeting and replies.
167
29.9k
void PingpongMockServer::ResetForScenario(const curl::fuzzer::proto::Scenario& scenario) {
168
29.9k
  connection_.reset();
169
29.9k
  scenario_ = &scenario;
170
29.9k
  control_reply_count_ = std::min<std::size_t>(scenario_limits::kMaxResponseChunks,
171
29.9k
                                               static_cast<std::size_t>(scenario.connection().on_readable_size()));
172
29.9k
  next_control_reply_ = 0;
173
29.9k
  pending_control_bytes_.clear();
174
29.9k
  control_transcript_.clear();
175
29.9k
  uploaded_data_.clear();
176
29.9k
  active_pollset_probe_count_ = 0;
177
29.9k
  writable_pollset_probe_count_ = 0;
178
29.9k
  body_marker_.clear();
179
29.9k
  body_length_remaining_ = 0;
180
29.9k
  body_terminator_remaining_ = 0;
181
29.9k
  body_mode_ = BodyMode::kCommand;
182
29.9k
  control_socket_ = CURL_SOCKET_BAD;
183
29.9k
  control_opened_ = false;
184
29.9k
  ResetProtocolState();
185
29.9k
}
186
187
/// Apply bounded transport knobs when creating the scripted socket. Fast IMAP
188
/// and POP3 retain bounded receive-buffer pressure; direct corpus replay must
189
/// also retain deterministic, well-defined behavior.
190
/// @param connection Peer receiving the socket settings.
191
/// @param script Connection script carrying optional backpressure values.
192
void PingpongMockServer::ApplyScriptBackpressure(MockConnection* connection,
193
27.5k
                                                 const curl::fuzzer::proto::Connection& script) {
194
27.5k
  if (connection == nullptr) {
195
0
    return;
196
0
  }
197
198
27.5k
  const std::uint32_t int_max = static_cast<std::uint32_t>(std::numeric_limits<int>::max());
199
27.5k
  const auto& backpressure = script.backpressure();
200
27.5k
  const int receive_buffer = static_cast<int>(std::min(backpressure.recv_buf_bytes(), int_max));
201
27.5k
  connection->ApplyBackpressure(receive_buffer, static_cast<std::size_t>(backpressure.drain_limit()));
202
27.5k
}
203
204
/// Return the next command-aligned response within the shared response-count
205
/// budget. Empty strings still advance the cursor: they are meaningful
206
/// truncation mutations for ordinary command states.
207
/// @return Scenario-owned reply, or nullptr after the bounded prefix.
208
948k
const std::string* PingpongMockServer::NextControlReply() {
209
948k
  if (scenario_ == nullptr || next_control_reply_ >= control_reply_count_) {
210
914k
    return nullptr;
211
914k
  }
212
33.9k
  return &scenario_->connection().on_readable(static_cast<int>(next_control_reply_++));
213
948k
}
214
215
/// Keep failed peer writes local to the mock. Response cursors must still
216
/// advance after curl closes early, otherwise a replacement socket could see
217
/// a reply intended for an earlier command.
218
/// @param bytes Response fragment to queue.
219
/// @return true when the complete fragment was queued.
220
49.9k
bool PingpongMockServer::WriteControlBytes(std::string_view bytes) {
221
49.9k
  return bytes.empty() || (connection_ != nullptr &&
222
48.9k
                           connection_->WriteAll(reinterpret_cast<const unsigned char*>(bytes.data()), bytes.size()));
223
49.9k
}
224
225
/// Consume the next scripted reply. Protocol peers use this when the reply
226
/// that completes an upload must be queued at command-acceptance time because
227
/// curl performs a blocking completion wait.
228
/// @return true when a scripted reply existed and was successfully written.
229
21.7k
bool PingpongMockServer::WriteNextReply() {
230
21.7k
  const std::string* response = NextControlReply();
231
21.7k
  return response == nullptr ? false : WriteControlBytes(*response);
232
21.7k
}
233
234
/// Half-close the server-to-client direction while retaining the read half.
235
/// STARTTLS peers use this after their plaintext acceptance response so curl's
236
/// newly installed TLS filter observes deterministic EOF instead of waiting.
237
13
void PingpongMockServer::ShutdownControlWrite() {
238
13
  if (connection_ != nullptr) {
239
13
    connection_->ShutdownWrite();
240
13
  }
241
13
}
242
243
/// Remove optional leading horizontal whitespace and return the first token
244
/// without allocating. Protocol arguments are never interpreted here.
245
/// @param line Complete command line.
246
/// @return View of its first non-whitespace token.
247
939k
std::string_view PingpongMockServer::FirstToken(std::string_view line) {
248
939k
  std::size_t begin = 0;
249
1.17M
  while (begin < line.size() && (line[begin] == ' ' || line[begin] == '\t')) {
250
231k
    ++begin;
251
231k
  }
252
253
939k
  std::size_t end = begin;
254
56.6M
  while (end < line.size() && line[end] != ' ' && line[end] != '\t' && line[end] != '\r' && line[end] != '\n') {
255
55.7M
    ++end;
256
55.7M
  }
257
939k
  return line.substr(begin, end - begin);
258
939k
}
259
260
/// Skip the first token and return the second whitespace-delimited token
261
/// without allocating. IMAP uses this to read the verb after the command tag.
262
/// @param line Complete command line.
263
/// @return View of its second whitespace-delimited token, or an empty view.
264
31.4k
std::string_view PingpongMockServer::SecondToken(std::string_view line) {
265
31.4k
  std::size_t position = 0;
266
85.4k
  while (position < line.size() && (line[position] == ' ' || line[position] == '\t')) {
267
54.0k
    ++position;
268
54.0k
  }
269
7.23M
  while (position < line.size() && line[position] != ' ' && line[position] != '\t' && line[position] != '\r' &&
270
7.20M
         line[position] != '\n') {
271
7.20M
    ++position;
272
7.20M
  }
273
55.8k
  while (position < line.size() && (line[position] == ' ' || line[position] == '\t')) {
274
24.4k
    ++position;
275
24.4k
  }
276
277
31.4k
  std::size_t end = position;
278
210k
  while (end < line.size() && line[end] != ' ' && line[end] != '\t' && line[end] != '\r' && line[end] != '\n') {
279
178k
    ++end;
280
178k
  }
281
31.4k
  return line.substr(position, end - position);
282
31.4k
}
283
284
/// Fold only ASCII lowercase command letters. Protocol verbs are ASCII tokens,
285
/// so locale-aware case conversion would add state and undefined signed-char
286
/// behavior without accepting anything curl can legitimately send.
287
/// @param token Parsed command token.
288
/// @param expected_uppercase Literal uppercase command name.
289
/// @return true when the tokens are equal ignoring ASCII case.
290
68.5k
bool PingpongMockServer::TokenEquals(std::string_view token, std::string_view expected_uppercase) {
291
68.5k
  if (token.size() != expected_uppercase.size()) {
292
30.1k
    return false;
293
30.1k
  }
294
95.3k
  for (std::size_t index = 0; index < token.size(); ++index) {
295
84.4k
    unsigned char actual = static_cast<unsigned char>(token[index]);
296
84.4k
    if (actual >= 'a' && actual <= 'z') {
297
689
      actual = static_cast<unsigned char>(actual - 'a' + 'A');
298
689
    }
299
84.4k
    if (actual != static_cast<unsigned char>(expected_uppercase[index])) {
300
27.5k
      return false;
301
27.5k
    }
302
84.4k
  }
303
10.8k
  return true;
304
38.4k
}
305
306
/// Retain only a bounded prefix for assertions. Parsing and draining continue
307
/// against the full transport bytes, so reaching the cap cannot change curl's
308
/// behavior or manufacture socket backpressure.
309
/// @param source Newly observed bytes.
310
/// @param limit Maximum retained destination size.
311
/// @param destination Capture buffer receiving the available prefix.
312
1.02M
void PingpongMockServer::CapturePrefix(std::string_view source, std::size_t limit, std::string* destination) {
313
1.02M
  if (destination == nullptr || destination->size() >= limit) {
314
395k
    return;
315
395k
  }
316
631k
  const std::size_t available = limit - destination->size();
317
631k
  destination->append(source.data(), std::min(source.size(), available));
318
631k
}
319
320
/// Advance the carrier without waiting, then process every complete command or
321
/// body segment already decoded into the pending buffer. A plaintext
322
/// connection yields raw socket bytes; a TLS carrier completes its handshake
323
/// and yields decrypted application bytes through ObserveIncomingData.
324
/// @return true when bytes, transport state, or a command/reply cursor advanced.
325
327k
bool PingpongMockServer::ServiceControlConnection() {
326
327k
  if (connection_ == nullptr) {
327
11.2k
    return false;
328
11.2k
  }
329
330
315k
  const std::size_t size_before_read = pending_control_bytes_.size();
331
315k
  const std::size_t transport_progress = connection_->DrainIncoming();
332
315k
  bool made_progress = pending_control_bytes_.size() != size_before_read || transport_progress != 0;
333
334
315k
  std::size_t consumed = 0;
335
1.34M
  while (consumed < pending_control_bytes_.size()) {
336
1.07M
    if (body_mode_ == BodyMode::kOpaque) {
337
19
      consumed = pending_control_bytes_.size();
338
19
      made_progress = true;
339
19
      break;
340
19
    }
341
342
1.07M
    if (body_mode_ == BodyMode::kMarker) {
343
20.2k
      const std::size_t marker = pending_control_bytes_.find(body_marker_, consumed);
344
20.2k
      if (marker == std::string::npos) {
345
19.4k
        break;
346
19.4k
      }
347
759
      const std::size_t body_end = marker + body_marker_.size();
348
759
      CapturePrefix(std::string_view(pending_control_bytes_.data() + consumed, body_end - consumed),
349
759
                    kMaxCapturedUploadBytes, &uploaded_data_);
350
759
      consumed = body_end;
351
759
      body_mode_ = BodyMode::kCommand;
352
759
      made_progress = true;
353
759
      HandleBodyComplete();
354
759
      continue;
355
20.2k
    }
356
357
1.05M
    if (body_mode_ == BodyMode::kExact) {
358
1.20k
      const std::size_t available = pending_control_bytes_.size() - consumed;
359
1.20k
      const std::size_t take = std::min(available, body_length_remaining_);
360
1.20k
      CapturePrefix(std::string_view(pending_control_bytes_.data() + consumed, take), kMaxCapturedUploadBytes,
361
1.20k
                    &uploaded_data_);
362
1.20k
      consumed += take;
363
1.20k
      body_length_remaining_ -= take;
364
1.20k
      if (take != 0) {
365
1.20k
        made_progress = true;
366
1.20k
      }
367
1.20k
      if (body_length_remaining_ == 0) {
368
603
        body_mode_ = BodyMode::kCommand;
369
603
        made_progress = true;
370
603
        HandleBodyComplete();
371
603
        continue;
372
603
      }
373
603
      break;
374
1.20k
    }
375
376
1.05M
    if (body_mode_ == BodyMode::kLiteral) {
377
20.5k
      if (body_length_remaining_ != 0) {
378
19.9k
        const std::size_t available = pending_control_bytes_.size() - consumed;
379
19.9k
        const std::size_t take = std::min(available, body_length_remaining_);
380
19.9k
        CapturePrefix(std::string_view(pending_control_bytes_.data() + consumed, take), kMaxCapturedUploadBytes,
381
19.9k
                      &uploaded_data_);
382
19.9k
        consumed += take;
383
19.9k
        body_length_remaining_ -= take;
384
19.9k
        made_progress = true;
385
19.9k
        continue;
386
19.9k
      }
387
388
543
      const std::size_t available = pending_control_bytes_.size() - consumed;
389
543
      if (body_terminator_remaining_ == 2 && available >= 2 && pending_control_bytes_[consumed] == '\r' &&
390
540
          pending_control_bytes_[consumed + 1] == '\n') {
391
540
        consumed += 2;
392
540
        body_terminator_remaining_ = 0;
393
540
        body_mode_ = BodyMode::kCommand;
394
540
        made_progress = true;
395
540
        HandleBodyComplete();
396
540
        continue;
397
540
      }
398
3
      if (available >= 1) {
399
3
        const char byte = pending_control_bytes_[consumed];
400
3
        if (byte == '\r' || byte == '\n') {
401
1
          ++consumed;
402
1
          if (byte == '\n' || body_terminator_remaining_ == 0) {
403
1
            body_terminator_remaining_ = 0;
404
1
            body_mode_ = BodyMode::kCommand;
405
1
            HandleBodyComplete();
406
1
          } else {
407
0
            body_terminator_remaining_ = 1;
408
0
          }
409
1
          made_progress = true;
410
1
          continue;
411
1
        }
412
        // No terminating empty line is recognisable. Resume command parsing so
413
        // malformed uploads still make bounded progress.
414
2
        body_terminator_remaining_ = 0;
415
2
        body_mode_ = BodyMode::kCommand;
416
2
        continue;
417
3
      }
418
0
      break;
419
3
    }
420
421
1.03M
    const std::size_t newline = pending_control_bytes_.find('\n', consumed);
422
1.03M
    if (newline == std::string::npos) {
423
32.3k
      break;
424
32.3k
    }
425
1.00M
    const std::size_t command_size = newline - consumed + 1;
426
1.00M
    const std::string_view command(pending_control_bytes_.data() + consumed, command_size);
427
1.00M
    CapturePrefix(command, kMaxCapturedControlBytes, &control_transcript_);
428
1.00M
    HandleLine(command);
429
1.00M
    consumed += command_size;
430
1.00M
    made_progress = true;
431
1.00M
  }
432
433
315k
  if (consumed != 0) {
434
75.0k
    pending_control_bytes_.erase(0, consumed);
435
75.0k
  }
436
315k
  return made_progress;
437
327k
}
438
439
/// Prepare cleanup while the mock can still write to curl's control socket.
440
/// Let the peer queue its protocol-specific liveness reply, then half-close so
441
/// an unfinished transfer cannot wait on a reply that will never arrive.
442
29.9k
void PingpongMockServer::FinishConnections() {
443
29.9k
  if (connection_ != nullptr) {
444
27.5k
    QueueShutdownReply();
445
27.5k
    connection_->ShutdownWrite();
446
27.5k
  }
447
29.9k
}
448
449
/// Give curl's graceful shutdown one last chance to emit its teardown command
450
/// while the peer still owns its read half, then release the multi as the base
451
/// class would. The matching liveness reply was already queued by
452
/// FinishConnections.
453
/// @param multi Detached multi handle whose connection cache may be shutting
454
///              the protocol connection down.
455
27.0k
void PingpongMockServer::HandleDetachedMulti(CurlMultiPtr multi) {
456
27.0k
  multi.reset();
457
27.0k
  (void)ServiceControlConnection();
458
27.0k
}
459
460
/// Alternate curl transitions with immediate peer service until the transfer
461
/// completes or deterministic idle/operation caps win. No select(), poll(), or
462
/// sleep is needed: every transport is in-process, and malformed scripts are
463
/// terminated by half-close after the bounded loop.
464
/// @param multi Multi handle containing `easy`.
465
/// @param easy Easy handle already installed on this mock.
466
/// @param scenario Control script to borrow.
467
29.9k
void PingpongMockServer::RunLoop(CURLM* multi, CURL* easy, const curl::fuzzer::proto::Scenario& scenario) {
468
29.9k
  (void)easy;
469
29.9k
  ResetForScenario(scenario);
470
471
29.9k
  int still_running = 1;
472
29.9k
  int idle_iterations = 0;
473
29.9k
  int drive_iterations = 0;
474
29.9k
  CURLMcode result = CURLM_OK;
475
300k
  while (still_running && idle_iterations < kMaxIdleIterations && drive_iterations++ < kMaxDriveIterations) {
476
270k
    const int running_before = still_running;
477
270k
    result = curl_multi_perform(multi, &still_running);
478
270k
    if (result != CURLM_OK) {
479
0
      break;
480
0
    }
481
482
    // Pollset construction is coverage work, not part of the default driver:
483
    // keep the extra public-API call behind the scenario opt-in. Waiting until
484
    // the socket callback has run and the transfer remains active ensures the
485
    // pollset belongs to a live protocol state rather than setup or cleanup.
486
270k
    if (scenario.probe_multi_pollset() && still_running && control_opened_) {
487
33.0k
      ProbeMultiPollset(multi);
488
33.0k
      ++active_pollset_probe_count_;
489
33.0k
      const bool incomplete_command = body_mode_ == BodyMode::kCommand && !pending_control_bytes_.empty() &&
490
11.4k
                                      pending_control_bytes_.find('\n') == std::string::npos;
491
33.0k
      if (incomplete_command && MultiPollsetWantsWrite(multi, control_socket_)) {
492
10.9k
        ++writable_pollset_probe_count_;
493
10.9k
      }
494
33.0k
    }
495
496
270k
    bool made_progress = still_running != running_before;
497
270k
    made_progress = ServiceControlConnection() || made_progress;
498
270k
    if (made_progress) {
499
141k
      idle_iterations = 0;
500
141k
    } else {
501
128k
      ++idle_iterations;
502
128k
    }
503
270k
  }
504
505
  // The final perform may have emitted the last command or body bytes
506
  // immediately before marking the transfer done. Drain them before cleanup.
507
29.9k
  (void)ServiceControlConnection();
508
29.9k
  FinishConnections();
509
29.9k
  scenario_ = nullptr;
510
29.9k
}
511
512
}  // namespace proto_fuzzer