-
-
Save wankdanker/bf86d55118d05ae181b0 to your computer and use it in GitHub Desktop.
node-odbc test case - pthread_mutex_lock.c:62: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Pool = require('../').Pool; | |
var pool = new Pool(); | |
var Database = require('../').Database; | |
var connectionString = 'Put a connection string to your database here'; | |
var connections = []; | |
var connectCount = 500; | |
openConnectionsUsingPool(connections); | |
function openConnectionsUsingPool(connections) { | |
for (var x = 0; x <= connectCount; x++) { | |
(function (connectionIndex) { | |
console.log("Opening connection #", connectionIndex); | |
pool.open(connectionString, function (err, connection) { | |
console.log("Opened connection #", connectionIndex); | |
if (err) { | |
console.log("error: ", err.message); | |
return false; | |
} | |
connections.push(connection); | |
if (connectionIndex == connectCount) { | |
closeConnections(connections); | |
} | |
}); | |
})(x); | |
} | |
} | |
function openConnectionsUsingDB(connections) { | |
for (var x = 0; x <= connectCount; x++) { | |
(function (connectionIndex) { | |
console.log("Opening connection #", connectionIndex); | |
var db = new Database(); | |
db.open(connectionString, function (err, connection) { | |
console.log("Opened connection #", connectionIndex); | |
if (err) { | |
console.log("error: ", err.message); | |
return false; | |
} | |
connections.push(db); | |
//connections.push(connection); | |
if (connectionIndex == connectCount) { | |
closeConnections(connections); | |
} | |
}); | |
})(x); | |
} | |
} | |
function closeConnections (connections) { | |
connections.forEach(function (connection, idx) { | |
console.log("Closing connection #", idx); | |
connection.close(function () { | |
console.log("Closed connection #", idx); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment