zeroc-ice 3.7.11 → 3.7.12

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 (209) hide show
  1. checksums.yaml +4 -4
  2. data/dist/IceRuby/Communicator.cpp +11 -2
  3. data/dist/IceRuby/Properties.cpp +2 -2
  4. data/dist/IceRuby/Types.cpp +3 -3
  5. data/dist/ice/cpp/include/Ice/InputStream.h +7 -4
  6. data/dist/ice/cpp/include/IceDiscovery/IceDiscovery.h +2 -2
  7. data/dist/ice/cpp/include/IceLocatorDiscovery/IceLocatorDiscovery.h +2 -2
  8. data/dist/ice/cpp/include/IceUtil/Config.h +2 -2
  9. data/dist/ice/cpp/include/IceUtil/ResourceConfig.h +2 -2
  10. data/dist/ice/cpp/include/generated/Glacier2/Metrics.h +2 -2
  11. data/dist/ice/cpp/include/generated/Glacier2/PermissionsVerifier.h +2 -2
  12. data/dist/ice/cpp/include/generated/Glacier2/PermissionsVerifierF.h +2 -2
  13. data/dist/ice/cpp/include/generated/Glacier2/Router.h +2 -2
  14. data/dist/ice/cpp/include/generated/Glacier2/RouterF.h +2 -2
  15. data/dist/ice/cpp/include/generated/Glacier2/SSLInfo.h +2 -2
  16. data/dist/ice/cpp/include/generated/Glacier2/Session.h +2 -2
  17. data/dist/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
  18. data/dist/ice/cpp/include/generated/Ice/Communicator.h +2 -2
  19. data/dist/ice/cpp/include/generated/Ice/CommunicatorF.h +2 -2
  20. data/dist/ice/cpp/include/generated/Ice/Connection.h +2 -2
  21. data/dist/ice/cpp/include/generated/Ice/ConnectionF.h +2 -2
  22. data/dist/ice/cpp/include/generated/Ice/Current.h +2 -2
  23. data/dist/ice/cpp/include/generated/Ice/Endpoint.h +2 -2
  24. data/dist/ice/cpp/include/generated/Ice/EndpointF.h +2 -2
  25. data/dist/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
  26. data/dist/ice/cpp/include/generated/Ice/FacetMap.h +2 -2
  27. data/dist/ice/cpp/include/generated/Ice/Identity.h +2 -2
  28. data/dist/ice/cpp/include/generated/Ice/ImplicitContext.h +2 -2
  29. data/dist/ice/cpp/include/generated/Ice/ImplicitContextF.h +2 -2
  30. data/dist/ice/cpp/include/generated/Ice/Instrumentation.h +2 -2
  31. data/dist/ice/cpp/include/generated/Ice/InstrumentationF.h +2 -2
  32. data/dist/ice/cpp/include/generated/Ice/LocalException.h +2 -2
  33. data/dist/ice/cpp/include/generated/Ice/Locator.h +2 -2
  34. data/dist/ice/cpp/include/generated/Ice/LocatorF.h +2 -2
  35. data/dist/ice/cpp/include/generated/Ice/Logger.h +2 -2
  36. data/dist/ice/cpp/include/generated/Ice/LoggerF.h +2 -2
  37. data/dist/ice/cpp/include/generated/Ice/Metrics.h +2 -2
  38. data/dist/ice/cpp/include/generated/Ice/ObjectAdapter.h +2 -2
  39. data/dist/ice/cpp/include/generated/Ice/ObjectAdapterF.h +2 -2
  40. data/dist/ice/cpp/include/generated/Ice/ObjectFactory.h +2 -2
  41. data/dist/ice/cpp/include/generated/Ice/Plugin.h +2 -2
  42. data/dist/ice/cpp/include/generated/Ice/PluginF.h +2 -2
  43. data/dist/ice/cpp/include/generated/Ice/Process.h +2 -2
  44. data/dist/ice/cpp/include/generated/Ice/ProcessF.h +2 -2
  45. data/dist/ice/cpp/include/generated/Ice/Properties.h +2 -2
  46. data/dist/ice/cpp/include/generated/Ice/PropertiesAdmin.h +2 -2
  47. data/dist/ice/cpp/include/generated/Ice/PropertiesF.h +2 -2
  48. data/dist/ice/cpp/include/generated/Ice/RemoteLogger.h +2 -2
  49. data/dist/ice/cpp/include/generated/Ice/Router.h +2 -2
  50. data/dist/ice/cpp/include/generated/Ice/RouterF.h +2 -2
  51. data/dist/ice/cpp/include/generated/Ice/ServantLocator.h +2 -2
  52. data/dist/ice/cpp/include/generated/Ice/ServantLocatorF.h +2 -2
  53. data/dist/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
  54. data/dist/ice/cpp/include/generated/Ice/ValueFactory.h +2 -2
  55. data/dist/ice/cpp/include/generated/Ice/Version.h +2 -2
  56. data/dist/ice/cpp/include/generated/IceBox/IceBox.h +2 -2
  57. data/dist/ice/cpp/include/generated/IceGrid/Admin.h +2 -2
  58. data/dist/ice/cpp/include/generated/IceGrid/Descriptor.h +2 -2
  59. data/dist/ice/cpp/include/generated/IceGrid/Exception.h +2 -2
  60. data/dist/ice/cpp/include/generated/IceGrid/FileParser.h +2 -2
  61. data/dist/ice/cpp/include/generated/IceGrid/PluginFacade.h +2 -2
  62. data/dist/ice/cpp/include/generated/IceGrid/Registry.h +2 -2
  63. data/dist/ice/cpp/include/generated/IceGrid/Session.h +2 -2
  64. data/dist/ice/cpp/include/generated/IceGrid/UserAccountMapper.h +2 -2
  65. data/dist/ice/cpp/include/generated/IcePatch2/FileInfo.h +2 -2
  66. data/dist/ice/cpp/include/generated/IcePatch2/FileServer.h +2 -2
  67. data/dist/ice/cpp/include/generated/IceSSL/ConnectionInfo.h +2 -2
  68. data/dist/ice/cpp/include/generated/IceSSL/ConnectionInfoF.h +2 -2
  69. data/dist/ice/cpp/include/generated/IceSSL/EndpointInfo.h +2 -2
  70. data/dist/ice/cpp/include/generated/IceStorm/IceStorm.h +2 -2
  71. data/dist/ice/cpp/include/generated/IceStorm/Metrics.h +2 -2
  72. data/dist/ice/cpp/src/Ice/BatchRequestQueue.cpp +31 -12
  73. data/dist/ice/cpp/src/Ice/BatchRequestQueue.h +7 -0
  74. data/dist/ice/cpp/src/Ice/CommunicatorI.cpp +10 -0
  75. data/dist/ice/cpp/src/Ice/ConnectionI.cpp +45 -0
  76. data/dist/ice/cpp/src/Ice/IPEndpointI.cpp +6 -0
  77. data/dist/ice/cpp/src/Ice/InputStream.cpp +25 -8
  78. data/dist/ice/cpp/src/Ice/Network.cpp +37 -24
  79. data/dist/ice/cpp/src/Ice/NetworkProxy.cpp +15 -4
  80. data/dist/ice/cpp/src/Ice/ObjectAdapterI.cpp +1 -0
  81. data/dist/ice/cpp/src/Ice/Reference.cpp +6 -0
  82. data/dist/ice/cpp/src/Ice/ReferenceFactory.cpp +3 -1
  83. data/dist/ice/cpp/src/Ice/Selector.cpp +13 -5
  84. data/dist/ice/cpp/src/Ice/Timer.cpp +8 -2
  85. data/dist/ice/cpp/src/Ice/UdpTransceiver.cpp +52 -34
  86. data/dist/ice/cpp/src/Ice/WSTransceiver.cpp +79 -13
  87. data/dist/ice/cpp/src/Ice/generated/BuiltinSequences.cpp +2 -2
  88. data/dist/ice/cpp/src/Ice/generated/Communicator.cpp +2 -2
  89. data/dist/ice/cpp/src/Ice/generated/CommunicatorF.cpp +2 -2
  90. data/dist/ice/cpp/src/Ice/generated/Connection.cpp +2 -2
  91. data/dist/ice/cpp/src/Ice/generated/ConnectionF.cpp +2 -2
  92. data/dist/ice/cpp/src/Ice/generated/Current.cpp +2 -2
  93. data/dist/ice/cpp/src/Ice/generated/Endpoint.cpp +2 -2
  94. data/dist/ice/cpp/src/Ice/generated/EndpointF.cpp +2 -2
  95. data/dist/ice/cpp/src/Ice/generated/EndpointTypes.cpp +2 -2
  96. data/dist/ice/cpp/src/Ice/generated/FacetMap.cpp +2 -2
  97. data/dist/ice/cpp/src/Ice/generated/Identity.cpp +2 -2
  98. data/dist/ice/cpp/src/Ice/generated/ImplicitContext.cpp +2 -2
  99. data/dist/ice/cpp/src/Ice/generated/ImplicitContextF.cpp +2 -2
  100. data/dist/ice/cpp/src/Ice/generated/Instrumentation.cpp +2 -2
  101. data/dist/ice/cpp/src/Ice/generated/InstrumentationF.cpp +2 -2
  102. data/dist/ice/cpp/src/Ice/generated/LocalException.cpp +2 -2
  103. data/dist/ice/cpp/src/Ice/generated/Locator.cpp +2 -2
  104. data/dist/ice/cpp/src/Ice/generated/LocatorF.cpp +2 -2
  105. data/dist/ice/cpp/src/Ice/generated/Logger.cpp +2 -2
  106. data/dist/ice/cpp/src/Ice/generated/LoggerF.cpp +2 -2
  107. data/dist/ice/cpp/src/Ice/generated/Metrics.cpp +2 -2
  108. data/dist/ice/cpp/src/Ice/generated/ObjectAdapter.cpp +2 -2
  109. data/dist/ice/cpp/src/Ice/generated/ObjectAdapterF.cpp +2 -2
  110. data/dist/ice/cpp/src/Ice/generated/ObjectFactory.cpp +2 -2
  111. data/dist/ice/cpp/src/Ice/generated/Plugin.cpp +2 -2
  112. data/dist/ice/cpp/src/Ice/generated/PluginF.cpp +2 -2
  113. data/dist/ice/cpp/src/Ice/generated/Process.cpp +2 -2
  114. data/dist/ice/cpp/src/Ice/generated/ProcessF.cpp +2 -2
  115. data/dist/ice/cpp/src/Ice/generated/Properties.cpp +2 -2
  116. data/dist/ice/cpp/src/Ice/generated/PropertiesAdmin.cpp +2 -2
  117. data/dist/ice/cpp/src/Ice/generated/PropertiesF.cpp +2 -2
  118. data/dist/ice/cpp/src/Ice/generated/RemoteLogger.cpp +2 -2
  119. data/dist/ice/cpp/src/Ice/generated/Router.cpp +2 -2
  120. data/dist/ice/cpp/src/Ice/generated/RouterF.cpp +2 -2
  121. data/dist/ice/cpp/src/Ice/generated/ServantLocator.cpp +2 -2
  122. data/dist/ice/cpp/src/Ice/generated/ServantLocatorF.cpp +2 -2
  123. data/dist/ice/cpp/src/Ice/generated/SliceChecksumDict.cpp +2 -2
  124. data/dist/ice/cpp/src/Ice/generated/ValueFactory.cpp +2 -2
  125. data/dist/ice/cpp/src/Ice/generated/Version.cpp +2 -2
  126. data/dist/ice/cpp/src/IceDiscovery/generated/IceDiscovery/IceDiscovery.h +2 -2
  127. data/dist/ice/cpp/src/IceDiscovery/generated/IceDiscovery.cpp +2 -2
  128. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/IceLocatorDiscovery/IceLocatorDiscovery.h +2 -2
  129. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/IceLocatorDiscovery.cpp +2 -2
  130. data/dist/ice/cpp/src/IceSSL/OpenSSLEngine.cpp +17 -9
  131. data/dist/ice/cpp/src/IceSSL/OpenSSLTransceiverI.cpp +1 -0
  132. data/dist/ice/cpp/src/IceSSL/OpenSSLUtil.cpp +2 -0
  133. data/dist/ice/cpp/src/IceSSL/RFC2253.cpp +1 -1
  134. data/dist/ice/cpp/src/IceSSL/SChannelEngine.cpp +12 -2
  135. data/dist/ice/cpp/src/IceSSL/SChannelTransceiverI.cpp +2 -1
  136. data/dist/ice/cpp/src/IceSSL/SSLEngine.cpp +16 -1
  137. data/dist/ice/cpp/src/IceSSL/SecureTransportEngine.cpp +107 -2
  138. data/dist/ice/cpp/src/IceSSL/SecureTransportEngine.h +7 -0
  139. data/dist/ice/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +2 -0
  140. data/dist/ice/cpp/src/IceSSL/SecureTransportUtil.cpp +1 -1
  141. data/dist/ice/cpp/src/IceSSL/TrustManager.cpp +12 -1
  142. data/dist/ice/cpp/src/IceSSL/generated/ConnectionInfo.cpp +2 -2
  143. data/dist/ice/cpp/src/IceSSL/generated/ConnectionInfoF.cpp +2 -2
  144. data/dist/ice/cpp/src/IceSSL/generated/EndpointInfo.cpp +2 -2
  145. data/dist/ice/cpp/src/IceUtil/ConvertUTF.cpp +4 -0
  146. data/dist/ice/cpp/src/IceUtil/FileUtil.cpp +1 -1
  147. data/dist/ice/cpp/src/IceUtil/Time.cpp +4 -4
  148. data/dist/ice/cpp/src/Slice/JavaUtil.cpp +4 -4
  149. data/dist/lib/Glacier2/Metrics.rb +1 -1
  150. data/dist/lib/Glacier2/PermissionsVerifier.rb +1 -1
  151. data/dist/lib/Glacier2/PermissionsVerifierF.rb +1 -1
  152. data/dist/lib/Glacier2/Router.rb +1 -1
  153. data/dist/lib/Glacier2/RouterF.rb +1 -1
  154. data/dist/lib/Glacier2/SSLInfo.rb +1 -1
  155. data/dist/lib/Glacier2/Session.rb +1 -1
  156. data/dist/lib/Ice/BuiltinSequences.rb +1 -1
  157. data/dist/lib/Ice/Communicator.rb +1 -1
  158. data/dist/lib/Ice/CommunicatorF.rb +1 -1
  159. data/dist/lib/Ice/Connection.rb +1 -1
  160. data/dist/lib/Ice/ConnectionF.rb +1 -1
  161. data/dist/lib/Ice/Current.rb +1 -1
  162. data/dist/lib/Ice/Endpoint.rb +1 -1
  163. data/dist/lib/Ice/EndpointF.rb +1 -1
  164. data/dist/lib/Ice/EndpointTypes.rb +1 -1
  165. data/dist/lib/Ice/FacetMap.rb +1 -1
  166. data/dist/lib/Ice/Identity.rb +1 -1
  167. data/dist/lib/Ice/ImplicitContext.rb +1 -1
  168. data/dist/lib/Ice/ImplicitContextF.rb +1 -1
  169. data/dist/lib/Ice/Instrumentation.rb +1 -1
  170. data/dist/lib/Ice/InstrumentationF.rb +1 -1
  171. data/dist/lib/Ice/LocalException.rb +1 -1
  172. data/dist/lib/Ice/Locator.rb +1 -1
  173. data/dist/lib/Ice/LocatorF.rb +1 -1
  174. data/dist/lib/Ice/Logger.rb +1 -1
  175. data/dist/lib/Ice/LoggerF.rb +1 -1
  176. data/dist/lib/Ice/Metrics.rb +1 -1
  177. data/dist/lib/Ice/ObjectAdapter.rb +1 -1
  178. data/dist/lib/Ice/ObjectAdapterF.rb +1 -1
  179. data/dist/lib/Ice/ObjectFactory.rb +1 -1
  180. data/dist/lib/Ice/Plugin.rb +1 -1
  181. data/dist/lib/Ice/PluginF.rb +1 -1
  182. data/dist/lib/Ice/Process.rb +1 -1
  183. data/dist/lib/Ice/ProcessF.rb +1 -1
  184. data/dist/lib/Ice/Properties.rb +1 -1
  185. data/dist/lib/Ice/PropertiesAdmin.rb +1 -1
  186. data/dist/lib/Ice/PropertiesF.rb +1 -1
  187. data/dist/lib/Ice/RemoteLogger.rb +1 -1
  188. data/dist/lib/Ice/Router.rb +1 -1
  189. data/dist/lib/Ice/RouterF.rb +1 -1
  190. data/dist/lib/Ice/ServantLocator.rb +1 -1
  191. data/dist/lib/Ice/ServantLocatorF.rb +1 -1
  192. data/dist/lib/Ice/SliceChecksumDict.rb +1 -1
  193. data/dist/lib/Ice/ValueFactory.rb +1 -1
  194. data/dist/lib/Ice/Version.rb +1 -1
  195. data/dist/lib/IceBox/IceBox.rb +1 -1
  196. data/dist/lib/IceGrid/Admin.rb +1 -1
  197. data/dist/lib/IceGrid/Descriptor.rb +1 -1
  198. data/dist/lib/IceGrid/Exception.rb +1 -1
  199. data/dist/lib/IceGrid/FileParser.rb +1 -1
  200. data/dist/lib/IceGrid/PluginFacade.rb +1 -1
  201. data/dist/lib/IceGrid/Registry.rb +1 -1
  202. data/dist/lib/IceGrid/Session.rb +1 -1
  203. data/dist/lib/IceGrid/UserAccountMapper.rb +1 -1
  204. data/dist/lib/IcePatch2/FileInfo.rb +1 -1
  205. data/dist/lib/IcePatch2/FileServer.rb +1 -1
  206. data/dist/lib/IceStorm/IceStorm.rb +1 -1
  207. data/dist/lib/IceStorm/Metrics.rb +1 -1
  208. data/ice.gemspec +1 -1
  209. metadata +1 -1
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) ZeroC, Inc. All rights reserved.
3
3
  //
