zeroc-ice 3.8.1 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/dist/IceRuby/Operation.cpp +22 -6
  3. data/dist/ice/cpp/include/Ice/Config.h +2 -2
  4. data/dist/ice/cpp/include/Ice/LocalExceptions.h +21 -0
  5. data/dist/ice/cpp/include/Ice/OutputStream.h +7 -5
  6. data/dist/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
  7. data/dist/ice/cpp/include/generated/Ice/Context.h +2 -2
  8. data/dist/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
  9. data/dist/ice/cpp/include/generated/Ice/Identity.h +2 -2
  10. data/dist/ice/cpp/include/generated/Ice/Locator.h +9 -11
  11. data/dist/ice/cpp/include/generated/Ice/LocatorRegistry.h +2 -2
  12. data/dist/ice/cpp/include/generated/Ice/Metrics.h +7 -7
  13. data/dist/ice/cpp/include/generated/Ice/OperationMode.h +2 -2
  14. data/dist/ice/cpp/include/generated/Ice/Process.h +2 -2
  15. data/dist/ice/cpp/include/generated/Ice/PropertiesAdmin.h +2 -2
  16. data/dist/ice/cpp/include/generated/Ice/PropertyDict.h +2 -2
  17. data/dist/ice/cpp/include/generated/Ice/RemoteLogger.h +2 -2
  18. data/dist/ice/cpp/include/generated/Ice/ReplyStatus.h +8 -4
  19. data/dist/ice/cpp/include/generated/Ice/Router.h +7 -7
  20. data/dist/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
  21. data/dist/ice/cpp/include/generated/Ice/Version.h +2 -2
  22. data/dist/ice/cpp/include/generated/IceDiscovery/Lookup.h +2 -2
  23. data/dist/ice/cpp/include/generated/IceLocatorDiscovery/Lookup.h +2 -2
  24. data/dist/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +5 -3
  25. data/dist/ice/cpp/src/Ice/ConnectionI.cpp +27 -9
  26. data/dist/ice/cpp/src/Ice/ConnectionI.h +1 -1
  27. data/dist/ice/cpp/src/Ice/FileUtil.cpp +3 -67
  28. data/dist/ice/cpp/src/Ice/FileUtil.h +0 -3
  29. data/dist/ice/cpp/src/Ice/IPEndpointI.cpp +4 -0
  30. data/dist/ice/cpp/src/Ice/IncomingRequest.cpp +1 -1
  31. data/dist/ice/cpp/src/Ice/InputStream.cpp +28 -15
  32. data/dist/ice/cpp/src/Ice/LocalExceptions.cpp +6 -0
  33. data/dist/ice/cpp/src/Ice/OutgoingAsync.cpp +1 -1
  34. data/dist/ice/cpp/src/Ice/OutgoingResponse.cpp +127 -127
  35. data/dist/ice/cpp/src/Ice/OutgoingResponseInternal.h +21 -0
  36. data/dist/ice/cpp/src/Ice/OutputStream.cpp +46 -61
  37. data/dist/ice/cpp/src/Ice/PropertyNames.cpp +2 -1
  38. data/dist/ice/cpp/src/Ice/ProxyFunctions.cpp +4 -4
  39. data/dist/ice/cpp/src/Ice/Reference.cpp +15 -15
  40. data/dist/ice/cpp/src/Ice/ReferenceFactory.cpp +16 -13
  41. data/dist/ice/cpp/src/Ice/ResourceConfig.h +2 -2
  42. data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.cpp +12 -11
  43. data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.h +1 -2
  44. data/dist/ice/cpp/src/Ice/SSL/SSLEndpointI.cpp +1 -1
  45. data/dist/ice/cpp/src/Ice/SSL/SSLEngine.h +1 -4
  46. data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.cpp +50 -43
  47. data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.h +1 -5
  48. data/dist/ice/cpp/src/Ice/SSL/SchannelTransceiverI.cpp +9 -0
  49. data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.cpp +107 -14
  50. data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.h +7 -2
  51. data/dist/ice/cpp/src/Ice/TcpEndpointI.cpp +2 -2
  52. data/dist/ice/cpp/src/Ice/UdpEndpointI.cpp +2 -2
  53. data/dist/ice/cpp/src/Ice/WSAcceptor.cpp +8 -3
  54. data/dist/ice/cpp/src/Ice/WSAcceptor.h +5 -1
  55. data/dist/ice/cpp/src/Ice/WSEndpoint.cpp +45 -2
  56. data/dist/ice/cpp/src/Ice/WSTransceiver.cpp +118 -7
  57. data/dist/ice/cpp/src/Ice/WSTransceiver.h +12 -1
  58. data/dist/ice/cpp/src/Ice/generated/BuiltinSequences.cpp +2 -2
  59. data/dist/ice/cpp/src/Ice/generated/Context.cpp +2 -2
  60. data/dist/ice/cpp/src/Ice/generated/EndpointTypes.cpp +2 -2
  61. data/dist/ice/cpp/src/Ice/generated/Identity.cpp +2 -2
  62. data/dist/ice/cpp/src/Ice/generated/Locator.cpp +2 -2
  63. data/dist/ice/cpp/src/Ice/generated/LocatorRegistry.cpp +2 -2
  64. data/dist/ice/cpp/src/Ice/generated/Metrics.cpp +2 -2
  65. data/dist/ice/cpp/src/Ice/generated/OperationMode.cpp +2 -2
  66. data/dist/ice/cpp/src/Ice/generated/Process.cpp +2 -2
  67. data/dist/ice/cpp/src/Ice/generated/PropertiesAdmin.cpp +2 -2
  68. data/dist/ice/cpp/src/Ice/generated/PropertyDict.cpp +2 -2
  69. data/dist/ice/cpp/src/Ice/generated/RemoteLogger.cpp +2 -2
  70. data/dist/ice/cpp/src/Ice/generated/ReplyStatus.cpp +4 -2
  71. data/dist/ice/cpp/src/Ice/generated/Router.cpp +2 -2
  72. data/dist/ice/cpp/src/Ice/generated/SliceChecksumDict.cpp +2 -2
  73. data/dist/ice/cpp/src/Ice/generated/Version.cpp +2 -2
  74. data/dist/ice/cpp/src/IceDiscovery/generated/Lookup.cpp +2 -2
  75. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/Lookup.cpp +2 -2
  76. data/dist/ice/cpp/src/Slice/DocCommentParser.cpp +6 -6
  77. data/dist/ice/cpp/src/Slice/DocCommentParser.h +4 -2
  78. data/dist/ice/cpp/src/Slice/MetadataValidation.cpp +24 -5
  79. data/dist/ice/cpp/src/Slice/MetadataValidation.h +3 -2
  80. data/dist/ice/cpp/src/Slice/Parser.cpp +117 -77
  81. data/dist/ice/cpp/src/Slice/Parser.h +19 -4
  82. data/dist/ice/cpp/src/Slice/Preprocessor.cpp +75 -19
  83. data/dist/ice/cpp/src/Slice/Preprocessor.h +0 -1
  84. data/dist/ice/cpp/src/Slice/SliceUtil.cpp +6 -58
  85. data/dist/ice/cpp/src/Slice/Util.h +0 -3
  86. data/dist/ice/cpp/src/slice2rb/RubyUtil.cpp +10 -8
  87. data/dist/ice/cpp/src/slice2rb/RubyUtil.h +10 -13
  88. data/dist/ice/slice/Ice/Identity.ice +3 -0
  89. data/dist/ice/slice/Ice/Locator.ice +6 -5
  90. data/dist/ice/slice/Ice/LocatorRegistry.ice +3 -0
  91. data/dist/ice/slice/Ice/Metrics.ice +1 -1
  92. data/dist/ice/slice/Ice/OperationMode.ice +8 -0
  93. data/dist/ice/slice/Ice/Process.ice +3 -0
  94. data/dist/ice/slice/Ice/ReplyStatus.ice +13 -0
  95. data/dist/lib/Glacier2/Metrics.rb +1 -1
  96. data/dist/lib/Glacier2/PermissionsVerifier.rb +3 -3
  97. data/dist/lib/Glacier2/Router.rb +8 -8
  98. data/dist/lib/Glacier2/SSLInfo.rb +1 -1
  99. data/dist/lib/Glacier2/Session.rb +15 -15
  100. data/dist/lib/Ice/BuiltinSequences.rb +1 -1
  101. data/dist/lib/Ice/Context.rb +1 -1
  102. data/dist/lib/Ice/EndpointTypes.rb +1 -1
  103. data/dist/lib/Ice/Identity.rb +1 -1
  104. data/dist/lib/Ice/LocalExceptions.rb +3 -0
  105. data/dist/lib/Ice/Locator.rb +5 -5
  106. data/dist/lib/Ice/LocatorRegistry.rb +4 -4
  107. data/dist/lib/Ice/Metrics.rb +7 -7
  108. data/dist/lib/Ice/OperationMode.rb +1 -1
  109. data/dist/lib/Ice/Process.rb +3 -3
  110. data/dist/lib/Ice/PropertiesAdmin.rb +4 -4
  111. data/dist/lib/Ice/PropertyDict.rb +1 -1
  112. data/dist/lib/Ice/ProxyFunctions.rb +8 -4
  113. data/dist/lib/Ice/RemoteLogger.rb +6 -6
  114. data/dist/lib/Ice/ReplyStatus.rb +3 -2
  115. data/dist/lib/Ice/Router.rb +5 -5
  116. data/dist/lib/Ice/SliceChecksumDict.rb +1 -1
  117. data/dist/lib/Ice/Version.rb +1 -1
  118. data/dist/lib/IceBox/ServiceManager.rb +8 -8
  119. data/dist/lib/IceGrid/Admin.rb +83 -83
  120. data/dist/lib/IceGrid/Descriptor.rb +1 -1
  121. data/dist/lib/IceGrid/Exception.rb +1 -1
  122. data/dist/lib/IceGrid/FileParser.rb +2 -2
  123. data/dist/lib/IceGrid/Registry.rb +13 -13
  124. data/dist/lib/IceGrid/Session.rb +6 -6
  125. data/dist/lib/IceGrid/UserAccountMapper.rb +2 -2
  126. data/dist/lib/IceStorm/IceStorm.rb +16 -16
  127. data/dist/lib/IceStorm/Metrics.rb +1 -1
  128. data/ice.gemspec +1 -1
  129. metadata +2 -1
