rustorb 0.7.0__tar.gz → 0.8.0__tar.gz

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 (146) hide show
  1. {rustorb-0.7.0 → rustorb-0.8.0}/Cargo.lock +8 -8
  2. {rustorb-0.7.0 → rustorb-0.8.0}/Cargo.toml +7 -7
  3. {rustorb-0.7.0 → rustorb-0.8.0}/PKG-INFO +1 -1
  4. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/decoder.rs +20 -0
  5. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/value.rs +29 -0
  6. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/benches/throughput.rs +71 -7
  7. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/connection.rs +246 -8
  8. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/idl/mod.rs +31 -0
  9. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/idl/tests.rs +39 -0
  10. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/idle.rs +23 -3
  11. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/lib.rs +1 -0
  12. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/object.rs +325 -95
  13. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/orb.rs +191 -33
  14. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/poa.rs +68 -24
  15. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/pool.rs +8 -0
  16. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/servant.rs +73 -14
  17. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/server.rs +234 -71
  18. rustorb-0.8.0/crates/rustorb-core/src/sock.rs +506 -0
  19. rustorb-0.8.0/crates/rustorb-core/src/stats.rs +247 -0
  20. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/wire.rs +423 -47
  21. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/async_api.rs +33 -0
  22. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/client.rs +55 -0
  23. rustorb-0.8.0/crates/rustorb-core/tests/colocated.rs +532 -0
  24. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/connections.rs +162 -0
  25. rustorb-0.8.0/crates/rustorb-core/tests/stats.rs +150 -0
  26. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/stress.rs +53 -0
  27. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/lib.rs +2 -1
  28. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/message.rs +100 -9
  29. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/writer.rs +37 -7
  30. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/tests/giop.rs +50 -1
  31. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/log.rs +9 -6
  32. {rustorb-0.7.0 → rustorb-0.8.0}/pyproject.toml +1 -1
  33. rustorb-0.7.0/crates/rustorb-core/src/sock.rs +0 -220
  34. {rustorb-0.7.0 → rustorb-0.8.0}/README.md +0 -0
  35. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/Cargo.toml +0 -0
  36. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/LICENSE-APACHE +0 -0
  37. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/LICENSE-MIT +0 -0
  38. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/README.md +0 -0
  39. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/encoder.rs +0 -0
  40. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/error.rs +0 -0
  41. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/lib.rs +0 -0
  42. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/long_double.rs +0 -0
  43. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/octets.rs +0 -0
  44. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/traits.rs +0 -0
  45. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/src/xcdr.rs +0 -0
  46. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/tests/cdr.rs +0 -0
  47. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-cdr/tests/xcdr.rs +0 -0
  48. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/Cargo.toml +0 -0
  49. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/LICENSE-APACHE +0 -0
  50. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/LICENSE-MIT +0 -0
  51. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/README.md +0 -0
  52. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/codeset.rs +0 -0
  53. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/dii.rs +0 -0
  54. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/dynany/mod.rs +0 -0
  55. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/dynany/tests.rs +0 -0
  56. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/exception.rs +0 -0
  57. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/fixed.rs +0 -0
  58. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/idl/abstract_iface.rs +0 -0
  59. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/idl/value.rs +0 -0
  60. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/iop.rs +0 -0
  61. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/name.rs +0 -0
  62. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/pi.rs +0 -0
  63. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/policy.rs +0 -0
  64. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/stream.rs +0 -0
  65. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/timeout.rs +0 -0
  66. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/tls.rs +0 -0
  67. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/trace.rs +0 -0
  68. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/typecode/cdr.rs +0 -0
  69. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/typecode/mod.rs +0 -0
  70. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/typecode/tests.rs +0 -0
  71. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/unix.rs +0 -0
  72. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/src/value.rs +0 -0
  73. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/ami.rs +0 -0
  74. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/any.rs +0 -0
  75. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/bidir.rs +0 -0
  76. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/dii.rs +0 -0
  77. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/message_size.rs +0 -0
  78. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/pi.rs +0 -0
  79. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/poa.rs +0 -0
  80. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/poa_manager_factory.rs +0 -0
  81. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/policy.rs +0 -0
  82. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/server.rs +0 -0
  83. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/soak.rs +0 -0
  84. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/sync_scope.rs +0 -0
  85. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/ca.pem +0 -0
  86. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/client-bundle.pem +0 -0
  87. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/client.key +0 -0
  88. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/client.pem +0 -0
  89. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/make-certs.sh +0 -0
  90. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/other-ca.pem +0 -0
  91. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/other-server.key +0 -0
  92. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/other-server.pem +0 -0
  93. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/server-bundle.pem +0 -0
  94. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/server.key +0 -0
  95. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/server.pem +0 -0
  96. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/wrong-name.key +0 -0
  97. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls/wrong-name.pem +0 -0
  98. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/tls.rs +0 -0
  99. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/trace.rs +0 -0
  100. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/unix.rs +0 -0
  101. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-core/tests/valuetype.rs +0 -0
  102. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/Cargo.toml +0 -0
  103. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/LICENSE-APACHE +0 -0
  104. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/LICENSE-MIT +0 -0
  105. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/README.md +0 -0
  106. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/component.rs +0 -0
  107. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/corbaloc.rs +0 -0
  108. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/error.rs +0 -0
  109. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/fragment.rs +0 -0
  110. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/header.rs +0 -0
  111. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/iiop.rs +0 -0
  112. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/ior.rs +0 -0
  113. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/src/service_context.rs +0 -0
  114. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/tests/ior.rs +0 -0
  115. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-giop/tests/omniorb_golden.rs +0 -0
  116. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/Cargo.toml +0 -0
  117. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/LICENSE-APACHE +0 -0
  118. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/LICENSE-MIT +0 -0
  119. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/README.md +0 -0
  120. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/build.rs +0 -0
  121. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/any.rs +0 -0
  122. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/dii.rs +0 -0
  123. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/dynany.rs +0 -0
  124. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/error.rs +0 -0
  125. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/lib.rs +0 -0
  126. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/orb.rs +0 -0
  127. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/pi.rs +0 -0
  128. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/poa.rs +0 -0
  129. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/tc.rs +0 -0
  130. {rustorb-0.7.0 → rustorb-0.8.0}/crates/rustorb-python/src/value.rs +0 -0
  131. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/BiDirPolicy.py +0 -0
  132. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/CORBA.py +0 -0
  133. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/DynamicAny.py +0 -0
  134. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/IOP.py +0 -0
  135. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/Messaging.py +0 -0
  136. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/Messaging__POA.py +0 -0
  137. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/PortableInterceptor.py +0 -0
  138. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/PortableServer.py +0 -0
  139. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/PortableServer__POA.py +0 -0
  140. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/TimeBase.py +0 -0
  141. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/__init__.py +0 -0
  142. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/_log.py +0 -0
  143. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/_native.pyi +0 -0
  144. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/_rt.py +0 -0
  145. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/_types.py +0 -0
  146. {rustorb-0.7.0 → rustorb-0.8.0}/rustorb/timeouts.py +0 -0
