aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/io/coded_stream.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/io/coded_stream.h')
-rw-r--r--src/google/protobuf/io/coded_stream.h39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h
index b71b4a98..20d86143 100644
--- a/src/google/protobuf/io/coded_stream.h
+++ b/src/google/protobuf/io/coded_stream.h
@@ -131,7 +131,9 @@
#define PROTOBUF_LITTLE_ENDIAN 1
#endif
#endif
+#include <google/protobuf/stubs/atomicops.h>
#include <google/protobuf/stubs/common.h>
+#include <google/protobuf/stubs/port.h>
namespace google {
@@ -371,11 +373,10 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// maximum message length should be limited to the shortest length that
// will not harm usability. The theoretical shortest message that could
// cause integer overflows is 512MB. The default limit is 64MB. Apps
- // should set shorter limits if possible. If warning_threshold is not -1,
- // a warning will be printed to stderr after warning_threshold bytes are
- // read. For backwards compatibility all negative values get squashed to -1,
- // as other negative values might have special internal meanings.
- // An error will always be printed to stderr if the limit is reached.
+ // should set shorter limits if possible. For backwards compatibility all
+ // negative values get squashed to -1, as other negative values might have
+ // special internal meanings. An error will always be printed to stderr if
+ // the limit is reached.
//
// This is unrelated to PushLimit()/PopLimit().
//
@@ -568,12 +569,6 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// current_limit_. Set using SetTotalBytesLimit().
int total_bytes_limit_;
- // If positive/0: Limit for bytes read after which a warning due to size
- // should be logged.
- // If -1: Printing of warning disabled. Can be set by client.
- // If -2: Internal: Limit has been reached, print full size when destructing.
- int total_bytes_warning_threshold_;
-
// Current recursion budget, controlled by IncrementRecursionDepth() and
// similar. Starts at recursion_limit_ and goes down: if this reaches
// -1 we are over budget.
@@ -581,6 +576,8 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
// Recursion depth limit, set by SetRecursionLimit().
int recursion_limit_;
+ bool disable_strict_correctness_enforcement_;
+
// See SetExtensionRegistry().
const DescriptorPool* extension_pool_;
MessageFactory* extension_factory_;
@@ -642,8 +639,6 @@ class LIBPROTOBUF_EXPORT CodedInputStream {
static const int kDefaultTotalBytesLimit = INT_MAX;
- static const int kDefaultTotalBytesWarningThreshold = 32 << 20; // 32MB
-
static int default_recursion_limit_; // 100 by default.
};
@@ -870,7 +865,7 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
}
static bool IsDefaultSerializationDeterministic() {
- return default_serialization_deterministic_;
+ return google::protobuf::internal::Acquire_Load(&default_serialization_deterministic_);
}
private:
@@ -885,7 +880,8 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
// See SetSerializationDeterministic() regarding these three fields.
bool serialization_deterministic_is_overridden_;
bool serialization_deterministic_override_;
- static bool default_serialization_deterministic_;
+ // Conceptually, default_serialization_deterministic_ is an atomic bool.
+ static google::protobuf::internal::AtomicWord default_serialization_deterministic_;
// Advance the buffer by a given number of bytes.
void Advance(int amount);
@@ -904,10 +900,15 @@ class LIBPROTOBUF_EXPORT CodedOutputStream {
void WriteVarint64SlowPath(uint64 value);
// See above. Other projects may use "friend" to allow them to call this.
- // Requires: no protocol buffer serialization in progress.
+ // After SetDefaultSerializationDeterministic() completes, all protocol
+ // buffer serializations will be deterministic by default. Thread safe.
+ // However, the meaning of "after" is subtle here: to be safe, each thread
+ // that wants deterministic serialization by default needs to call
+ // SetDefaultSerializationDeterministic() or ensure on its own that another
+ // thread has done so.
friend void ::google::protobuf::internal::MapTestForceDeterministic();
static void SetDefaultSerializationDeterministic() {
- default_serialization_deterministic_ = true;
+ google::protobuf::internal::Release_Store(&default_serialization_deterministic_, 1);
}
};
@@ -1395,9 +1396,9 @@ inline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input)
current_limit_(kint32max),
buffer_size_after_limit_(0),
total_bytes_limit_(kDefaultTotalBytesLimit),
- total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold),
recursion_budget_(default_recursion_limit_),
recursion_limit_(default_recursion_limit_),
+ disable_strict_correctness_enforcement_(true),
extension_pool_(NULL),
extension_factory_(NULL) {
// Eagerly Refresh() so buffer space is immediately available.
@@ -1416,9 +1417,9 @@ inline CodedInputStream::CodedInputStream(const uint8* buffer, int size)
current_limit_(size),
buffer_size_after_limit_(0),
total_bytes_limit_(kDefaultTotalBytesLimit),
- total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold),
recursion_budget_(default_recursion_limit_),
recursion_limit_(default_recursion_limit_),
+ disable_strict_correctness_enforcement_(true),
extension_pool_(NULL),
extension_factory_(NULL) {
// Note that setting current_limit_ == size is important to prevent some