dart-drivers / mysql

MySQL Connector for Dart
Other
99 stars 38 forks source link

Bug in ConnectionPool._closeQuery #49

Closed dglinyanov closed 9 years ago

dglinyanov commented 10 years ago

This code assumes it will get same connection in future callback (cnx), that it sent into _waitUntilReady:

_waitUntilReady(cnx).then((_) {
    _log.finest("Connection ready - closing query: ${q.sql}");
    var handler = new _CloseStatementHandler(preparedQuery.statementHandlerId);
    cnx.autoRelease = !retain;
    cnx.processHandler(handler, noResponse: true);
  });

but it gets another object (_), that has different data. In my case cnx._handler is not empty, so processHandler throws exception. But after _finishAndReuse (before future callback) _._handler becomes null and the state of _ is more likely ready for closing prepared query. So I would use _ in callback rather cnx. I can send a pull request if I am right and there must _ instead of cnx.