@@ -438,11 +438,11 @@ dependencies = [
438
438
 
439
439
  [[package]]
440
440
  name = "rustorb-cdr"
441
- version = "0.7.0"
441
+ version = "0.8.0"
442
442
 
443
443
  [[package]]
444
444
  name = "rustorb-core"
445
- version = "0.7.0"
445
+ version = "0.8.0"
446
446
  dependencies = [
447
447
  "criterion",
448
448
  "libc",
@@ -457,7 +457,7 @@ dependencies = [
457
457
 
458
458
  [[package]]
459
459
  name = "rustorb-ffi"
460
- version = "0.7.0"
460
+ version = "0.8.0"
461
461
  dependencies = [
462
462
  "rustorb-cdr",
463
463
  "rustorb-core",
@@ -466,7 +466,7 @@ dependencies = [
466
466
 
467
467
  [[package]]
468
468
  name = "rustorb-giop"
469
- version = "0.7.0"
469
+ version = "0.8.0"
470
470
  dependencies = [
471
471
  "rustorb-cdr",
472
472
  "serde_json",
@@ -474,7 +474,7 @@ dependencies = [
474
474
 
475
475
  [[package]]
476
476
  name = "rustorb-interop"
477
- version = "0.7.0"
477
+ version = "0.8.0"
478
478
  dependencies = [
479
479
  "rustorb-core",
480
480
  "rustorb-naming",
@@ -491,14 +491,14 @@ dependencies = [
491
491
 
492
492
  [[package]]
493
493
  name = "rustorb-naming"
494
- version = "0.7.0"
494
+ version = "0.8.0"
495
495
  dependencies = [
496
496
  "rustorb-core",
497
497
  ]
498
498
 
499
499
  [[package]]
500
500
  name = "rustorb-python"
501
- version = "0.7.0"
501
+ version = "0.8.0"
502
502
  dependencies = [
503
503
  "pyo3",
504
504
  "pyo3-build-config",
@@ -508,7 +508,7 @@ dependencies = [
508
508
 
509
509
  [[package]]
510
510
  name = "rustorb-typesupport"
511
- version = "0.7.0"
511
+ version = "0.8.0"
512
512
  dependencies = [
513
513
  "rustorb-cdr",
514
514
  ]
@@ -3,7 +3,7 @@ resolver = "3"
3
3
  members = ["crates/rustorb-cdr", "crates/rustorb-giop", "crates/rustorb-core", "crates/rustorb-python"]
4
4
 
5
5
  [workspace.package]
6
- version = "0.7.0"
6
+ version = "0.8.0"
7
7
  edition = "2024"
8
8
  rust-version = "1.85"
9
9
  license = "MIT OR Apache-2.0"
@@ -13,12 +13,12 @@ keywords = ["corba", "giop", "iiop", "orb", "rpc"]
13
13
  categories = ["network-programming"]
14
14
 
15
15
  [workspace.dependencies]
16
- rustorb-cdr = { path = "crates/rustorb-cdr", version = "0.7.0" }
17
- rustorb-typesupport = { path = "crates/rustorb-typesupport", version = "0.7.0" }
18
- rustorb-giop = { path = "crates/rustorb-giop", version = "0.7.0" }
19
- rustorb-core = { path = "crates/rustorb-core", version = "0.7.0" }
20
- rustorb-naming = { path = "crates/rustorb-naming", version = "0.7.0" }
21
- tokio = { version = "1", default-features = false }
16
+ rustorb-cdr = { path = "crates/rustorb-cdr", version = "0.8.0" }
17
+ rustorb-typesupport = { path = "crates/rustorb-typesupport", version = "0.8.0" }
18
+ rustorb-giop = { path = "crates/rustorb-giop", version = "0.8.0" }
19
+ rustorb-core = { path = "crates/rustorb-core", version = "0.8.0" }
20
+ rustorb-naming = { path = "crates/rustorb-naming", version = "0.8.0" }
21
+ tokio = { version = "1.53.3", default-features = false }
22
22
 
23
23
  [workspace.lints.rust]
24
24
  unsafe_op_in_unsafe_fn = "deny"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rustorb
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Topic :: System :: Networking
6
6
  Classifier: Topic :: Software Development :: Object Brokering
@@ -198,6 +198,26 @@ impl<'a> Decoder<'a> {
198
198
  self.read_octets_raw(n)
199
199
  }
200
200
 
201
+ /// Reads the raw bytes of up to `count` elements of `size` octets
202
+ /// each (a power of two, the size of a number), for reading a run of
203
+ /// numbers at once: aligns for the first element, then takes as many
204
+ /// whole elements as follow it, which is all of them except in a
205
+ /// chunked valuetype, where the run stops at the end of the open chunk.
206
+ /// At least one element when `count` is not 0; a caller loops until it
207
+ /// has read all. The bytes are in [`byte_order`](Decoder::byte_order).
208
+ pub fn read_elements(&mut self, size: usize, count: usize) -> Result<&'a [u8]> {
209
+ if count == 0 {
210
+ return Ok(&[]);
211
+ }
212
+ self.align(size)?;
213
+ let mut n = count;
214
+ if let Some(end) = self.chunk_end() {
215
+ n = n.min((end - self.pos) / size).max(1);
216
+ }
217
+ let len = n.checked_mul(size).ok_or(Error::LengthOverflow(n))?;
218
+ self.read_octets(len)
219
+ }
220
+
201
221
  /// Skips padding, ignoring chunks.
202
222
  pub(crate) fn align_raw(&mut self, align: usize) -> Result<()> {
203
223
  let rem = self.position() % align;
@@ -579,6 +579,35 @@ mod tests {
579
579
  assert!(dec.is_empty());
580
580
  }
581
581
 
582
+ #[test]
583
+ fn read_elements_stops_at_chunk_ends() {
584
+ // A chunked value whose three longs are split over two chunks.
585
+ let mut bytes = Vec::new();
586
+ bytes.extend_from_slice(&0x7fff_ff0au32.to_be_bytes());
587
+ bytes.extend_from_slice(&10u32.to_be_bytes());
588
+ bytes.extend_from_slice(b"IDL:V:1.0\0\0\0");
589
+ bytes.extend_from_slice(&8u32.to_be_bytes());
590
+ bytes.extend_from_slice(&1i32.to_be_bytes());
591
+ bytes.extend_from_slice(&2i32.to_be_bytes());
592
+ bytes.extend_from_slice(&4u32.to_be_bytes());
593
+ bytes.extend_from_slice(&3i32.to_be_bytes());
594
+ bytes.extend_from_slice(&(-1i32).to_be_bytes());
595
+ bytes.extend_from_slice(&[0, 0, 0, 9]);
596
+
597
+ let mut dec = decoder(&bytes, ByteOrder::Big);
598
+ assert!(matches!(
599
+ dec.read_value_header().unwrap(),
600
+ ValueHeader::Value { chunked: true, .. }
601
+ ));
602
+ assert_eq!(dec.read_elements(4, 3).unwrap(), &[0, 0, 0, 1, 0, 0, 0, 2]);
603
+ assert_eq!(dec.read_elements(4, 1).unwrap(), &[0, 0, 0, 3]);
604
+ assert_eq!(dec.read_elements(4, 0).unwrap(), &[] as &[u8]);
605
+ dec.end_value().unwrap();
606
+ // Outside a value: all of them.
607
+ assert_eq!(dec.read_elements(2, 2).unwrap(), &[0, 0, 0, 9]);
608
+ assert!(dec.is_empty());
609
+ }
610
+
582
611
  #[test]
583
612
  fn truncation_skips_unread_state() {
584
613
  let order = ByteOrder::Little;
@@ -14,7 +14,16 @@
14
14
  //! with `read_octet_seq_shared` / `write_octet_seq_shared`), and 16 client ORBs
15
15
  //! (a connection each) calling at once. `echo_long_noop_interceptors` is
16
16
  //! `echo_long` with a Portable Interceptor that does nothing on each side.
17
+ //! - `orb/oneway`: oneway calls as fast as the client sends them, timed
18
+ //! until the servant has run every one (the server's rate).
19
+ //! - `orb/echo_long_threads_one_ref/4`: 4 threads calling through one
20
+ //! object reference (one connection) at once.
21
+ //! - `orb/echo_long_in_process`: the caller and the servant in one ORB.
22
+ //!
23
+ //! The speed plan (docs/perf-plan.md, #203) compares these before and
24
+ //! after each step.
17
25
 
26
+ use std::sync::atomic::{AtomicU64, Ordering};
18
27
  use std::sync::{Arc, Barrier};
19
28
  use std::thread;
20
29
  use std::time::{Duration, Instant};
@@ -36,6 +45,9 @@ use rustorb_core::{
36
45
  const ECHO_ID: &str = "IDL:bench/Echo:1.0";
37
46
  const MIB: usize = 1 << 20;
38
47
 
48
+ /// The oneway `post` calls the servants have run.
49
+ static POSTED: AtomicU64 = AtomicU64::new(0);
50
+
39
51
  struct Echo;
40
52
 
41
53
  impl Servant for Echo {
@@ -65,6 +77,11 @@ impl Servant for Echo {
65
77
  reply.output().write_octet_seq(v)?;
66
78
  Ok(())
67
79
  }
80
+ "post" => {
81
+ input.read::<i32>()?;
82
+ POSTED.fetch_add(1, Ordering::Relaxed);
83
+ Ok(())
84
+ }
68
85
  _ => Err(SystemException::new(
69
86
  SystemExceptionKind::BAD_OPERATION,
70
87
  minor::UNKNOWN_OPERATION,
@@ -114,7 +131,10 @@ fn giop(c: &mut Criterion) {
114
131
  struct Pair {
115
132
  server: Orb,
116
133
  client: Orb,
134
+ /// The object, through the client ORB.
117
135
  obj: ObjectRef,
136
+ /// The object, in the server ORB.
137
+ local: ObjectRef,
118
138
  }
119
139
 
120
140
  /// Client and server interceptors that do nothing.
@@ -166,6 +186,7 @@ impl Pair {
166
186
  server,
167
187
  client,
168
188
  obj,
189
+ local,
169
190
  }
170
191
  }
171
192
  }
@@ -207,6 +228,25 @@ fn echo_octets_shared(obj: &ObjectRef, data: &Octets) -> usize {
207
228
  reply.input().read_octet_seq_shared().unwrap().len()
208
229
  }
209
230
 
231
+ /// Sends `n` oneway calls, then waits until the servant has run them all.
232
+ fn oneway(obj: &ObjectRef, n: u64) {
233
+ let target = POSTED.load(Ordering::Relaxed) + n;
234
+ for i in 0..n {
235
+ obj.request("post")
236
+ .args(move |out| {
237
+ out.write_i32(i as i32);
238
+ Ok(())
239
+ })
240
+ .send_oneway()
241
+ .unwrap();
242
+ }
243
+ let deadline = Instant::now() + Duration::from_secs(30);
244
+ while POSTED.load(Ordering::Relaxed) < target {
245
+ assert!(Instant::now() < deadline, "oneway calls lost");
246
+ thread::yield_now();
247
+ }
248
+ }
249
+
210
250
  fn echo_octets(obj: &ObjectRef, data: &[u8]) -> usize {
211
251
  let reply = obj
212
252
  .request("echo_octets")
@@ -225,6 +265,28 @@ fn orb(c: &mut Criterion) {
225
265
  group.bench_function("echo_long", |b| {
226
266
  b.iter(|| assert_eq!(echo_long(&pair.obj, 7), 7));
227
267
  });
268
+ group.bench_function("echo_long_in_process", |b| {
269
+ b.iter(|| assert_eq!(echo_long(&pair.local, 7), 7));
270
+ });
271
+ group.bench_function("oneway", |b| {
272
+ b.iter_custom(|iters| {
273
+ let t = Instant::now();
274
+ oneway(&pair.obj, iters);
275
+ t.elapsed()
276
+ });
277
+ });
278
+ // Each iteration is one call from each thread, all at once.
279
+ {
280
+ let threads = 4;
281
+ let refs = vec![pair.obj.clone(); threads];
282
+ group.throughput(Throughput::Elements(threads as u64));
283
+ group.bench_with_input(
284
+ BenchmarkId::new("echo_long_threads_one_ref", threads),
285
+ &refs,
286
+ |b, refs| b.iter_custom(|iters| concurrent(refs, iters)),
287
+ );
288
+ }
289
+ group.throughput(Throughput::Elements(1));
228
290
  let intercepted = Pair::with(vec![Arc::new(Noop)]);
229
291
  group.bench_function("echo_long_noop_interceptors", |b| {
230
292
  b.iter(|| assert_eq!(echo_long(&intercepted.obj, 7), 7));
@@ -254,11 +316,12 @@ fn orb(c: &mut Criterion) {
254
316
  (o, obj)
255
317
  })
256
318
  .collect();
319
+ let refs: Vec<ObjectRef> = orbs.iter().map(|(_, obj)| obj.clone()).collect();
257
320
  group.throughput(Throughput::Elements(clients as u64));
258
321
  group.bench_with_input(
259
322
  BenchmarkId::new("echo_long_connections", clients),
260
- &orbs,
261
- |b, orbs| b.iter_custom(|iters| concurrent(orbs, iters)),
323
+ &refs,
324
+ |b, refs| b.iter_custom(|iters| concurrent(refs, iters)),
262
325
  );
263
326
  for (o, _) in orbs {
264
327
  let _ = o.destroy();
@@ -267,12 +330,13 @@ fn orb(c: &mut Criterion) {
267
330
  group.finish();
268
331
  }
269
332
 
270
- /// Has every client make `iters` calls at once; returns the wall time.
271
- fn concurrent(orbs: &[(Orb, ObjectRef)], iters: u64) -> Duration {
272
- let start = Arc::new(Barrier::new(orbs.len() + 1));
273
- let handles: Vec<_> = orbs
333
+ /// Has a thread for each reference make `iters` calls, all at once;
334
+ /// returns the wall time.
335
+ fn concurrent(refs: &[ObjectRef], iters: u64) -> Duration {
336
+ let start = Arc::new(Barrier::new(refs.len() + 1));
337
+ let handles: Vec<_> = refs
274
338
  .iter()
275
- .map(|(_, obj)| {
339
+ .map(|obj| {
276
340
  let obj = obj.clone();
277
341
  let start = Arc::clone(&start);
278
342
  thread::spawn(move || {
@@ -17,7 +17,7 @@
17
17
 
18
18
  use std::collections::HashMap;
19
19
  use std::io::{self, IoSlice};
20
- use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
20
+ use std::sync::atomic::{AtomicBool, AtomicU32, AtomicU64, AtomicUsize, Ordering};
21
21
  use std::sync::{Arc, Mutex, OnceLock, Weak};
22
22
 
23
23
  use std::time::{Duration, Instant};
@@ -31,9 +31,10 @@ use tokio::sync::oneshot;
31
31
  use crate::idle::Stamp;
32
32
  use crate::server::{Outbox, Server, ServerConn};
33
33
  use crate::sock::{Stream, WriteHalf};
34
+ use crate::stats::{self, Counter};
34
35
  use crate::tls::{self, Tls};
35
36
  use crate::trace;
36
- use crate::wire::{Here, Inbound, ReadError};
37
+ use crate::wire::{FirstRead, Here, Inbound, Lag, ReadError};
37
38
  use crate::{CodeSets, OrbOptions};
38
39
 
39
40
  /// Why a connection stopped delivering replies.
@@ -81,8 +82,171 @@ pub(crate) enum Transport {
81
82
  /// the transport.
82
83
  pub(crate) type EndpointKey = (String, u16, Transport);
83
84
 
84
- /// The ORB's client connections, one per endpoint.
85
- pub(crate) type ConnectionPool = Mutex<HashMap<EndpointKey, Arc<Connection>>>;
85
+ /// The ORB's client connections, by endpoint.
86
+ pub(crate) type ConnectionPool = Mutex<HashMap<EndpointKey, Slot>>;
87
+
88
+ /// The connections to one endpoint (docs/connections.md): up to
89
+ /// [`OrbOptions::max_connections_per_server`], opened as calls run at
90
+ /// the same time. A call takes a connection no call is on, the one the
91
+ /// calling thread used last if it can; with none free it opens another,
92
+ /// and at the limit it shares the one with the fewest calls.
93
+ #[derive(Debug, Default)]
94
+ pub(crate) struct Slot {
95
+ conns: Vec<Arc<Connection>>,
96
+ /// Connections being opened for the endpoint.
97
+ opening: usize,
98
+ /// Wakes the calls waiting for a connection being opened.
99
+ opened: Arc<tokio::sync::Notify>,
100
+ }
101
+
102
+ /// What [`Slot::pick`] chose.
103
+ pub(crate) enum Pick {
104
+ /// Use this connection.
105
+ Use(Lease),
106
+ /// Open a connection; the slot counts it as opening.
107
+ Open,
108
+ /// Wait for one being opened, and pick again: the limit is reached
109
+ /// with connections being opened only.
110
+ Wait(Arc<tokio::sync::Notify>),
111
+ }
112
+
113
+ impl Slot {
114
+ /// A slot with `conn` only (a connection a client offered for
115
+ /// bidirectional GIOP).
116
+ pub(crate) fn only(conn: Arc<Connection>) -> Slot {
117
+ Slot {
118
+ conns: vec![conn],
119
+ ..Slot::default()
120
+ }
121
+ }
122
+
123
+ /// The usable connections.
124
+ pub(crate) fn usable(&self) -> impl Iterator<Item = &Arc<Connection>> {
125
+ self.conns.iter().filter(|c| c.is_usable())
126
+ }
127
+
128
+ /// Whether the slot has `conn`.
129
+ pub(crate) fn has(&self, conn: &Arc<Connection>) -> bool {
130
+ self.conns.iter().any(|c| Arc::ptr_eq(c, conn))
131
+ }
132
+
133
+ /// Chooses the connection for a call, with at most `max` connections.
134
+ pub(crate) fn pick(&mut self, max: usize) -> Pick {
135
+ let me = thread_tag();
136
+ let mut usable = 0;
137
+ let mut best: Option<(&Arc<Connection>, usize)> = None;
138
+ for c in self.conns.iter().filter(|c| c.is_usable()) {
139
+ // Calls to a client's objects go over the connection it
140
+ // offered: it may not be reachable otherwise.
141
+ if c.is_accepted() {
142
+ return Pick::Use(Lease::new(c));
143
+ }
144
+ usable += 1;
145
+ let calls = c.calls.load(Ordering::Relaxed);
146
+ if calls == 0 && c.last_thread.load(Ordering::Relaxed) == me {
147
+ return Pick::Use(Lease::new(c));
148
+ }
149
+ if best.is_none_or(|(_, fewest)| calls < fewest) {
150
+ best = Some((c, calls));
151
+ }
152
+ }
153
+ match best {
154
+ Some((c, 0)) => Pick::Use(Lease::new(c)),
155
+ _ if usable + self.opening < max.max(1) => {
156
+ self.opening += 1;
157
+ Pick::Open
158
+ }
159
+ Some((c, _)) => {
160
+ stats::count(Counter::connection_shares);
161
+ Pick::Use(Lease::new(c))
162
+ }
163
+ None => Pick::Wait(Arc::clone(&self.opened)),
164
+ }
165
+ }
166
+
167
+ /// Ends an opening [`pick`](Self::pick) asked for: `conn` joins the
168
+ /// slot, unless it holds `max` usable connections already (others
169
+ /// opened meanwhile); then the call uses the least busy of those and
170
+ /// `conn` is returned to be closed.
171
+ pub(crate) fn opened(
172
+ &mut self,
173
+ conn: Option<Arc<Connection>>,
174
+ max: usize,
175
+ ) -> Option<(Lease, Option<Arc<Connection>>)> {
176
+ self.opening = self.opening.saturating_sub(1);
177
+ self.opened.notify_waiters();
178
+ let conn = conn?;
179
+ let full = self.usable().any(|c| c.is_accepted()) || self.usable().count() >= max.max(1);
180
+ if full {
181
+ let existing = self
182
+ .usable()
183
+ .min_by_key(|c| (!c.is_accepted(), c.calls.load(Ordering::Relaxed)))
184
+ .expect("a usable connection");
185
+ return Some((Lease::new(existing), Some(conn)));
186
+ }
187
+ self.conns.retain(|c| c.is_usable());
188
+ self.conns.push(Arc::clone(&conn));
189
+ Some((Lease::new(&conn), None))
190
+ }
191
+
192
+ /// Takes the connections out that `choose` picks.
193
+ pub(crate) fn take(
194
+ &mut self,
195
+ mut choose: impl FnMut(&Connection) -> bool,
196
+ ) -> Vec<Arc<Connection>> {
197
+ let mut taken = Vec::new();
198
+ self.conns.retain(|c| {
199
+ if choose(c) {
200
+ taken.push(Arc::clone(c));
201
+ false
202
+ } else {
203
+ true
204
+ }
205
+ });
206
+ taken
207
+ }
208
+
209
+ /// Whether nothing is in the slot or being opened for it.
210
+ pub(crate) fn is_empty(&self) -> bool {
211
+ self.conns.is_empty() && self.opening == 0
212
+ }
213
+ }
214
+
215
+ /// A connection taken for one call: counted as busy until dropped.
216
+ #[derive(Debug)]
217
+ pub(crate) struct Lease(Arc<Connection>);
218
+
219
+ impl Lease {
220
+ /// Taken under the pool's lock, so that the next pick sees the call.
221
+ fn new(conn: &Arc<Connection>) -> Lease {
222
+ conn.calls.fetch_add(1, Ordering::Relaxed);
223
+ conn.last_thread.store(thread_tag(), Ordering::Relaxed);
224
+ Lease(Arc::clone(conn))
225
+ }
226
+ }
227
+
228
+ impl std::ops::Deref for Lease {
229
+ type Target = Arc<Connection>;
230
+
231
+ fn deref(&self) -> &Arc<Connection> {
232
+ &self.0
233
+ }
234
+ }
235
+
236
+ impl Drop for Lease {
237
+ fn drop(&mut self) {
238
+ self.0.calls.fetch_sub(1, Ordering::Relaxed);
239
+ }
240
+ }
241
+
242
+ /// A number for the calling thread, never 0.
243
+ fn thread_tag() -> u64 {
244
+ static NEXT: AtomicU64 = AtomicU64::new(1);
245
+ thread_local! {
246
+ static TAG: u64 = NEXT.fetch_add(1, Ordering::Relaxed);
247
+ }
248
+ TAG.with(|t| *t)
249
+ }
86
250
 
87
251
  /// What a waiting caller receives.
88
252
  pub(crate) type Delivery = Result<Message, Closed>;
@@ -138,6 +302,9 @@ pub(crate) struct Connection {
138
302
  /// The code sets of the first request with a code set context; `None`
139
303
  /// until one was sent.
140
304
  code_sets: Mutex<Option<CodeSets>>,
305
+ /// The code set context of the requests, made once: the code sets
306
+ /// are fixed for the connection.
307
+ code_set_context: OnceLock<(CodeSets, ByteOrder, ServiceContext)>,
141
308
  /// Set under the `pending` lock (by [`close`](Self::close) too), so
142
309
  /// that an idle connection takes no new request once chosen to close.
143
310
  closing: AtomicBool,
@@ -149,6 +316,10 @@ pub(crate) struct Connection {
149
316
  serving: OnceLock<Serving>,
150
317
  /// Whether a request with the `BI_DIR_IIOP` context went out.
151
318
  offered: AtomicBool,
319
+ /// Calls on the connection now ([`Lease`]).
320
+ calls: AtomicUsize,
321
+ /// The thread that took the connection last ([`thread_tag`]).
322
+ last_thread: AtomicU64,
152
323
  }
153
324
 
154
325
  impl Connection {
@@ -191,7 +362,7 @@ impl Connection {
191
362
  Peer(&endpoint),
192
363
  if session.is_some() { " with TLS" } else { "" }
193
364
  );
194
- let (reader, writer) = stream.into_split();
365
+ let (reader, writer) = stream.into_split()?;
195
366
  let conn = Arc::new(Connection {
196
367
  endpoint,
197
368
  inbound: Arc::new(Inbound::new(reader, session.clone(), max_message_size)),
@@ -205,13 +376,17 @@ impl Connection {
205
376
  // the other side odd ones (GIOP 1.2, bidirectional GIOP).
206
377
  next_request_id: AtomicU32::new(0),
207
378
  code_sets: Mutex::new(None),
379
+ code_set_context: OnceLock::new(),
208
380
  closing: AtomicBool::new(false),
209
381
  last_used: Stamp::new(),
210
382
  pool,
211
383
  serving: OnceLock::new(),
212
384
  offered: AtomicBool::new(false),
385
+ calls: AtomicUsize::new(0),
386
+ last_thread: AtomicU64::new(0),
213
387
  });
214
388
  tokio::spawn(read_loop(Arc::clone(&conn)));
389
+ stats::count(Counter::connects);
215
390
  Ok(conn)
216
391
  }
217
392
 
@@ -236,11 +411,14 @@ impl Connection {
236
411
  }),
237
412
  next_request_id: AtomicU32::new(1),
238
413
  code_sets: Mutex::new(None),
414
+ code_set_context: OnceLock::new(),
239
415
  closing: AtomicBool::new(false),
240
416
  last_used: Stamp::new(),
241
417
  pool,
242
418
  serving: OnceLock::new(),
243
419
  offered: AtomicBool::new(false),
420
+ calls: AtomicUsize::new(0),
421
+ last_thread: AtomicU64::new(0),
244
422
  })
245
423
  }
246
424
 
@@ -292,6 +470,11 @@ impl Connection {
292
470
  &self.endpoint
293
471
  }
294
472
 
473
+ /// Whether no call holds the connection ([`Lease`]).
474
+ pub(crate) fn is_free(&self) -> bool {
475
+ self.calls.load(Ordering::Relaxed) == 0
476
+ }
477
+
295
478
  /// Whether the connection can take new requests.
296
479
  pub(crate) fn is_usable(&self) -> bool {
297
480
  !self.closing.load(Ordering::Acquire) && self.pending.lock().unwrap().closed.is_none()
@@ -312,6 +495,22 @@ impl Connection {
312
495
  *self.code_sets.lock().unwrap().get_or_insert(proposed)
313
496
  }
314
497
 
498
+ /// The code set context announcing `cs` in byte order `order`.
499
+ pub(crate) fn code_set_context(
500
+ &self,
501
+ cs: CodeSets,
502
+ order: ByteOrder,
503
+ ) -> std::borrow::Cow<'_, ServiceContext> {
504
+ let (made_cs, made_order, context) = self
505
+ .code_set_context
506
+ .get_or_init(|| (cs, order, cs.context().to_service_context(order)));
507
+ if (*made_cs, *made_order) == (cs, order) {
508
+ std::borrow::Cow::Borrowed(context)
509
+ } else {
510
+ std::borrow::Cow::Owned(cs.context().to_service_context(order))
511
+ }
512
+ }
513
+
315
514
  /// Registers a caller waiting for the reply to `request_id`.
316
515
  pub(crate) fn expect_reply(
317
516
  &self,
@@ -341,10 +540,18 @@ impl Connection {
341
540
  ///
342
541
  /// Blocks the thread; the caller is a thread of its own (the sync API
343
542
  /// runs the call with `block_on` outside the runtime).
543
+ ///
544
+ /// With `keep`, the caller keeps the reading after its reply, off the
545
+ /// runtime's poller, for its next call on the connection: that costs
546
+ /// no `epoll_ctl` and no read for nothing each call. `keep` gives the
547
+ /// reading back to the reader task if no call comes within
548
+ /// [`crate::OrbOptions::follow_linger`], and a caller that waits for
549
+ /// the task meanwhile gives it back at once ([`resume`](Self::resume)).
344
550
  pub(crate) fn read_reply_here(
345
551
  &self,
346
552
  request_id: u32,
347
553
  deadline: Option<Instant>,
554
+ keep: Option<&Lag>,
348
555
  ) -> Option<Option<Message>> {
349
556
  if self.is_accepted() {
350
557
  // The server connection's reader reads.
@@ -375,7 +582,7 @@ impl Connection {
375
582
  return None;
376
583
  }
377
584
  loop {
378
- let (version, message) = match self.inbound.read_here(deadline) {
585
+ let (version, message) = match self.inbound.read_here(deadline, FirstRead::Wait) {
379
586
  Here::Message(version, message) => (version, message),
380
587
  Here::TimedOut => return Some(None),
381
588
  Here::HandedBack => return None,
@@ -389,14 +596,42 @@ impl Connection {
389
596
  }
390
597
  };
391
598
  if id == request_id {
392
- self.inbound.release();
393
599
  self.forget(request_id);
600
+ match keep {
601
+ // Requests from the server come through the reader
602
+ // task, which must read whatever arrives.
603
+ Some(lag) if self.serving.get().is_none() => self.keep_reading(lag),
604
+ _ => self.inbound.release(),
605
+ }
394
606
  return Some(Some(message));
395
607
  }
396
608
  self.deliver(id, message);
397
609
  }
398
610
  }
399
611
 
612
+ /// After its reply, the caller keeps the reading for its next call,
613
+ /// unless another caller waits for a reply: that one waits for the
614
+ /// reader task.
615
+ fn keep_reading(&self, lag: &Lag) {
616
+ self.inbound.busy(true);
617
+ lag.watch(&self.inbound);
618
+ stats::count(Counter::reply_keeps);
619
+ // A caller that registered before this saw the reading with this
620
+ // thread and left it ([`resume`](Self::resume) found nothing to
621
+ // do): it gets the task back now. One that registers after this
622
+ // finds the reading kept.
623
+ if !self.pending.lock().unwrap().waiters.is_empty() {
624
+ self.resume();
625
+ }
626
+ }
627
+
628
+ /// Gives the reading back to the reader task if a caller kept it
629
+ /// after its reply ([`read_reply_here`](Self::read_reply_here)): the
630
+ /// calling caller waits for the task to read its reply.
631
+ pub(crate) fn resume(&self) {
632
+ self.inbound.resume();
633
+ }
634
+
400
635
  /// Stops waiting for `request_id`, after a timeout.
401
636
  pub(crate) fn forget(&self, request_id: u32) {
402
637
  self.pending.lock().unwrap().waiters.remove(&request_id);
@@ -787,7 +1022,10 @@ impl Connection {
787
1022
  /// (a connection a client offered has one per listen point).
788
1023
  pub(crate) fn leave_pool(self: &Arc<Self>) {
789
1024
  if let Some(pool) = self.pool.upgrade() {
790
- pool.lock().unwrap().retain(|_, c| !Arc::ptr_eq(c, self));
1025
+ pool.lock().unwrap().retain(|_, slot| {
1026
+ slot.take(|c| std::ptr::eq(c, &**self));
1027
+ !slot.is_empty()
1028
+ });
791
1029
  }
792
1030
  }
793
1031
  }