4
4
  //
5
- // Ice version 3.7.11
5
+ // Ice version 3.7.12
6
6
  //
7
7
  // <auto-generated>
8
8
  //
@@ -44,7 +44,7 @@
44
44
  # if ICE_INT_VERSION % 100 >= 50
45
45
  # error Beta header file detected
46
46
  # endif
47
- # if ICE_INT_VERSION % 100 < 11
47
+ # if ICE_INT_VERSION % 100 < 12
48
48
  # error Ice patch level mismatch!
49
49
  # endif
50
50
  #endif
@@ -102,17 +102,22 @@ BatchRequestQueue::finishBatchRequest(OutputStream* os,
102
102
  const Ice::ObjectPrxPtr& proxy,
103
103
  const std::string& operation)
104
104
  {
105
- //
106
- // No need for synchronization, no other threads are supposed
107
- // to modify the queue since we set _batchStreamInUse to true.
108
- //
109
- assert(_batchStreamInUse);
110
- _batchStream.swap(*os);
105
+ {
106
+ //
107
+ // Bring the request stream back and become the owner so this thread's own auto-flush below can re-enter
108
+ // swap(). swap() lets only _batchStreamOwner through while the stream is in use, and only after passing
109
+ // that gate does it read the queue's bookkeeping; no other thread can touch the queue, so the mutations
110
+ // below need no further synchronization.
111
+ //
112
+ Lock sync(*this);
113
+ assert(_batchStreamInUse);
114
+ _batchStream.swap(*os);
115
+ _batchStreamCanFlush = true;
116
+ _batchStreamOwner = IceUtil::ThreadControl();
117
+ }
111
118
 
112
119
  try
113
120
  {
114
- _batchStreamCanFlush = true; // Allow flush to proceed even if the stream is marked in use.
115
-
116
121
  if(_maxSize > 0 && _batchStream.b.size() >= _maxSize)
117
122
  {
118
123
  #ifdef ICE_CPP11_MAPPING
@@ -149,8 +154,13 @@ BatchRequestQueue::finishBatchRequest(OutputStream* os,
149
154
  _batchStreamCanFlush = false;
150
155
  notifyAll();
151
156
  }
152
- catch(const std::exception&)
157
+ catch(...)
153
158
  {
159
+ //
160
+ // Restore the queue to a usable state on any exception, including a non-std::exception escaping the
161
+ // interceptor. Otherwise _batchStreamInUse would stay set and all future prepareBatchRequest/swap calls
162
+ // would block forever.
163
+ //
154
164
  Lock sync(*this);
155
165
  _batchStream.resize(_batchMarker);
156
166
  _batchStreamInUse = false;
@@ -177,13 +187,18 @@ int
177
187
  BatchRequestQueue::swap(OutputStream* os, bool& compress)
178
188
  {
179
189
  Lock sync(*this);
190
+
191
+ waitStreamInUse(true);
192
+
193
+ //
194
+ // Read the bookkeeping only after waitStreamInUse: finishBatchRequest mutates it without the lock while it
195
+ // owns the in-use stream, so reading _batchRequestNum before the wait would race those writes.
196
+ //
180
197
  if(_batchRequestNum == 0)
181
198
  {
182
199
  return 0;
183
200
  }
184
201
 
185
- waitStreamInUse(true);
186
-
187
202
  vector<Ice::Byte> lastRequest;
188
203
  if(_batchMarker < _batchStream.b.size())
189
204
  {
@@ -230,7 +245,11 @@ BatchRequestQueue::isEmpty()
230
245
  void
231
246
  BatchRequestQueue::waitStreamInUse(bool flush)
232
247
  {
233
- while(_batchStreamInUse && !(flush && _batchStreamCanFlush))
248
+ //
249
+ // Only the thread that currently owns the in-use stream may bypass the wait to run its own auto-flush; every
250
+ // other caller waits for the in-progress batch request to finish.
251
+ //
252
+ while(_batchStreamInUse && !(flush && _batchStreamCanFlush && _batchStreamOwner == IceUtil::ThreadControl()))
234
253
  {
235
254
  wait();
236
255
  }
@@ -8,6 +8,7 @@
8
8
  #include <IceUtil/Shared.h>
9
9
  #include <IceUtil/Mutex.h>
10
10
  #include <IceUtil/Monitor.h>
11
+ #include <IceUtil/Thread.h>
11
12
  #include <Ice/UniquePtr.h>
12
13
 
13
14
  #include <Ice/BatchRequestInterceptor.h>
@@ -46,7 +47,13 @@ private:
46
47
  #endif
47
48
  Ice::OutputStream _batchStream;
48
49
  bool _batchStreamInUse;
50
+ //
51
+ // While finishBatchRequest holds the in-use stream, _batchStreamCanFlush is true and _batchStreamOwner is its
52
+ // thread: the only thread allowed to re-enter swap() (for its own auto-flush). Other threads wait for
53
+ // _batchStreamInUse to clear.
54
+ //
49
55
  bool _batchStreamCanFlush;
56
+ IceUtil::ThreadControl _batchStreamOwner;
50
57
  bool _batchCompress;
51
58
  int _batchRequestNum;
52
59
  size_t _batchMarker;
@@ -15,6 +15,7 @@
15
15
  #include <Ice/TraceLevels.h>
16
16
  #include <Ice/Router.h>
17
17
  #include <Ice/OutgoingAsync.h>
18
+ #include <Ice/RequestHandler.h> // For RetryException
18
19
  #include <IceUtil/Mutex.h>
19
20
  #include <IceUtil/MutexPtrLock.h>
20
21
  #include <Ice/UUID.h>
@@ -146,6 +147,15 @@ CommunicatorFlushBatchAsync::flushConnection(const ConnectionIPtr& con, Ice::Com
146
147
  con->sendAsyncRequest(flushBatch, compress, false, batchRequestNum);
147
148
  }
148
149
  }
150
+ catch(const RetryException& ex)
151
+ {
152
+ //
153
+ // If the connection is closed and sendAsyncRequest throws a RetryException, we release the use count taken
154
+ // above and rethrow the underlying exception to the caller.
155
+ //
156
+ check(false);
157
+ ex.get()->ice_throw();
158
+ }
149
159
  catch(const LocalException&)
150
160
  {
151
161
  check(false);
@@ -1060,17 +1060,28 @@ Ice::ConnectionI::end_heartbeat(const AsyncResultPtr& r)
1060
1060
  void
1061
1061
  Ice::ConnectionI::setHeartbeatCallback(ICE_IN(ICE_DELEGATE(HeartbeatCallback)) callback)
1062
1062
  {
1063
+ //
1064
+ // Destroy the replaced callback after the lock is released, as in setCloseCallback.
1065
+ //
1066
+ ICE_DELEGATE(HeartbeatCallback) previous;
1063
1067
  IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
1064
1068
  if(_state >= StateClosed)
1065
1069
  {
1066
1070
  return;
1067
1071
  }
1072
+ previous.swap(_heartbeatCallback);
1068
1073
  _heartbeatCallback = callback;
1069
1074
  }
1070
1075
 
1071
1076
  void
1072
1077
  Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_DELEGATE(CloseCallback)) callback)
1073
1078
  {
1079
+ //
1080
+ // Holds the callback this call replaces. It is declared before the lock so that it is destroyed after the lock
1081
+ // is released: destroying a callback can run arbitrary code (a language mapping may attach a finalizer to it),
1082
+ // and that code can call back into this connection, which must not relock the connection mutex.
1083
+ //
1084
+ ICE_DELEGATE(CloseCallback) previous;
1074
1085
  IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
1075
1086
  if(_state >= StateClosed)
1076
1087
  {
@@ -1109,6 +1120,7 @@ Ice::ConnectionI::setCloseCallback(ICE_IN(ICE_DELEGATE(CloseCallback)) callback)
1109
1120
  }
1110
1121
  else
1111
1122
  {
1123
+ previous.swap(_closeCallback);
1112
1124
  _closeCallback = callback;
1113
1125
  }
1114
1126
  }
@@ -1242,6 +1254,11 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con
1242
1254
  outAsync->invokeExceptionAsync();
1243
1255
  }
1244
1256
  }
1257
+
1258
+ if(_asyncRequests.empty())
1259
+ {
1260
+ notifyAll(); // Notify threads blocked in close(GracefullyWithWait)
1261
+ }
1245
1262
  return;
1246
1263
  }
1247
1264
  }
@@ -1265,6 +1282,11 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con
1265
1282
  outAsync->invokeExceptionAsync();
1266
1283
  }
