Formato
Plain text
Post date
2015-03-29 00:14
Publication Period
Unlimited
  1. Index: src/google/protobuf/message.cc
  2. ===================================================================
  3. --- src/google/protobuf/message.cc (revision 490)
  4. +++ src/google/protobuf/message.cc (working copy)
  5. @@ -277,7 +277,8 @@
  6. void GeneratedMessageFactory::RegisterFile(
  7. const char* file, RegistrationFunc* registration_func) {
  8. if (!InsertIfNotPresent(&file_map_, file, registration_func)) {
  9. - GOOGLE_LOG(FATAL) << "File is already registered: " << file;
  10. + registration_func(file);
  11. + //GOOGLE_LOG(FATAL) << "File is already registered: " << file;
  12. }
  13. }
  14. @@ -292,7 +293,7 @@
  15. // the mutex.
  16. mutex_.AssertHeld();
  17. if (!InsertIfNotPresent(&type_map_, descriptor, prototype)) {
  18. - GOOGLE_LOG(DFATAL) << "Type is already registered: " << descriptor->full_name();
  19. + //GOOGLE_LOG(DFATAL) << "Type is already registered: " << descriptor->full_name();
  20. }
  21. }
  22. Index: src/google/protobuf/descriptor_database.cc
  23. ===================================================================
  24. --- src/google/protobuf/descriptor_database.cc (revision 490)
  25. +++ src/google/protobuf/descriptor_database.cc (working copy)
  26. @@ -309,7 +309,18 @@
  27. const void* encoded_file_descriptor, int size) {
  28. FileDescriptorProto file;
  29. if (file.ParseFromArray(encoded_file_descriptor, size)) {
  30. + std::pair<const void*, int> existing = index_.FindFile(file.name());
  31. + if (existing.first) {
  32. + if (existing.second == size && memcmp(existing.first, encoded_file_descriptor, size) == 0) {
  33. + // Contents match
  34. + return true;
  35. + }
  36. + else {
  37. + GOOGLE_LOG(ERROR) << "File descriptor " << file.name() << " is already registered, but descriptor contents are different";
  38. + }
  39. + }
  40. return index_.AddFile(file, make_pair(encoded_file_descriptor, size));
  41. +
  42. } else {
  43. GOOGLE_LOG(ERROR) << "Invalid file descriptor data passed to "
  44. "EncodedDescriptorDatabase::Add().";
Descargar Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text