@@ -2,9 +2,11 @@
2
2
 
3
3
  #include "Ice/OutgoingResponse.h"
4
4
  #include "Ice/Demangle.h"
5
+ #include "Ice/Initialize.h"
5
6
  #include "Ice/LocalExceptions.h"
6
7
  #include "Ice/ObjectAdapter.h"
7
8
  #include "Ice/UserException.h"
9
+ #include "OutgoingResponseInternal.h"
8
10
  #include "Protocol.h"
9
11
 
10
12
  #include <sstream>
@@ -30,131 +32,6 @@ namespace
30
32
  os << "dispatch failed with " << typeId << ": " << what;
31
33
  return os.str();
32
34
  }
33
-
34
- // The "core" implementation of makeOutgoingResponse for exceptions. Note that it can throw an exception.
35
- OutgoingResponse makeOutgoingResponseCore(std::exception_ptr exc, const Current& current)
36
- {
37
- assert(exc);
38
- OutputStream ostr{currentProtocolEncoding};
39
-
40
- if (current.requestId != 0)
41
- {
42
- ostr.writeBlob(replyHdr, sizeof(replyHdr));
43
- ostr.write(current.requestId);
44
- }
45
- ReplyStatus replyStatus;
46
- string exceptionId;
47
- string exceptionDetails; // may include the stack trace.
48
- string dispatchExceptionMessage;
49
-
50
- try
51
- {
52
- rethrow_exception(exc);
53
- }
54
- catch (const UserException& ex)
55
- {
56
- // We keep exceptionId and exceptionDetails empty.
57
-
58
- replyStatus = ReplyStatus::UserException;
59
-
60
- if (current.requestId != 0)
61
- {
62
- ostr.write(replyStatus);
63
- ostr.startEncapsulation(current.encoding, FormatType::SlicedFormat);
64
- ostr.write(ex);
65
- ostr.endEncapsulation();
66
- }
67
- }
68
- catch (const DispatchException& ex)
69
- {
70
- exceptionId = ex.ice_id();
71
- exceptionDetails = toString(ex); // can include a stack trace
72
- replyStatus = ex.replyStatus();
73
-
74
- if (replyStatus >= ReplyStatus::ObjectNotExist && replyStatus <= ReplyStatus::OperationNotExist)
75
- {
76
- if (current.requestId != 0) // only marshal response for two-way requests
77
- {
78
- // The identity, facet, operation are often left unset at this point.
79
- Identity id;
80
- string facet;
81
- string operation;
82
- if (auto* rfe = dynamic_cast<const RequestFailedException*>(&ex))
83
- {
84
- id = rfe->id();
85
- facet = rfe->facet();
86
- operation = rfe->operation();
87
- }
88
- if (id.name.empty())
89
- {
90
- id = current.id;
91
- facet = current.facet;
92
- }
93
- if (operation.empty())
94
- {
95
- operation = current.operation;
96
- }
97
-
98
- ostr.write(replyStatus);
99
- ostr.write(id);
100
-
101
- if (facet.empty())
102
- {
103
- ostr.write(static_cast<string*>(nullptr), static_cast<string*>(nullptr));
104
- }
105
- else
106
- {
107
- ostr.write(&facet, &facet + 1);
108
- }
109
- ostr.write(operation, false);
110
- }
111
- // dispatchExceptionMessage remains empty: RequestFailedException does not carry a message and we
112
- // don't include this message in OutgoingResponse.
113
- }
114
- else
115
- {
116
- dispatchExceptionMessage = ex.what();
117
- // And marshal this exception after the last catch block.
118
- }
119
- }
120
- catch (const LocalException& ex)
121
- {
122
- exceptionId = ex.ice_id();
123
- exceptionDetails = toString(ex);
124
- dispatchExceptionMessage = createDispatchExceptionMessage(exceptionId, ex.what());
125
- replyStatus = ReplyStatus::UnknownLocalException;
126
- }
127
- catch (const std::exception& ex)
128
- {
129
- exceptionId = demangle(typeid(ex).name());
130
- ostringstream str;
131
- str << "c++ exception: " << ex.what();
132
- exceptionDetails = str.str();
133
- dispatchExceptionMessage = createDispatchExceptionMessage(exceptionId, ex.what());
134
- replyStatus = ReplyStatus::UnknownException;
135
- }
136
- catch (...)
137
- {
138
- exceptionId = "unknown";
139
- exceptionDetails = "c++ exception: unknown";
140
- dispatchExceptionMessage = createDispatchExceptionMessage(exceptionId, "c++ exception");
141
- replyStatus = ReplyStatus::UnknownException;
142
- }
143
-
144
- if (current.requestId != 0 && replyStatus > ReplyStatus::OperationNotExist)
145
- {
146
- // We can't use the generated code to marshal a possibly unknown reply status.
147
- ostr.write(static_cast<uint8_t>(replyStatus));
148
- ostr.write(dispatchExceptionMessage);
149
- }
150
-
151
- return OutgoingResponse{
152
- replyStatus,
153
- std::move(exceptionId),
154
- std::move(exceptionDetails),
155
- std::move(ostr),
156
- current};
157
- }
158
35
  } // anonymous namespace