1267
1284
  }
1285
+
1286
+ if(_asyncRequests.empty())
1287
+ {
1288
+ notifyAll(); // Notify threads blocked in close(GracefullyWithWait)
1289
+ }
1268
1290
  return;
1269
1291
  }
1270
1292
  }
@@ -1286,6 +1308,11 @@ Ice::ConnectionI::asyncRequestCanceled(const OutgoingAsyncBasePtr& outAsync, con
1286
1308
  outAsync->invokeExceptionAsync();
1287
1309
  }
1288
1310
  }
1311
+
1312
+ if(_asyncRequests.empty())
1313
+ {
1314
+ notifyAll(); // Notify threads blocked in close(GracefullyWithWait)
1315
+ }
1289
1316
  return;
1290
1317
  }
1291
1318
  }
@@ -3234,6 +3261,11 @@ Ice::ConnectionI::doUncompress(InputStream& compressed, InputStream& uncompresse
3234
3261
  throw CompressionException(__FILE__, __LINE__, "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError));
3235
3262
  }
3236
3263
 
3264
+ if(uncompressedLen != static_cast<unsigned int>(uncompressedSize - headerSize))
3265
+ {
3266
+ throw ProtocolException(__FILE__, __LINE__, "decompressed message size does not match expected size");
3267
+ }
3268
+
3237
3269
  copy(compressed.b.begin(), compressed.b.begin() + headerSize, uncompressed.b.begin());
3238
3270
  }
