Fixing timeout routine for MySQL