rustorb 0.3.0__tar.gz → 0.4.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 (138) hide show
  1. {rustorb-0.3.0 → rustorb-0.4.0}/Cargo.lock +9 -8
  2. {rustorb-0.3.0 → rustorb-0.4.0}/Cargo.toml +6 -6
  3. {rustorb-0.3.0 → rustorb-0.4.0}/PKG-INFO +1 -1
  4. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/lib.rs +1 -1
  5. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/object.rs +135 -0
  6. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/orb.rs +81 -0
  7. rustorb-0.4.0/crates/rustorb-core/tests/ami.rs +357 -0
  8. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/pi.rs +6 -1
  9. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/stress.rs +13 -1
  10. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/orb.rs +210 -0
  11. {rustorb-0.3.0 → rustorb-0.4.0}/pyproject.toml +1 -1
  12. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/CORBA.py +10 -0
  13. rustorb-0.4.0/rustorb/Messaging.py +191 -0
  14. rustorb-0.4.0/rustorb/Messaging__POA.py +15 -0
  15. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/_native.pyi +2 -0
  16. rustorb-0.3.0/rustorb/Messaging.py +0 -26
  17. {rustorb-0.3.0 → rustorb-0.4.0}/README.md +0 -0
  18. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/Cargo.toml +0 -0
  19. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/LICENSE-APACHE +0 -0
  20. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/LICENSE-MIT +0 -0
  21. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/README.md +0 -0
  22. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/decoder.rs +0 -0
  23. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/encoder.rs +0 -0
  24. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/error.rs +0 -0
  25. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/lib.rs +0 -0
  26. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/long_double.rs +0 -0
  27. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/octets.rs +0 -0
  28. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/traits.rs +0 -0
  29. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/value.rs +0 -0
  30. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/src/xcdr.rs +0 -0
  31. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/tests/cdr.rs +0 -0
  32. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-cdr/tests/xcdr.rs +0 -0
  33. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/Cargo.toml +0 -0
  34. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/LICENSE-APACHE +0 -0
  35. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/LICENSE-MIT +0 -0
  36. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/README.md +0 -0
  37. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/benches/throughput.rs +0 -0
  38. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/codeset.rs +0 -0
  39. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/connection.rs +0 -0
  40. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/dii.rs +0 -0
  41. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/dynany/mod.rs +0 -0
  42. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/dynany/tests.rs +0 -0
  43. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/exception.rs +0 -0
  44. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/fixed.rs +0 -0
  45. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/idl/abstract_iface.rs +0 -0
  46. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/idl/mod.rs +0 -0
  47. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/idl/tests.rs +0 -0
  48. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/idl/value.rs +0 -0
  49. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/idle.rs +0 -0
  50. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/iop.rs +0 -0
  51. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/name.rs +0 -0
  52. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/pi.rs +0 -0
  53. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/poa.rs +0 -0
  54. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/policy.rs +0 -0
  55. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/pool.rs +0 -0
  56. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/servant.rs +0 -0
  57. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/server.rs +0 -0
  58. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/stream.rs +0 -0
  59. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/timeout.rs +0 -0
  60. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/tls.rs +0 -0
  61. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/trace.rs +0 -0
  62. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/typecode/cdr.rs +0 -0
  63. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/typecode/mod.rs +0 -0
  64. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/typecode/tests.rs +0 -0
  65. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/value.rs +0 -0
  66. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/src/wire.rs +0 -0
  67. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/any.rs +0 -0
  68. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/async_api.rs +0 -0
  69. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/bidir.rs +0 -0
  70. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/client.rs +0 -0
  71. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/connections.rs +0 -0
  72. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/dii.rs +0 -0
  73. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/message_size.rs +0 -0
  74. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/poa.rs +0 -0
  75. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/policy.rs +0 -0
  76. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/server.rs +0 -0
  77. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/soak.rs +0 -0
  78. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/ca.pem +0 -0
  79. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/client-bundle.pem +0 -0
  80. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/client.key +0 -0
  81. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/client.pem +0 -0
  82. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/make-certs.sh +0 -0
  83. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/other-ca.pem +0 -0
  84. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/other-server.key +0 -0
  85. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/other-server.pem +0 -0
  86. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/server-bundle.pem +0 -0
  87. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/server.key +0 -0
  88. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/server.pem +0 -0
  89. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/wrong-name.key +0 -0
  90. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls/wrong-name.pem +0 -0
  91. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/tls.rs +0 -0
  92. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/trace.rs +0 -0
  93. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-core/tests/valuetype.rs +0 -0
  94. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/Cargo.toml +0 -0
  95. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/LICENSE-APACHE +0 -0
  96. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/LICENSE-MIT +0 -0
  97. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/README.md +0 -0
  98. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/component.rs +0 -0
  99. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/corbaloc.rs +0 -0
  100. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/error.rs +0 -0
  101. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/fragment.rs +0 -0
  102. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/header.rs +0 -0
  103. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/iiop.rs +0 -0
  104. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/ior.rs +0 -0
  105. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/lib.rs +0 -0
  106. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/message.rs +0 -0
  107. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/service_context.rs +0 -0
  108. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/src/writer.rs +0 -0
  109. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/tests/giop.rs +0 -0
  110. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/tests/ior.rs +0 -0
  111. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-giop/tests/omniorb_golden.rs +0 -0
  112. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/Cargo.toml +0 -0
  113. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/LICENSE-APACHE +0 -0
  114. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/LICENSE-MIT +0 -0
  115. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/README.md +0 -0
  116. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/build.rs +0 -0
  117. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/any.rs +0 -0
  118. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/dii.rs +0 -0
  119. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/dynany.rs +0 -0
  120. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/error.rs +0 -0
  121. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/lib.rs +0 -0
  122. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/log.rs +0 -0
  123. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/pi.rs +0 -0
  124. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/poa.rs +0 -0
  125. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/tc.rs +0 -0
  126. {rustorb-0.3.0 → rustorb-0.4.0}/crates/rustorb-python/src/value.rs +0 -0
  127. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/BiDirPolicy.py +0 -0
  128. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/DynamicAny.py +0 -0
  129. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/IOP.py +0 -0
  130. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/PortableInterceptor.py +0 -0
  131. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/PortableServer.py +0 -0
  132. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/PortableServer__POA.py +0 -0
  133. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/TimeBase.py +0 -0
  134. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/__init__.py +0 -0
  135. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/_log.py +0 -0
  136. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/_rt.py +0 -0
  137. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/_types.py +0 -0
  138. {rustorb-0.3.0 → rustorb-0.4.0}/rustorb/timeouts.py +0 -0
