release connection when query done in mysql socket

This commit is contained in:
lichengyin 2015-10-22 14:55:46 +08:00
parent 4dce495bb4
commit f2adb80149

View File

@ -107,6 +107,11 @@ export default class extends think.adapter.socket {
let startTime = Date.now();
let fn = think.promisify(connection.query, connection);
let promise = fn(data).then((rows = []) => {
// just call connection.release() and the connection will return to the pool,
// ready to be used again by someone else.
// https://github.com/felixge/node-mysql#pooling-connections
connection.release();
if (this.config.log_sql) {
think.log(sql, 'SQL', startTime);
}