mysql icon indicating copy to clipboard operation
mysql copied to clipboard

Make ffi calls interruptible

Open k-bx opened this issue 7 years ago • 6 comments

GHC 7.8 brought interruptible FFI. This might be very useful sometimes, especially upon hanging request through FFI. Some more context on a reddit thread.

What do you think? Would that be a good thing to have? Should mysql support GHC >=7.8 or would adding such thing require doing ifdefs to support older GHCs as well? Thanks.

k-bx avatar Mar 23 '17 13:03 k-bx

If I understand it correctly custom SIGPIPE handler is needed - https://dev.mysql.com/doc/refman/5.7/en/c-api-threaded-clients.html

qrilka avatar Mar 23 '17 13:03 qrilka

Don't safe FFI calls also allow interruption? I'm pretty sure that's already happening here.

3noch avatar Mar 23 '17 14:03 3noch

@3noch Austin Seipp talks about it explicitly in the post linked above

qrilka avatar Mar 23 '17 14:03 qrilka

@qrilka I see. Right now I think the C code is just blocking RTS signals: https://github.com/paul-rouse/mysql/blob/master/cbits/mysql_signals.c#L28-L32

3noch avatar Mar 23 '17 14:03 3noch

@3noch but only SIGALRM and SIGVTALRM are blocked. MySQL docs say:

To use your own SIGPIPE handler, first call mysql_library_init(),
then install your handler.

I have tried unblocking SIGPIPE before doing a test query but the signal doesn't get through.

@paul-rouse could we know your opinion on this issue?

qrilka avatar Mar 29 '17 13:03 qrilka

Sorry, I'm not ignoring this, but I have a work deadline - I'll give it proper thought soon!

paul-rouse avatar Mar 30 '17 17:03 paul-rouse