@@ -438,11 +438,11 @@ dependencies = [
438
438
 
439
439
  [[package]]
440
440
  name = "rustorb-cdr"
441
- version = "0.3.0"
441
+ version = "0.4.0"
442
442
 
443
443
  [[package]]
444
444
  name = "rustorb-core"
445
- version = "0.3.0"
445
+ version = "0.4.0"
446
446
  dependencies = [
447
447
  "criterion",
448
448
  "libc",
@@ -457,15 +457,16 @@ dependencies = [
457
457
 
458
458
  [[package]]
459
459
  name = "rustorb-ffi"
460
- version = "0.3.0"
460
+ version = "0.4.0"
461
461
  dependencies = [
462
462
  "rustorb-cdr",
463
463
  "rustorb-core",
464
+ "tokio",
464
465
  ]
465
466
 
466
467
  [[package]]
467
468
  name = "rustorb-giop"
468
- version = "0.3.0"
469
+ version = "0.4.0"
469
470
  dependencies = [
470
471
  "rustorb-cdr",
471
472
  "serde_json",
@@ -473,7 +474,7 @@ dependencies = [
473
474
 
474
475
  [[package]]
475
476
  name = "rustorb-interop"
476
- version = "0.3.0"
477
+ version = "0.4.0"
477
478
  dependencies = [
478
479
  "rustorb-core",
479
480
  "rustorb-naming",
@@ -490,14 +491,14 @@ dependencies = [
490
491
 
491
492
  [[package]]
492
493
  name = "rustorb-naming"
493
- version = "0.3.0"
494
+ version = "0.4.0"
494
495
  dependencies = [
495
496
  "rustorb-core",
496
497
  ]
497
498
 
498
499
  [[package]]
499
500
  name = "rustorb-python"
500
- version = "0.3.0"
501
+ version = "0.4.0"
501
502
  dependencies = [
502
503
  "pyo3",
503
504
  "pyo3-build-config",
@@ -507,7 +508,7 @@ dependencies = [
507
508
 
508
509
  [[package]]
509
510
  name = "rustorb-typesupport"
510
- version = "0.3.0"
511
+ version = "0.4.0"
511
512
  dependencies = [
512
513
  "rustorb-cdr",
513
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.3.0"
6
+ version = "0.4.0"
7
7
  edition = "2024"
8
8
  rust-version = "1.85"
9
9
  license = "MIT OR Apache-2.0"
@@ -13,11 +13,11 @@ 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.3.0" }
17
- rustorb-typesupport = { path = "crates/rustorb-typesupport", version = "0.3.0" }
18
- rustorb-giop = { path = "crates/rustorb-giop", version = "0.3.0" }
19
- rustorb-core = { path = "crates/rustorb-core", version = "0.3.0" }
20
- rustorb-naming = { path = "crates/rustorb-naming", version = "0.3.0" }
16
+ rustorb-cdr = { path = "crates/rustorb-cdr", version = "0.4.0" }
17
+ rustorb-typesupport = { path = "crates/rustorb-typesupport", version = "0.4.0" }
18
+ rustorb-giop = { path = "crates/rustorb-giop", version = "0.4.0" }
19
+ rustorb-core = { path = "crates/rustorb-core", version = "0.4.0" }
20
+ rustorb-naming = { path = "crates/rustorb-naming", version = "0.4.0" }
21
21
  tokio = { version = "1", default-features = false }
22
22
 
23
23
  [workspace.lints.rust]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rustorb
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Topic :: System :: Networking
6
6
  Classifier: Topic :: Software Development :: Object Brokering
@@ -87,7 +87,7 @@ pub use exception::{
87
87
  Exception, OMG_VMCID, SystemException, SystemExceptionKind, UserException, minor,
88
88
  };
89
89
  pub use fixed::{Fixed, ParseFixedError};
90
- pub use object::{AsyncRequest, ObjectRef, Reply, Request};
90
+ pub use object::{AsyncRequest, CallbackRequest, ObjectRef, Reply, Request};
91
91
  pub use orb::{ClientAuth, EndpointAddr, Orb, OrbOptions, ResolveError, TlsOptions};
92
92
  pub use poa::{
93
93
  Bidirectional, IdAssignment, IdUniqueness, ImplicitActivation, Lifespan, ObjectId, Poa,
@@ -152,6 +152,18 @@ impl ObjectRef {
152
152
  }
153
153
  }
154
154
 
155
+ /// Starts a request for `operation` whose reply goes to a callback
156
+ /// ([`CallbackRequest`]): the base of the asynchronous method
157
+ /// invocation (AMI) of the language bindings.
158
+ pub fn request_callback(&self, operation: &str) -> CallbackRequest {
159
+ CallbackRequest {
160
+ obj: self.clone(),
161
+ operation: operation.to_owned(),
162
+ args: None,
163
+ timeout: None,
164
+ }
165
+ }
166
+
155
167
  /// The slots of the calling thread for a request on this reference,
156
168
  /// if its ORB has client interceptors.
157
169
  pub(crate) fn request_slots(&self) -> Option<Vec<crate::Any>> {
@@ -462,6 +474,129 @@ impl<'a> AsyncRequest<'a> {
462
474
  }
463
475
  }
464
476
 
477
+ /// A request that returns at once and hands its reply to a callback: what
478
+ /// the `sendc_` operations of AMI (`docs/ami.md`) are built on.
479
+ ///
480
+ /// The request is sent by the ORB's runtime, as [`AsyncRequest`] does,
481
+ /// and the callback runs on a thread of the ORB's reply pool, not on the
482
+ /// thread that sent it nor on a tokio worker, so it may use the
483
+ /// synchronous API (to call a `ReplyHandler`, say). The timeout and the
484
+ /// Portable Interceptors' request scope slots are those of the thread
485
+ /// that calls [`send`](CallbackRequest::send).
486
+ pub struct CallbackRequest {
487
+ obj: ObjectRef,
488
+ operation: String,
489
+ args: Option<Box<SendArgsFn<'static>>>,
490
+ timeout: Option<Option<Duration>>,
491
+ }
492
+
493
+ impl fmt::Debug for CallbackRequest {
494
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
495
+ f.debug_struct("CallbackRequest")
496
+ .field("operation", &self.operation)
497
+ .field("timeout", &self.timeout)
498
+ .finish_non_exhaustive()
499
+ }
500
+ }
501
+
502
+ impl CallbackRequest {
503
+ /// [`Request::args`]. The function owns what it writes: it runs after
504
+ /// [`send`](CallbackRequest::send) has returned, on the ORB's runtime,
505
+ /// once or more (when the request is forwarded or sent again).
506
+ pub fn args<F>(mut self, f: F) -> CallbackRequest
507
+ where
508
+ F: Fn(&mut OutStream<'_>) -> Result<(), SystemException> + Send + Sync + 'static,
509
+ {
510
+ self.args = Some(Box::new(f));
511
+ self
512
+ }
513
+
514
+ /// [`Request::timeout`].
515
+ pub fn timeout(mut self, timeout: Option<Duration>) -> CallbackRequest {
516
+ self.timeout = Some(timeout);
517
+ self
518
+ }
519
+
520
+ /// Sends the request without waiting for it. `done` gets the reply or
521
+ /// the exception exactly once, on a thread of the reply pool. Fails
522
+ /// only when the ORB is shut down (`BAD_INV_ORDER`), and then `done`
523
+ /// is not called.
524
+ ///
525
+ /// If the ORB is destroyed or its runtime ends before the reply
526
+ /// arrives, `done` gets the exception of the failed call
527
+ /// (`COMM_FAILURE` or `TRANSIENT`), on the thread that ends it.
528
+ pub fn send<F>(self, done: F) -> Result<(), SystemException>
529
+ where
530
+ F: FnOnce(Result<Reply, Exception>) + Send + 'static,
531
+ {
532
+ let CallbackRequest {
533
+ obj,
534
+ operation,
535
+ args,
536
+ timeout,
537
+ } = self;
538
+ let orb = obj.orb.clone();
539
+ orb.check_running()?;
540
+ let timeout = timeout.unwrap_or_else(|| obj.effective_timeout());
541
+ let slots = request_slots(&obj);
542
+ let pending = PendingReply {
543
+ orb: orb.clone(),
544
+ done: Some(done),
545
+ result: None,
546
+ };
547
+ orb.runtime_handle().spawn(async move {
548
+ let mut pending = pending;
549
+ let request = AsyncRequest {
550
+ obj: &obj,
551
+ operation,
552
+ args: args.map(|a| a as Box<SendArgsFn<'_>>),
553
+ timeout: Some(timeout),
554
+ dii: None,
555
+ slots: Some(slots),
556
+ };
557
+ pending.result = Some(request.invoke().await);
558
+ pending.deliver();
559
+ });
560
+ Ok(())
561
+ }
562
+ }
563
+
564
+ /// The callback of a [`CallbackRequest`] and, once known, its result.
565
+ /// Dropped without being delivered (its task or its job dropped by an
566
+ /// ending runtime or pool), it calls the callback where it is dropped.
567
+ struct PendingReply<F: FnOnce(Result<Reply, Exception>) + Send + 'static> {
568
+ orb: Orb,
569
+ done: Option<F>,
570
+ result: Option<Result<Reply, Exception>>,
571
+ }
572
+
573
+ impl<F: FnOnce(Result<Reply, Exception>) + Send + 'static> PendingReply<F> {
574
+ /// Runs the callback on the reply pool.
575
+ fn deliver(self) {
576
+ let orb = self.orb.clone();
577
+ orb.submit_reply(Box::new(move || drop(self)));
578
+ }
579
+ }
580
+
581
+ impl<F: FnOnce(Result<Reply, Exception>) + Send + 'static> Drop for PendingReply<F> {
582
+ /// Calls the callback: on the reply pool through `deliver`; here when
583
+ /// dropped undelivered (the task or the job was dropped), with
584
+ /// `COMM_FAILURE`, off the threads of a runtime.
585
+ fn drop(&mut self) {
586
+ if let Some(done) = self.done.take() {
587
+ let result = self.result.take().unwrap_or_else(|| {
588
+ Err(sys(
589
+ SystemExceptionKind::COMM_FAILURE,
590
+ 0,
591
+ CompletionStatus::Maybe,
592
+ )
593
+ .into())
594
+ });
595
+ crate::orb::run_reply_job(Box::new(move || done(result)));
596
+ }
597
+ }
598
+ }
599
+
465
600
  /// A normal reply: the return value and the `out` and `inout` arguments.
466
601
  #[derive(Debug, Clone)]
467
602
  pub struct Reply {
@@ -635,6 +635,10 @@ pub(crate) struct OrbInner {
635
635
  pi: Mutex<Option<Arc<crate::pi::Interceptors>>>,
636
636
  /// The `BidirectionalPolicy` set with [`Orb::set_policy_overrides`].
637
637
  pub(crate) bidir_override: Mutex<Option<crate::Bidirectional>>,
638
+ /// The threads that run the callbacks of
639
+ /// [`CallbackRequest`](crate::CallbackRequest)s, started with the
640
+ /// first; `Err` once the ORB is destroyed.
641
+ replies: Mutex<Result<Option<crate::pool::Pool>, ()>>,
638
642
  }
639
643
 
640
644
  /// An initial reference registered at run time.
@@ -714,6 +718,7 @@ impl Orb {
714
718
  /// Initialises an ORB with `options`. Fails with the exception of an
715
719
  /// [`OrbInitializer`](crate::pi::OrbInitializer) that failed.
716
720
  pub fn with_options(options: OrbOptions) -> Result<Orb, SystemException> {
721
+ ignore_sigpipe();
717
722
  let runtime = tokio::runtime::Builder::new_multi_thread()
718
723
  .worker_threads(options.io_threads.max(1))
719
724
  .thread_name("rustorb-io")
@@ -806,6 +811,7 @@ impl Orb {
806
811
  pi_on: AtomicBool::new(false),
807
812
  pi: Mutex::new(None),
808
813
  bidir_override: Mutex::new(None),
814
+ replies: Mutex::new(Ok(None)),
809
815
  }),
810
816
  };
811
817
  let mut initializers = crate::pi::registered_initializers();
@@ -1387,6 +1393,9 @@ impl Orb {
1387
1393
  if let Some(server) = self.inner.server.lock().unwrap().take() {
1388
1394
  server.stop_pool();
1389
1395
  }
1396
+ // The callbacks queued run on this thread (the pool drops them).
1397
+ let replies = std::mem::replace(&mut *self.inner.replies.lock().unwrap(), Err(()));
1398
+ drop(replies);
1390
1399
  // Local objects may hold the ORB.
1391
1400
  let registered = std::mem::take(&mut *self.inner.registered.lock().unwrap());
1392
1401
  drop(registered);
@@ -1399,6 +1408,31 @@ impl Orb {
1399
1408
  Ok(())
1400
1409
  }
1401
1410
 
1411
+ /// Runs `job` on the reply pool of [`CallbackRequest`]s, or on the
1412
+ /// calling thread once the ORB is destroyed.
1413
+ ///
1414
+ /// [`CallbackRequest`]: crate::CallbackRequest
1415
+ pub(crate) fn submit_reply(&self, job: Job) {
1416
+ let mut replies = self.inner.replies.lock().unwrap();
1417
+ match &mut *replies {
1418
+ Ok(pool) => {
1419
+ let options = &self.inner.options;
1420
+ pool.get_or_insert_with(|| {
1421
+ crate::pool::Pool::new(
1422
+ 0,
1423
+ options.max_server_threads,
1424
+ options.server_thread_idle_timeout,
1425
+ )
1426
+ })
1427
+ .submit(job);
1428
+ }
1429
+ Err(()) => {
1430
+ drop(replies);
1431
+ run_reply_job(job);
1432
+ }
1433
+ }
1434
+ }
1435
+
1402
1436
  pub(crate) fn check_running(&self) -> Result<(), SystemException> {
1403
1437
  if self.inner.shut_down.load(Ordering::Acquire) {
1404
1438
  return Err(SystemException::new(
@@ -1577,6 +1611,53 @@ fn run_job(job: Job) {
1577
1611
  let _ = panic::catch_unwind(AssertUnwindSafe(job));
1578
1612
  }
1579
1613
 
1614
+ /// Runs a reply callback that cannot go to the reply pool (the ORB is
1615
+ /// destroyed, or it was dropped undelivered): on this thread, unless this
1616
+ /// is a thread of a runtime, where the synchronous API the callback may
1617
+ /// use fails; then on a thread of [`REPLY_FALLBACK`].
1618
+ /// Sets SIGPIPE to be ignored, once, if nothing in the process has set it
1619
+ /// (a Rust program ignores it already; a C++ one does not). The ORB writes
1620
+ /// to sockets with `writev`, which raises SIGPIPE when the other side has
1621
+ /// closed: the write should fail with EPIPE instead of ending the process.
1622
+ #[cfg(unix)]
1623
+ fn ignore_sigpipe() {
1624
+ static ONCE: std::sync::Once = std::sync::Once::new();
1625
+ ONCE.call_once(|| {
1626
+ // SAFETY: sigaction with a zeroed, then filled, struct; the old
1627
+ // action is kept unless it is the default one.
1628
+ unsafe {
1629
+ let mut old: libc::sigaction = std::mem::zeroed();
1630
+ if libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut old) == 0
1631
+ && old.sa_sigaction == libc::SIG_DFL
1632
+ {
1633
+ let mut ignore: libc::sigaction = std::mem::zeroed();
1634
+ ignore.sa_sigaction = libc::SIG_IGN;
1635
+ libc::sigemptyset(&mut ignore.sa_mask);
1636
+ libc::sigaction(libc::SIGPIPE, &ignore, std::ptr::null_mut());
1637
+ }
1638
+ }
1639
+ });
1640
+ }
1641
+
1642
+ #[cfg(not(unix))]
1643
+ fn ignore_sigpipe() {}
1644
+
1645
+ pub(crate) fn run_reply_job(job: Job) {
1646
+ if Handle::try_current().is_err() {
1647
+ run_job(job);
1648
+ return;
1649
+ }
1650
+ REPLY_FALLBACK
1651
+ .get_or_init(|| crate::pool::Pool::new(0, 64, Duration::from_secs(600)))
1652
+ .submit(job);
1653
+ }
1654
+
1655
+ /// The threads of the reply callbacks of [`run_reply_job`], for every
1656
+ /// ORB. Threads that stay, rather than one started for each callback: a
1657
+ /// JVM called on a thread that ended right after crashed now and then on
1658
+ /// Windows.
1659
+ static REPLY_FALLBACK: std::sync::OnceLock<crate::pool::Pool> = std::sync::OnceLock::new();
1660
+
1580
1661
  /// See [`Orb::in_runtime`].
1581
1662
  pub(crate) struct InRuntime<F> {
1582
1663
  handle: Handle,