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

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

上级 09769f17
...@@ -25,6 +25,7 @@ Change Log ...@@ -25,6 +25,7 @@ Change Log
</li><li>Support TRUNC(timestamp) for improved Oracle compatiblity. </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 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>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> </li></ul>
<h2>Version 1.3.171 (2013-03-17)</h2> <h2>Version 1.3.171 (2013-03-17)</h2>
......
...@@ -71,20 +71,15 @@ public class TableLinkConnection { ...@@ -71,20 +71,15 @@ public class TableLinkConnection {
return t; return t;
} }
synchronized (map) { synchronized (map) {
TableLinkConnection result; TableLinkConnection result = map.get(t);
result = map.get(t);
if (result == null) { if (result == null) {
synchronized (t) {
t.open(); t.open();
}
// put the connection in the map after is has been opened, // 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); map.put(t, t);
result = t; result = t;
} }
synchronized (result) {
result.useCounter++; result.useCounter++;
}
return result; return result;
} }
} }
...@@ -132,13 +127,17 @@ public class TableLinkConnection { ...@@ -132,13 +127,17 @@ public class TableLinkConnection {
* @param force if the connection needs to be closed even if it is still * @param force if the connection needs to be closed even if it is still
* used elsewhere (for example, because the connection is broken) * used elsewhere (for example, because the connection is broken)
*/ */
synchronized void close(boolean force) { void close(boolean force) {
if (--useCounter <= 0 || force) { boolean actuallyClose = false;
JdbcUtils.closeSilently(conn);
synchronized (map) { synchronized (map) {
if (--useCounter <= 0 || force) {
actuallyClose = true;
map.remove(this); map.remove(this);
} }
} }
if (actuallyClose) {
JdbcUtils.closeSilently(conn);
}
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论