I spent some time this morning trying to use HDBC-mysql to talk to a database. It uses the C mysql bindings, which talks over a blocking socket to the database server. Not surprisingly, it fails reliably when the thread it's running in is hit by an RTS-initiated alarm signal.
I've managed to make the code *appear* to work successfully with some hacking:
- Run in a bound thread
- Use pthread_sigmask to temporarily block SIGALRM and SIGVTALRM to *only* this thread while issuing the sensitive native calls
- Profit?
What I am wondering is if there's a practical downside to doing this. Am I going to accidentally kill something? This is a very important gap in the usability of GHC with native libraries, and if this approach actually turns out to be safe in practice, that would be wonderful.