Comments (4)
@nhorman So, this is a nice idea, but won't quite work. There are various reasons, but here's an arbitrary one:
T1 calls some blocking API call, and enters block_until_pred and goes to sleep
There was no data queued for the network when this happened, so poll() is listening to POLLIN but not POLLOUT
(since the UDP socket kernel buffers are not full, listening to POLLOUT would make it wake up immediately)
Later T2 calls a non-blocking API call, and the connection is ticked
Data is generated and queued for transmission to the network
The amount of data generated fills the UDP socket kernel buffers, which means some
data needs to be transmitted in the future when POLLOUT is asserted
The data to be transmitted may e.g. be an application message which yields a response which T1 is waiting for
Therefore to make forward progress, T1's internal poll(2) call must return and be re-executed
so that it is now listening for POLLOUT
Since this can't happen without T2 having some way to notify T1 to wake up, T1 still has circumstances where
blocking calls will incorrectly hang (at least until an event timeout)
But it's a nice idea and closing in on a decent solution. My take on the fix here (which does still need a notifier) is in #24257.
from openssl.
Couldn't this problem be solved more efficiently with the use of a muted, condition variable, and state variable (the last of which records which streams are readable)? It would save a potentially significant number of syscalls, and as you note, avoid having to create socket resources under the covers
from openssl.
Couldn't this problem be solved more efficiently with the use of a muted, condition variable, and state variable (the last of which records which streams are readable)? It would save a potentially significant number of syscalls, and as you note, avoid having to create socket resources under the covers
The problem is that modern OSes generally don't have syscalls which can block on both a condition variable and a socket at the same time.
This basically means your options for blocking on something are:
- Block on a condition variable and have it woken up by another thread (which means we have to spin up another thread to do background processing, and that thread makes the poll() call)
- Block on some set of sockets (as described above)
So there will always be more resources consumed — the choice is between creating a socketpair/eventfd and creating a thread.
from openssl.
Sorry, Ii wasn't being clear, all I meant to suggest was that you could implement what you needed without creating an additional thread - i.e. a "someone is waiting" heuristic. something like the following pseudo code:
lock_mutex
if another_thread_is_blocking_on_the_socket
wait_on_condition_variable
set another_thread_is_blocking_on_the_socket = true
unlock_mutex
block_on_socket_ready
read_socket_data
lock_mutex
set_another_thread_is_blocking_on_the_socket = false
signal_condition_variable
unlock_mutex
return socket data
Thats pretty simplistic of course, and it doesn't account for cases in which the socket data has to be from a given stream in the quic connection, but you could setup a per stream signal variable, so that whatever thread gets into your critical section only wakes the correct thread (which may be itself, in which case you should signal all waiting threads, so another one can take over the blocking operation. The resource fanout is still linear of course if you do a per stream condition variable, but it might be less egregious than having to pump data through various socket pairs, or spawn a new entire thread.
from openssl.
Related Issues (20)
- Missing image on https://mta.openssl.org/mailman/listinfo/openssl-announce (low priority)
- There is a memory leak vulnerability at line 178 in the /openssl/crypto/x509/x_ietfatt.c file.
- There is a memory leak vulnerability at line 250 in the /openssl/crypto/pkcs12/p12_crt.c file.
- Provision to add complete record processing in OpenSSL HOT 3
- devcrypto.so file creation for openssl1.1.1f
- Is the way how you handle $CROSS_COMPILE and $CC really correct? HOT 2
- 3.3.0 build problem on VMS IA64 -- Defect in <stdlib.h> HOT 4
- There is a memory leak defect in line 112 of the /openssl/test/cmp_hdr_test.c file.
- There is a memory leak defect at line 83 in the file /openssl/test/cmp_hdr_test.c.
- There is a memory leak defect at line 141 in the file /openssl/test/cmp_hdr_test.c.
- There is a memory leak defect at line 304 in the file /openssl/test/cmp_hdr_test.c. HOT 2
- There is a memory leak defect at line 82 in the file /openssl/test/ecstresstest.c.
- Additional smaller build targets HOT 3
- OpenSC + Smartcard-HSM + secp521r1 + OpenSSH = signing failed for ECDSA "secp521r1": error in libcrypto HOT 1
- Segfault and data race between OPENSSL_sk_{num, insert, value} in X509 store/lookup HOT 3
- ML-KEM in TLS HOT 5
- Changing Modules directory
- Update SmtpUTF8Mailbox support to RFC 9598
- Not getting Expected output for tls13-kdf EXTRACT-ONLY testcase
- Improve BIO_s_accept api call documentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openssl.