Partially revert last patch.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 23 Jul 2015 15:29:13 +0000 (17:29 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 23 Jul 2015 15:29:13 +0000 (17:29 +0200)
add_data_raw() does not change the stream suitability points at all;
it just writes to disk. Thus, we don't need this complicated little dance
to give it multiple blocks.

stream.cpp

index 557502b..50679ca 100644 (file)
@@ -114,35 +114,13 @@ void Stream::set_backlog_size(size_t new_size)
 
        // Now cheat a bit by rewinding, and adding all the old data back.
        bytes_received -= existing_data.size();
-
-       size_t bytes_before_suitable_starting_point;
-       if (last_suitable_starting_point == -1) {
-               bytes_before_suitable_starting_point = existing_data.size();
-       } else if (size_t(last_suitable_starting_point) < backlog_size) {
-               bytes_before_suitable_starting_point = 0;
-       } else {
-               bytes_before_suitable_starting_point = last_suitable_starting_point - backlog_size;
-       }
+       DataElement data_element;
+       data_element.data.iov_base = const_cast<char *>(existing_data.data());
+       data_element.data.iov_len = existing_data.size();
+       data_element.suitable_for_stream_start = NOT_SUITABLE_FOR_STREAM_START;  // Ignored by add_data_raw().
 
        vector<DataElement> data_elements;
-       if (bytes_before_suitable_starting_point > 0) {
-               // There's really no usable data here (except for ?backlog=1 users),
-               // but we need to get the accounting right anyway.
-               DataElement data_element;
-               data_element.data.iov_base = const_cast<char *>(existing_data.data());
-               data_element.data.iov_len = bytes_before_suitable_starting_point;
-               data_element.suitable_for_stream_start = NOT_SUITABLE_FOR_STREAM_START;
-               data_elements.push_back(data_element);
-       }
-       if (bytes_before_suitable_starting_point < existing_data.size()) {
-               DataElement data_element;
-               data_element.data.iov_base = const_cast<char *>(existing_data.data() + bytes_before_suitable_starting_point);
-               data_element.data.iov_len = existing_data.size() - bytes_before_suitable_starting_point;
-               data_element.suitable_for_stream_start = SUITABLE_FOR_STREAM_START;
-               data_elements.push_back(data_element);
-       }
-
-       last_suitable_starting_point = -1;
+       data_elements.push_back(data_element);
        add_data_raw(data_elements);
 }