3239
3271
  #endif
@@ -3343,6 +3375,19 @@ Ice::ConnectionI::parseMessage(InputStream& stream, Int& invokeNum, Int& request
3343
3375
  invokeNum = 0;
3344
3376
  throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
3345
3377
  }
3378
+
3379
+ //
3380
+ // A batched request occupies at least 12 bytes on the wire (a 2-byte identity, a
3381
+ // 1-byte facet path, a 1-byte operation name, a 1-byte operation mode, a 1-byte
3382
+ // context, and a 6-byte parameters encapsulation). Reject a count larger than the
3383
+ // remaining message data could possibly hold.
3384
+ //
3385
+ const Int minBatchRequestSize = 12;
3386
+ if(invokeNum > (stream.b.end() - stream.i) / minBatchRequestSize)
3387
+ {
3388
+ invokeNum = 0;
3389
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
3390
+ }
3346
3391
  servantManager = _servantManager;
3347
3392
  adapter = _adapter;
3348
3393
  dispatchCount += invokeNum;
@@ -531,6 +531,12 @@ IceInternal::IPEndpointI::IPEndpointI(const ProtocolInstancePtr& instance, Input
531
531
  {
532
532
  s->read(const_cast<string&>(_host), false);
533
533
  s->read(const_cast<Ice::Int&>(_port));
534
+ if(_port < 0 || _port > 65535)
535
+ {
536
+ ostringstream os;
537
+ os << "port value '" << _port << "' is out of range";
538
+ throw MarshalException(__FILE__, __LINE__, os.str());
539
+ }
534
540
  }
535
541
 
536
542
  IceInternal::EndpointHostResolver::EndpointHostResolver(const InstancePtr& instance) :
@@ -20,6 +20,7 @@
20
20
  #include <Ice/SlicedData.h>
21
21
  #include <Ice/StringConverter.h>
22
22
  #include <iterator>
23
+ #include <climits>
23
24
 
24
25
  #ifndef ICE_UNALIGNED
25
26
  # if defined(__i386) || defined(_M_IX86) || defined(__x86_64) || defined(_M_X64)
@@ -324,7 +325,8 @@ Ice::InputStream::skipEncapsulation()
324
325
  {
325
326
  throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
326
327
  }
327
- if(i - sizeof(Int) + sz > b.end())
328
+ // sz includes the 4 bytes of the size itself, which we have already read.
329
+ if(sz - 4 > b.end() - i)
328
330
  {
329
331
  throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
330
332
  }
@@ -384,14 +386,19 @@ Ice::InputStream::readAndCheckSeqSize(int minSize)
384
386
  // the estimated remaining buffer size. This estimation is based on
385
387
  // the minimum size of the enclosing sequences, it's _minSeqSize.
386
388
  //
387
- if(_startSeq == -1 || i > (b.begin() + _startSeq + _minSeqSize))
389
+ // 'sz' is peer-controlled (up to INT32_MAX), so we compute the minimum size of this sequence in
390
+ // 64-bit: 'sz * minSize' would otherwise overflow a 32-bit int and bypass the bounds check below.
391
+ Long minSeqSize = static_cast<Long>(sz) * minSize;
392
+
393
+ // '_startSeq + _minSeqSize' does not overflow: on the previous call, the bounds check below
394
+ // established this sum is <= b.size(), itself smaller than INT32_MAX.
395
+ if(_startSeq == -1 || (i - b.begin()) > _startSeq + _minSeqSize)
388
396
  {
389
397
  _startSeq = static_cast<int>(i - b.begin());
390
- _minSeqSize = sz * minSize;
391
398
  }
392
399
  else
393
400
  {
394
- _minSeqSize += sz * minSize;
401
+ minSeqSize += _minSeqSize;
395
402
  }
396
403
 
397
404
  //
@@ -399,11 +406,14 @@ Ice::InputStream::readAndCheckSeqSize(int minSize)
399
406
  // possibly enclosed sequences), something is wrong with the marshalled
400
407
  // data: it's claiming having more data that what is possible to read.
401
408
  //
402
- if(_startSeq + _minSeqSize > static_cast<int>(b.size()))
409
+ if(_startSeq + minSeqSize > static_cast<Long>(b.size()))
403
410
  {
404
411
  throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
405
412
  }
406
413
 
414
+ // minSeqSize is now known to be <= b.size(), itself smaller than INT32_MAX.
415
+ _minSeqSize = static_cast<int>(minSeqSize);
416
+
407
417
  return sz;
408
418
  }
