From: "Florian G. Pflug" Date: 2003-05-18T11:55:51+09:00 Subject: C Extensions blocking all ruby threads Hi I noticed that there a quite a few ruby c-extensions that use blocking read, write and select calls without properly wrapping them with some rb_thread_select loop. This is annoying, because I leads to all ruby threads being blocked until the read, write or select finishes. I first noticed that when using the postgres module. This module actually provides non-blocking functions too (using the non-blocking api postgres provides). But e.g. the mysql module for ruby seems not to provide any non-blocking methods for querying. Of course this is especially bad for database interfaces, since queries potentially take a very long time. Of course one solutions would be to fix those extensions (if it's possible - I don't know if there is a non-blocking api to mysql). But I though, that maybe ruby could replace the read() and write() functions of the libc with something that respects other ruby threads (by using a rb_thread_select loop) before loading c-extensions. If this is possible (I don't see why it shouldn't be, but I tend to oversee subtle problems sometimes... ;-) ), it would solve the blocking problem once and for all. Or, if there might by some problems in special cases, the function replacement could only be done when the extension is loaded via require_fixup() instead of require(), or something like that. If this hasn't already been done, or someone has arguments why this cannot work, I might try it out if I find some spare time... greetings, Florian Pflug