159
36
 
160
37
  OutgoingResponse::OutgoingResponse(
@@ -264,13 +141,136 @@ Ice::makeOutgoingResponse(bool ok, pair<const byte*, const byte*> encapsulation,
264
141
  OutgoingResponse
265
142
  Ice::makeOutgoingResponse(std::exception_ptr exc, const Current& current) noexcept
266
143
  {
144
+ IceInternal::Instance* instance = getInstance(current.adapter->getCommunicator()).get();
145
+
267
146
  try
268
147
  {
269
- return makeOutgoingResponseCore(exc, current);
148
+ return makeOutgoingResponseCore(exc, current, instance);
270
149
  }
271
150
  catch (...)
272
151
  {
273
152
  // This could throw again, but then it's either a bug or we can't allocate anything.
274
- return makeOutgoingResponseCore(current_exception(), current);
153
+ return makeOutgoingResponseCore(current_exception(), current, instance);
275
154
  }
276
155
  }
156
+
157
+ // The "core" implementation of makeOutgoingResponse for exceptions. Note that it can throw an exception.
158
+ OutgoingResponse
159
+ Ice::makeOutgoingResponseCore(std::exception_ptr exc, const Current& current, Instance* instance)
160
+ {
161
+ assert(exc);
162
+ OutputStream ostr{instance, currentProtocolEncoding};
163
+
164
+ if (current.requestId != 0)
165
+ {
166
+ ostr.writeBlob(replyHdr, sizeof(replyHdr));
167
+ ostr.write(current.requestId);
168
+ }
169
+ ReplyStatus replyStatus;
170
+ string exceptionId;
171
+ string exceptionDetails; // may include the stack trace.
172
+ string dispatchExceptionMessage;
173
+
174
+ try
175
+ {
176
+ rethrow_exception(exc);
177
+ }
178
+ catch (const UserException& ex)
179
+ {
180
+ // We keep exceptionId and exceptionDetails empty.
181
+
182
+ replyStatus = ReplyStatus::UserException;
183
+
184
+ if (current.requestId != 0)
185
+ {
186
+ ostr.write(replyStatus);
187
+ ostr.startEncapsulation(current.encoding, FormatType::SlicedFormat);
188
+ ostr.write(ex);
189
+ ostr.endEncapsulation();
190
+ }
191
+ }
192
+ catch (const DispatchException& ex)
193
+ {
194
+ exceptionId = ex.ice_id();
195
+ exceptionDetails = toString(ex); // can include a stack trace
196
+ replyStatus = ex.replyStatus();
197
+
198
+ if (replyStatus >= ReplyStatus::ObjectNotExist && replyStatus <= ReplyStatus::OperationNotExist)
199
+ {
200
+ if (current.requestId != 0) // only marshal response for two-way requests
201
+ {
202
+ // The identity, facet, operation are often left unset at this point.
203
+ Identity id;
204
+ string facet;
205
+ string operation;
206
+ if (auto* rfe = dynamic_cast<const RequestFailedException*>(&ex))
207
+ {
208
+ id = rfe->id();
209
+ facet = rfe->facet();
210
+ operation = rfe->operation();
211
+ }
212
+ if (id.name.empty())
213
+ {
214
+ id = current.id;
215
+ facet = current.facet;
216
+ }
217
+ if (operation.empty())
218
+ {
219
+ operation = current.operation;
220
+ }
221
+
222
+ ostr.write(replyStatus);
223
+ ostr.write(id);
224
+
225
+ if (facet.empty())
226
+ {
227
+ ostr.write(static_cast<string*>(nullptr), static_cast<string*>(nullptr));
228
+ }
229
+ else
230
+ {
231
+ ostr.write(&facet, &facet + 1);
232
+ }
233
+ ostr.write(operation, false);
234
+ }
235
+ // dispatchExceptionMessage remains empty: RequestFailedException does not carry a message and we
236
+ // don't include this message in OutgoingResponse.
237
+ }
238
+ else
239
+ {
240
+ dispatchExceptionMessage = ex.what();
241
+ // And marshal this exception after the last catch block.
242
+ }
243
+ }
244
+ catch (const LocalException& ex)
245
+ {
246
+ exceptionId = ex.ice_id();
247
+ exceptionDetails = toString(ex);
248
+ dispatchExceptionMessage = createDispatchExceptionMessage(exceptionId, ex.what());
249
+ replyStatus = ReplyStatus::UnknownLocalException;
250
+ }
251
+ catch (const std::exception& ex)
252
+ {
253
+ exceptionId = demangle(typeid(ex).name());
254
+ ostringstream str;
255
+ str << "c++ exception: " << ex.what();
256
+ exceptionDetails = str.str();
257
+ dispatchExceptionMessage = createDispatchExceptionMessage(exceptionId, ex.what());
258
+ replyStatus = ReplyStatus::UnknownException;
259
+ }
260
+ catch (...)
261
+ {
262
+ exceptionId = "unknown";
263
+ exceptionDetails = "c++ exception: unknown";
264
+ dispatchExceptionMessage = createDispatchExceptionMessage(exceptionId, "c++ exception");
265
+ replyStatus = ReplyStatus::UnknownException;
266
+ }
267
+
268
+ if (current.requestId != 0 && replyStatus > ReplyStatus::OperationNotExist)
269
+ {
270
+ // We can't use the generated code to marshal a possibly unknown reply status.
271
+ ostr.write(static_cast<uint8_t>(replyStatus));
272
+ ostr.write(dispatchExceptionMessage);
273
+ }
274
+
275
+ return OutgoingResponse{replyStatus, std::move(exceptionId), std::move(exceptionDetails), std::move(ostr), current};
276
+ }
@@ -0,0 +1,21 @@
1
+ // Copyright (c) ZeroC, Inc.
2
+
3
+ #ifndef ICE_OUTGOING_RESPONSE_INTERNAL_H
4
+ #define ICE_OUTGOING_RESPONSE_INTERNAL_H
5
+
6
+ #include "Ice/OutgoingResponse.h"
7
+
8
+ namespace Ice
9
+ {
10
+ /// @private
11
+ /// The "core" implementation of makeOutgoingResponse for exceptions. Note that it can throw an exception.
12
+ /// @param exception The exception to marshal into the response.
13
+ /// @param current A reference to the Current object of the request. @c current.adapter can be null here; the
14
+ /// implementation uses @p instance instead.
15
+ /// @param instance The IceInternal::Instance object. Not null.
16
+ /// @return The new response.
17
+ OutgoingResponse
18
+ makeOutgoingResponseCore(std::exception_ptr exception, const Current& current, IceInternal::Instance* instance);
19
+ }
20
+
21
+ #endif
@@ -68,6 +68,10 @@ Ice::OutputStream::OutputStream(
68
68
  _format(format),
69
69
  _currentEncaps(nullptr)
70
70
  {
71
+ if (!_wstringConverter)
72
+ {
73
+ _wstringConverter = getProcessWstringConverter();
74
+ }
71
75
  }
72
76
 
73
77
  Ice::OutputStream::OutputStream(
@@ -85,6 +89,11 @@ Ice::OutputStream::OutputStream(
85
89
  _currentEncaps(nullptr)
86
90
  {
87
91
  b.reset();
92
+
93
+ if (!_wstringConverter)
94
+ {
95
+ _wstringConverter = getProcessWstringConverter();
96
+ }
88
97
  }
89
98
 
90
99
  Ice::OutputStream::OutputStream(const CommunicatorPtr& communicator, EncodingVersion encoding)
@@ -104,6 +113,7 @@ Ice::OutputStream::OutputStream(Instance* instance, EncodingVersion encoding)
104
113
  instance->getStringConverter(),
105
114
  instance->getWstringConverter())
106
115
  {
116
+ assert(_wstringConverter);
107
117
  }
108
118
 
109
119
  Ice::OutputStream::OutputStream(OutputStream&& other) noexcept
@@ -116,6 +126,7 @@ Ice::OutputStream::OutputStream(OutputStream&& other) noexcept
116
126
  _currentEncaps(other._currentEncaps)
117
127
  {
118
128
  // Reset other to its default state.
129
+ other._wstringConverter = getProcessWstringConverter();
119
130
  other._closure = nullptr;
120
131
  other._encoding = Encoding_1_1;
121
132
  other._format = FormatType::CompactFormat;
@@ -140,6 +151,7 @@ Ice::OutputStream::operator=(OutputStream&& other) noexcept
140
151
  _currentEncaps = other._currentEncaps;
141
152
 
142
153
  // Reset other to its default state.
154
+ other._wstringConverter = getProcessWstringConverter();
143
155
  other._closure = nullptr;
144
156
  other._encoding = Encoding_1_1;
145
157
  other._format = FormatType::CompactFormat;
@@ -703,13 +715,7 @@ Ice::OutputStream::write(const char*)
703
715
  void
704
716
  Ice::OutputStream::writeConverted(const char* vdata, size_t vsize)
705
717
  {
706
- StringConverterPtr stringConverter = _stringConverter;
707
- if (!stringConverter)
708
- {
709
- stringConverter = getProcessStringConverter();
710
- }
711
-
712
- if (!stringConverter)
718
+ if (!_stringConverter)
713
719
  {
714
720
  // No converter installed; write the string as-is (assumed to be UTF-8 already).
715
721
  writeSize(static_cast<int32_t>(vsize));
@@ -735,7 +741,7 @@ Ice::OutputStream::writeConverted(const char* vdata, size_t vsize)
735
741
  auto sizePos = startOneByteSize();
736
742
 
737
743
  StreamUTF8BufferI buffer(*this);
738
- byte* lastByte = stringConverter->toUTF8(vdata, vdata + vsize, buffer);
744
+ byte* lastByte = _stringConverter->toUTF8(vdata, vdata + vsize, buffer);
739
745
  if (lastByte != b.end())
740
746
  {
741
747
  resize(static_cast<size_t>(lastByte - b.begin()));
@@ -750,7 +756,7 @@ Ice::OutputStream::writeConverted(const char* vdata, size_t vsize)
750
756
  auto sizePos = startSize();
751
757
 
752
758
  StreamUTF8BufferI buffer(*this);
753
- byte* lastByte = stringConverter->toUTF8(vdata, vdata + vsize, buffer);
759
+ byte* lastByte = _stringConverter->toUTF8(vdata, vdata + vsize, buffer);
754
760
  if (lastByte != b.end())
755
761
  {
756
762
  resize(static_cast<size_t>(lastByte - b.begin()));
@@ -788,68 +794,47 @@ Ice::OutputStream::write(wstring_view v)
788
794
  return;
789
795
  }
790
796
 
791
- //
792
- // What is the size of the resulting UTF-8 encoded string?
793
- // Impossible to tell, so we guess. If we don't guess correctly,
794
- // we'll have to fix the mistake afterwards
795
- //
797
+ assert(_wstringConverter);
798
+
799
+ // The worst-case expansion for converting a wide string to UTF-8 is 3x or 4x depending on the platform.
800
+ const size_t factor = sizeof(wchar_t) == 2 ? 3 : 4;
801
+
796
802
  try
797
803
  {
798
- auto guessedSize = static_cast<int32_t>(v.size());
799
- writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
800
-
801
- size_t firstIndex = b.size();
802
- StreamUTF8BufferI buffer(*this);
804
+ // (252 / 3 = 84, 252 / 4 = 63)
805
+ if (v.size() <= 252 / factor)
806
+ {
807
+ // The maximum UTF-8 size is v.size() * factor <= 252, which fits in a 1-byte size encoding.
808
+ // We use this upper bound to decide the size encoding:
809
+ // - If v.size() <= 252 / factor, the converted string is at most 252 bytes, which always fits in a 1-byte
810
+ // size.
811
+ // - Otherwise, we use the 5-byte size encoding to avoid guessing and memmove fixups.
812
+ auto sizePos = startOneByteSize();
803
813
 
804
- byte* lastByte = nullptr;
814
+ StreamUTF8BufferI buffer(*this);
815
+ byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
816
+ if (lastByte != b.end())
817
+ {
818
+ resize(static_cast<size_t>(lastByte - b.begin()));
819
+ }
805
820
 
806
- WstringConverterPtr wstringConverter = _wstringConverter;
807
- if (!wstringConverter)
808
- {
809
- wstringConverter = getProcessWstringConverter();
821
+ endOneByteSize(sizePos);
822
+ return;
810
823
  }
811
- assert(wstringConverter); // never null
812
- lastByte = wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
813
-
814
- if (lastByte != b.end())
824
+ else
815
825
  {
816
- resize(static_cast<size_t>(lastByte - b.begin()));
817
- }
818
- size_t lastIndex = b.size();
819
-
820
- auto actualSize = static_cast<int32_t>(lastIndex - firstIndex);
826
+ // Write the first byte of the 5-byte size encoding, followed by a 4-byte size placeholder.
827
+ write(uint8_t(255));
828
+ auto sizePos = startSize();
821
829
 
822
- //
823
- // Check against the guess
824
- //
825
- if (guessedSize != actualSize)
826
- {
827
- if (guessedSize <= 254 && actualSize > 254)
828
- {
829
- //
830
- // Move the UTF-8 sequence 4 bytes further
831
- // Use memmove instead of memcpy since the source and destination typically overlap.
832
- //
833
- resize(b.size() + 4);
834
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
835
- }
836
- else if (guessedSize > 254 && actualSize <= 254)
830
+ StreamUTF8BufferI buffer(*this);
831
+ byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
832
+ if (lastByte != b.end())
837
833
  {
838
- //
839
- // Move the UTF-8 sequence 4 bytes back
840
- //
841
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
842
- resize(b.size() - 4);
834
+ resize(static_cast<size_t>(lastByte - b.begin()));
843
835
  }
844
836
 
845
- if (guessedSize <= 254)
846
- {
847
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
848
- }
849
- else
850
- {
851
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
852
- }
837
+ endSize(sizePos);
853
838
  }
854
839
  }
855
840
  catch (const Ice::IllegalConversionException& ex)
@@ -70,6 +70,7 @@ const PropertyArray PropertyNames::ThreadPoolProps
70
70
  const Property ObjectAdapterPropsData[] =
71
71
  {
72
72
  Property{"AdapterId", "", false, false, nullptr},
73
+ Property{"AllowedOrigins", "", false, false, nullptr},
73
74
  Property{"Connection", "", false, false, &PropertyNames::ConnectionProps},
74
75
  Property{"Endpoints", "", false, false, nullptr},
75
76
  Property{"Locator", "", false, false, &PropertyNames::ProxyProps},
@@ -89,7 +90,7 @@ const PropertyArray PropertyNames::ObjectAdapterProps
89
90
  .prefixOnly=true,
90
91
  .isOptIn=false,
91
92
  .properties=ObjectAdapterPropsData,
92
- .length=12
93
+ .length=13
93
94
  };
94
95
 
95
96
  const Property IcePropsData[] =
@@ -53,8 +53,8 @@ Ice::proxyIdentityAndFacetLess(const optional<ObjectPrx>& lhs, const optional<Ob
53
53
  {
54
54
  if (lhs && rhs)
55
55
  {
56
- Identity lhsIdentity = lhs->ice_getIdentity();
57
- Identity rhsIdentity = rhs->ice_getIdentity();
56
+ const Identity& lhsIdentity = lhs->ice_getIdentity();
57
+ const Identity& rhsIdentity = rhs->ice_getIdentity();
58
58
 
59
59
  if (lhsIdentity < rhsIdentity)
60
60
  {
@@ -65,8 +65,8 @@ Ice::proxyIdentityAndFacetLess(const optional<ObjectPrx>& lhs, const optional<Ob
65
65
  return false;
66
66
  }
67
67
 
68
- string lhsFacet = lhs->ice_getFacet();
69
- string rhsFacet = rhs->ice_getFacet();
68
+ const string& lhsFacet = lhs->ice_getFacet();
69
+ const string& rhsFacet = rhs->ice_getFacet();
70
70
 
71
71
  return lhsFacet < rhsFacet;
72
72
  }
@@ -549,7 +549,7 @@ IceInternal::FixedReference::changeConnectionId(string) const
549
549
  ReferencePtr
550
550
  IceInternal::FixedReference::changeConnection(Ice::ConnectionIPtr newConnection) const
551
551
  {
552
- FixedReferencePtr r = dynamic_pointer_cast<FixedReference>(clone());
552
+ FixedReferencePtr r = static_pointer_cast<FixedReference>(clone());
553
553
  r->_fixedConnection = std::move(newConnection);
554
554
  return r;
555
555
  }
@@ -787,7 +787,7 @@ IceInternal::RoutableReference::changeEncoding(Ice::EncodingVersion encoding) co
787
787
  ReferencePtr r = Reference::changeEncoding(encoding);
788
788
  if (r.get() != const_cast<RoutableReference*>(this))
789
789
  {
790
- LocatorInfoPtr& locInfo = dynamic_pointer_cast<RoutableReference>(r)->_locatorInfo;
790
+ LocatorInfoPtr& locInfo = static_pointer_cast<RoutableReference>(r)->_locatorInfo;
791
791
  if (locInfo && locInfo->getLocator()->ice_getEncodingVersion() != encoding)
792
792
  {
793
793
  locInfo = getInstance()->locatorManager()->get(locInfo->getLocator()->ice_encodingVersion(encoding));
@@ -809,7 +809,7 @@ IceInternal::RoutableReference::changeCompress(bool newCompress) const
809
809
  {
810
810
  newEndpoints.push_back(endpoint->compress(newCompress));
811
811
  }
812
- dynamic_pointer_cast<RoutableReference>(r)->_endpoints = newEndpoints;
812
+ static_pointer_cast<RoutableReference>(r)->_endpoints = std::move(newEndpoints);
813
813
  }
814
814
  return r;
815
815
  }
@@ -817,7 +817,7 @@ IceInternal::RoutableReference::changeCompress(bool newCompress) const
817
817
  ReferencePtr
818
818
  IceInternal::RoutableReference::changeEndpoints(vector<EndpointIPtr> newEndpoints) const
819
819
  {
820
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
820
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
821
821
  r->_endpoints = std::move(newEndpoints);
822
822
  r->applyOverrides(r->_endpoints);
823
823
  r->_adapterId.clear();
@@ -827,7 +827,7 @@ IceInternal::RoutableReference::changeEndpoints(vector<EndpointIPtr> newEndpoint
827
827
  ReferencePtr
828
828
  IceInternal::RoutableReference::changeAdapterId(string newAdapterId) const
829
829
  {
830
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
830
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
831
831
  r->_adapterId = std::move(newAdapterId);
832
832
  r->_endpoints.clear();
833
833
  return r;
@@ -837,7 +837,7 @@ ReferencePtr
837
837
  IceInternal::RoutableReference::changeLocator(optional<LocatorPrx> newLocator) const
838
838
  {
839
839
  LocatorInfoPtr newLocatorInfo = newLocator ? getInstance()->locatorManager()->get(newLocator.value()) : nullptr;
840
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
840
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
841
841
  r->_locatorInfo = std::move(newLocatorInfo);
842
842
  return r;
843
843
  }
@@ -846,7 +846,7 @@ ReferencePtr
846
846
  IceInternal::RoutableReference::changeRouter(optional<RouterPrx> newRouter) const
847
847
  {
848
848
  RouterInfoPtr newRouterInfo = newRouter ? getInstance()->routerManager()->get(newRouter.value()) : nullptr;
849
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
849
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
850
850
  r->_routerInfo = std::move(newRouterInfo);
851
851
  return r;
852
852
  }
@@ -854,7 +854,7 @@ IceInternal::RoutableReference::changeRouter(optional<RouterPrx> newRouter) cons
854
854
  ReferencePtr
855
855
  IceInternal::RoutableReference::changeCollocationOptimized(bool newCollocationOptimized) const
856
856
  {
857
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
857
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
858
858
  r->_collocationOptimized = newCollocationOptimized;
859
859
  return r;
860
860
  }
@@ -862,7 +862,7 @@ IceInternal::RoutableReference::changeCollocationOptimized(bool newCollocationOp
862
862
  ReferencePtr
863
863
  IceInternal::RoutableReference::changeCacheConnection(bool newCache) const
864
864
  {
865
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
865
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
866
866
  r->_cacheConnection = newCache;
867
867
  return r;
868
868
  }
@@ -870,7 +870,7 @@ IceInternal::RoutableReference::changeCacheConnection(bool newCache) const
870
870
  ReferencePtr
871
871
  IceInternal::RoutableReference::changeEndpointSelection(EndpointSelectionType newType) const
872
872
  {
873
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
873
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
874
874
  r->_endpointSelection = newType;
875
875
  return r;
876
876
  }
@@ -878,7 +878,7 @@ IceInternal::RoutableReference::changeEndpointSelection(EndpointSelectionType ne
878
878
  ReferencePtr
879
879
  IceInternal::RoutableReference::changeLocatorCacheTimeout(chrono::milliseconds timeout) const
880
880
  {
881
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
881
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
882
882
  r->_locatorCacheTimeout = timeout;
883
883
  return r;
884
884
  }
@@ -886,7 +886,7 @@ IceInternal::RoutableReference::changeLocatorCacheTimeout(chrono::milliseconds t
886
886
  ReferencePtr
887
887
  IceInternal::RoutableReference::changeConnectionId(string id) const
888
888
  {
889
- RoutableReferencePtr r = dynamic_pointer_cast<RoutableReference>(clone());
889
+ RoutableReferencePtr r = static_pointer_cast<RoutableReference>(clone());
890
890
  r->_connectionId = id;
891
891
  if (!_endpoints.empty()) // Also override the connection id on the endpoints.
892
892
  {
@@ -896,7 +896,7 @@ IceInternal::RoutableReference::changeConnectionId(string id) const
896
896
  {
897
897
  newEndpoints.push_back(endpoint->connectionId(id));
898
898
  }
899
- r->_endpoints = newEndpoints;
899
+ r->_endpoints = std::move(newEndpoints);
900
900
  }
901
901
  return r;
902
902
  }
@@ -1259,7 +1259,7 @@ IceInternal::RoutableReference::getConnectionAsync(
1259
1259
  if (_routerInfo)
1260
1260
  {
1261
1261
  // If we route, we send everything to the router's client proxy endpoints.
1262
- auto self = dynamic_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1262
+ auto self = static_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1263
1263
 
1264
1264
  _routerInfo->getClientEndpointsAsync(
1265
1265
  [self = std::move(self), response = std::move(response), exception](vector<EndpointIPtr> endpoints) mutable
@@ -1364,7 +1364,7 @@ IceInternal::RoutableReference::getConnectionNoRouterInfoAsync(
1364
1364
  if (_locatorInfo)
1365
1365
  {
1366
1366
  RoutableReferencePtr self =
1367
- dynamic_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1367
+ static_pointer_cast<RoutableReference>(const_cast<RoutableReference*>(this)->shared_from_this());
1368
1368
  _locatorInfo->getEndpoints(
1369
1369
  self,
1370
1370
  _locatorCacheTimeout,