409
419
 
@@ -1942,7 +1952,7 @@ Ice::InputStream::EncapsDecoder10::read(PatchFunc patchFunc, void* patchAddr)
1942
1952
  //
1943
1953
  Int index;
1944
1954
  _stream->read(index);
1945
- if(index > 0)
1955
+ if(index > 0 || index == INT_MIN)
1946
1956
  {
1947
1957
  throw MarshalException(__FILE__, __LINE__, "invalid object id");
1948
1958
  }
@@ -2435,7 +2445,11 @@ Ice::InputStream::EncapsDecoder11::startSlice()
2435
2445
  if(_current->sliceFlags & FLAG_HAS_SLICE_SIZE)
2436
2446
  {
2437
2447
  _stream->read(_current->sliceSize);
2438
- if(_current->sliceSize < 4)
2448
+ // A slice with optional members carries at least the 1-byte end marker in its body, so its
2449
+ // size (which includes the 4-byte size field) must be >= 5. We rely on this in skipSlice's
2450
+ // slice-preservation logic, which excludes the end marker by stepping back one byte.
2451
+ Ice::Int minSliceSize = (_current->sliceFlags & FLAG_HAS_OPTIONAL_MEMBERS) ? 5 : 4;
2452
+ if(_current->sliceSize < minSliceSize)
2439
2453
  {
2440
2454
  throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
2441
2455
  }
@@ -2586,7 +2600,10 @@ Ice::InputStream::EncapsDecoder11::readOptional(Ice::Int readTag, Ice::OptionalF
2586
2600
  Int
2587
2601
  Ice::InputStream::EncapsDecoder11::readInstance(Int index, PatchFunc patchFunc, void* patchAddr)
2588
2602
  {
2589
- assert(index > 0);
2603
+ if(index <= 0)
2604
+ {
2605
+ throw MarshalException(__FILE__, __LINE__, "invalid class instance index");
2606
+ }
2590
2607
 
2591
2608
  if(index > 1)
2592
2609
  {
@@ -1587,35 +1587,48 @@ IceInternal::getRecvBufferSize(SOCKET fd)
1587
1587
  void
1588
1588
  IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string& intf)
1589
1589
  {
1590
- vector<string> interfaces = getInterfacesForMulticast(intf, getProtocolSupport(group));
1591
- set<int> indexes;
1592
- for(vector<string>::const_iterator p = interfaces.begin(); p != interfaces.end(); ++p)
1590
+ try
1593
1591
  {
1594
- int rc = 0;
1595
- if(group.saStorage.ss_family == AF_INET)
1596
- {
1597
- struct ip_mreq mreq;
1598
- mreq.imr_multiaddr = group.saIn.sin_addr;
1599
- mreq.imr_interface = getInterfaceAddress(*p);
1600
- rc = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
1601
- }
1602
- else
1592
+ vector<string> interfaces = getInterfacesForMulticast(intf, getProtocolSupport(group));
1593
+ set<int> indexes;
1594
+ for(vector<string>::const_iterator p = interfaces.begin(); p != interfaces.end(); ++p)
1603
1595
  {
1604
- int index = getInterfaceIndex(*p);
1605
- if(indexes.find(index) == indexes.end()) // Don't join twice the same interface (if it has multiple IPs)
1596
+ int rc = 0;
1597
+ if(group.saStorage.ss_family == AF_INET)
1606
1598
  {
1607
- indexes.insert(index);
1608
- struct ipv6_mreq mreq;
1609
- mreq.ipv6mr_multiaddr = group.saIn6.sin6_addr;
1610
- mreq.ipv6mr_interface = static_cast<unsigned int>(index);
1611
- rc = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
1599
+ struct ip_mreq mreq;
1600
+ mreq.imr_multiaddr = group.saIn.sin_addr;
1601
+ mreq.imr_interface = getInterfaceAddress(*p);
1602
+ rc = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
1603
+ }
1604
+ else
1605
+ {
1606
+ int index = getInterfaceIndex(*p);
1607
+ // Don't join twice the same interface (if it has multiple IPs).
1608
+ if(indexes.find(index) == indexes.end())
1609
+ {
1610
+ indexes.insert(index);
1611
+ struct ipv6_mreq mreq;
1612
+ mreq.ipv6mr_multiaddr = group.saIn6.sin6_addr;
1613
+ mreq.ipv6mr_interface = static_cast<unsigned int>(index);
1614
+ rc = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, reinterpret_cast<char*>(&mreq),
1615
+ int(sizeof(mreq)));
1616
+ }
1617
+ }
1618
+ if(rc == SOCKET_ERROR)
1619
+ {
1620
+ throw SocketException(__FILE__, __LINE__, getSocketErrno());
1612
1621
  }
1613
1622
  }
1614
- if(rc == SOCKET_ERROR)
1615
- {
1616
- closeSocketNoThrow(fd);
1617
- throw SocketException(__FILE__, __LINE__, getSocketErrno());
1618
- }
1623
+ }
1624
+ catch(...)
1625
+ {
1626
+ //
1627
+ // Close the socket on any failure (interface resolution or the multicast join) so this helper always
1628
+ // leaves the socket closed when it throws, like doBind and setReuseAddress.
1629
+ //
1630
+ closeSocketNoThrow(fd);
1631
+ throw;
1619
1632
  }
1620
1633
  }
1621
1634
 
@@ -232,7 +232,12 @@ HTTPNetworkProxy::endRead(Buffer& buf)
232
232
  // reading otherwise we're done.
233
233
  //
234
234
  const Ice::Byte* end = HttpParser().isCompleteMessage(buf.b.begin(), buf.i);
235
- if(!end && buf.i == buf.b.end())
235
+ if(end)
236
+ {
237
+ return SocketOperationNone;
238
+ }
239
+
240
+ if(buf.i == buf.b.end())
236
241
  {
237
242
  //
238
243
  // Read one more byte, we can't easily read bytes in advance
@@ -243,16 +248,22 @@ HTTPNetworkProxy::endRead(Buffer& buf)
243
248
  //
244
249
  buf.b.resize(buf.b.size() + 1);
245
250
  buf.i = buf.b.begin() + buf.b.size() - 1;
246
- return SocketOperationRead;
247
251
  }
248
- return SocketOperationNone;
252
+ return SocketOperationRead;
249
253
  }
250
254
 
251
255
  void
252
256
  HTTPNetworkProxy::finish(Buffer& readBuffer, Buffer&)
253
257
  {
254
258
  HttpParser parser;
255
- parser.parse(readBuffer.b.begin(), readBuffer.b.end());
259
+ try
260
+ {
261
+ parser.parse(readBuffer.b.begin(), readBuffer.b.end());
262
+ }
263
+ catch(const WebSocketException& ex)
264
+ {
265
+ throw Ice::ProtocolException(__FILE__, __LINE__, "malformed HTTP proxy response: " + ex.reason);
266
+ }
256
267
  if(parser.status() != 200)
257
268
  {
258
269
  throw Ice::ConnectFailedException(__FILE__, __LINE__);
@@ -1486,6 +1486,7 @@ Ice::ObjectAdapterI::filterProperties(StringSeq& unknownProps)
1486
1486
  "ThreadPool.SizeWarn",
1487
1487
  "ThreadPool.StackSize",
1488
1488
  "ThreadPool.Serialize",
1489
+ "ThreadPool.ThreadIdleTime",
1489
1490
  "ThreadPool.ThreadPriority"
1490
1491
  };
1491
1492
 
@@ -1516,7 +1516,13 @@ IceInternal::RoutableReference::operator<(const Reference& r) const
1516
1516
  {
1517
1517
  return true;
1518
1518
  }
1519
+ #ifdef ICE_CPP11_MAPPING
1520
+ else if(lexicographical_compare(rhs->_endpoints.begin(), rhs->_endpoints.end(),
1521
+ _endpoints.begin(), _endpoints.end(),
1522
+ Ice::TargetCompare<shared_ptr<EndpointI>, std::less>()))
1523
+ #else
1519
1524
  else if(rhs->_endpoints < _endpoints)
1525
+ #endif
1520
1526
  {
1521
1527
  return false;
1522
1528
  }
@@ -593,7 +593,9 @@ IceInternal::ReferenceFactory::create(const Identity& ident, InputStream* s)
593
593
  vector<EndpointIPtr> endpoints;
594
594
  string adapterId;
595
595
 
596
- Ice::Int sz = s->readSize();
596
+ // Each endpoint occupies at least 8 bytes on the wire (a 2-byte type plus a 6-byte minimum
597
+ // encapsulation), so readAndCheckSeqSize rejects an oversized count before we allocate.
598
+ Ice::Int sz = s->readAndCheckSeqSize(8);
597
599
 
598
600
  if(sz > 0)
599
601
  {
@@ -155,10 +155,13 @@ Selector::getNextHandler(SocketOperation& status, int timeout)
155
155
  }
156
156
  else
157
157
  {
158
- Ice::SocketException ex(__FILE__, __LINE__, err);
159
- Ice::Error out(_instance->initializationData().logger);
160
- out << "couldn't dequeue packet from completion port:\n" << ex;
161
- IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(5)); // Sleep 5s to avoid looping
158
+ // This indicates an internal error with the IOCP completion port, we log the error and abort.
159
+ {
160
+ Ice::SocketException ex(__FILE__, __LINE__, err);
161
+ Ice::Error out(_instance->initializationData().logger);
162
+ out << "couldn't dequeue packet from completion port:\n" << ex;
163
+ } // The message is logged when out goes out of scope.
164
+ abort();
162
165
  }
163
166
  }
