It is a big problem for us, and I can only imagine for anyone using MySQL, when a mysql client hangs on an established connection to the mysql server because the network to the server is disrupted (such as someone pulling power to a network hub or many other scenarios). We have changed the source code to fix this, but I'd sure like to hear comments from people that know MySQL.
The mysql client can respond with an error if the server dies or is shutdown because the network will cleanup the broken connection. The mysql client can also respond with an error if the server is not available for a connection. But if the connection is already established and the network connection is disrupted, the client simply hangs. Someone please tell me if I am wrong, or if I am doing something wrong. Perhaps there is a feature or option I am overlooking (the option to set a timeout when connecting does not affect existing connections). Perhaps my change here could be incorporated into the source code control if someone will guide me. What we have done to get around this problem is to use poll with a timeout before blindly hanging on a read. I had to alter the vio_read method in the violite.c file: int vio_read(Vio * vio, gptr buf, int size) { ...orig code still here.... // don't read before checking with // new function new_poll_read // to avoid read hangs! if (new_poll_read(vio, 1)) { r = read(vio->sd, buf, size); } else { r = -1; } } // New method that uses poll my_bool new_poll_read(Vio *vio,uint timeout) { struct pollfd fds; int res = 0 ; bool is_blocking=vio_is_blocking(vio); DBUG_ENTER("new_poll_read"); fds.fd=vio->sd; fds.events=POLLIN; fds.revents=0; if(is_blocking) { timeout *= 1000; } else { timeout = 0; } res = poll(&fds,1,(int) timeout); return res > 0 && fds.revents & POLLIN ; if(0) { ; } else if( res <= 0) // error or timeout { return res; } else if(res > 0) // ready { if(!(fds.revents & POLLIN)) { return fds.revents & POLLIN; } } else // impossible { assert(0) ; } } -- -=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=- Lance Welsh [EMAIL PROTECTED] Seascape Communications (650) 327-6890 -=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=- --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php