提交 477322e8 authored 作者: noelgrandin's avatar noelgrandin

Fix issue #453, ABBA race conditions in TABLE LINK connection sharing.

上级 09769f17
......@@ -25,6 +25,7 @@ Change Log
</li><li>Support TRUNC(timestamp) for improved Oracle compatiblity.
</li><li>Add support for CREATE TABLE TEST (ID BIGSERIAL) for PostgreSQL compatibility. Patch from Jesse Long.
</li><li>Add new collation command SET BINARY_COLLATION UNSIGNED, helps with people testing BINARY columns in MySQL mode.
</li><li>Fix issue #453, ABBA race conditions in TABLE LINK connection sharing.
</li></ul>
<h2>Version 1.3.171 (2013-03-17)</h2>
......
......@@ -71,20 +71,15 @@ public class TableLinkConnection {
return t;
}
synchronized (map) {
TableLinkConnection result;
result = map.get(t);
TableLinkConnection result = map.get(t);
if (result == null) {
synchronized (t) {
t.open();
}
t.open();
// put the connection in the map after is has been opened,
// so we know it works
// when we know it works
map.put(t, t);
result = t;
}
synchronized (result) {
result.useCounter++;
}
result.useCounter++;
return result;
}
}
......@@ -132,13 +127,17 @@ public class TableLinkConnection {
* @param force if the connection needs to be closed even if it is still
* used elsewhere (for example, because the connection is broken)
*/
synchronized void close(boolean force) {
if (--useCounter <= 0 || force) {
JdbcUtils.closeSilently(conn);
synchronized (map) {
void close(boolean force) {
boolean actuallyClose = false;
synchronized (map) {
if (--useCounter <= 0 || force) {
actuallyClose = true;
map.remove(this);
}
}
if (actuallyClose) {
JdbcUtils.closeSilently(conn);
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论