164
167
  AsyncInfo* info = static_cast<AsyncInfo*>(ol);
@@ -1379,6 +1382,12 @@ Selector::finish(EventHandler* handler, bool closeNow)
1379
1382
  void
1380
1383
  Selector::ready(EventHandler* handler, SocketOperation status, bool value)
1381
1384
  {
1385
+ //
1386
+ // Hold the selector lock across the read-modify-write of handler->_ready. The run-loop thread reads _ready
1387
+ // with this lock held (in startSelect/finishSelect, via EventHandlerWrapper), so updating it without the lock
1388
+ // would be a data race.
1389
+ //
1390
+ Lock sync(*this);
1382
1391
  if(((handler->_ready & status) != 0) == value)
1383
1392
  {
1384
1393
  return; // Nothing to do if ready state already correctly set.
@@ -1393,7 +1402,6 @@ Selector::ready(EventHandler* handler, SocketOperation status, bool value)
1393
1402
  handler->_ready = static_cast<SocketOperation>(handler->_ready & ~status);
1394
1403
  }
1395
1404
 
1396
- Lock sync(*this);
1397
1405
  std::map<EventHandler*, EventHandlerWrapperPtr>::iterator p = _wrappers.find(handler);
1398
1406
  assert(p != _wrappers.end());
1399
1407
  p->second->checkReady();
@@ -36,6 +36,12 @@ Timer::Timer(int priority) :
36
36
  void
37
37
  Timer::destroy()
38
38
  {
39
+ //
40
+ // Destroy the tasks after the lock is released and the timer thread joined: a task's destructor can re-enter the
41
+ // timer via cancel(), which would deadlock while _monitor is locked.
42
+ //
43
+ set<Token> tokens;
44
+ map<TimerTaskPtr, IceUtil::Time, TimerTaskCompare> tasks;
39
45
  {
40
46
  IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
41
47
  if(_destroyed)
@@ -44,8 +50,8 @@ Timer::destroy()
44
50
  }
45
51
  _destroyed = true;
46
52
  _monitor.notify();
47
- _tasks.clear();
48
- _tokens.clear();
53
+ tasks.swap(_tasks);
54
+ tokens.swap(_tokens);
49
55
  }
50
56
 
51
57
  if(getThreadControl() == ThreadControl())