Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
60aa28a7
提交
60aa28a7
authored
6 年前
作者:
Andrei Tokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #1672, switch MVStore.state back to volatile from Atomic
上级
734f8029
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
27 行删除
+18
-27
MVStore.java
h2/src/main/org/h2/mvstore/MVStore.java
+18
-27
没有找到文件。
h2/src/main/org/h2/mvstore/MVStore.java
浏览文件 @
60aa28a7
...
...
@@ -185,7 +185,7 @@ public class MVStore implements AutoCloseable {
private
volatile
boolean
reuseSpace
=
true
;
private
final
AtomicInteger
state
=
new
AtomicInteger
()
;
private
volatile
int
state
;
private
final
FileStore
fileStore
;
...
...
@@ -960,10 +960,11 @@ public class MVStore implements AutoCloseable {
// isClosed() would wait until closure is done and then we jump out of the loop.
// This is a subtle difference between !isClosed() and isOpen().
while
(!
isClosed
())
{
if
(
state
.
compareAndSet
(
STATE_OPEN
,
STATE_STOPPING
))
{
try
{
stopBackgroundThread
(
normalShutdown
);
storeLock
.
lock
();
stopBackgroundThread
(
normalShutdown
);
storeLock
.
lock
();
try
{
if
(
state
==
STATE_OPEN
)
{
state
=
STATE_STOPPING
;
try
{
try
{
if
(
normalShutdown
&&
fileStore
!=
null
&&
!
fileStore
.
isReadOnly
())
{
...
...
@@ -979,7 +980,7 @@ public class MVStore implements AutoCloseable {
shrinkFileIfPossible
(
0
);
}
state
.
set
(
STATE_CLOSING
)
;
state
=
STATE_CLOSING
;
// release memory early - this is important when called
// because of out of memory
...
...
@@ -1000,11 +1001,11 @@ public class MVStore implements AutoCloseable {
}
}
}
finally
{
st
oreLock
.
unlock
()
;
st
ate
=
STATE_CLOSED
;
}
}
finally
{
state
.
set
(
STATE_CLOSED
);
}
}
finally
{
storeLock
.
unlock
();
}
}
}
...
...
@@ -2806,7 +2807,7 @@ public class MVStore implements AutoCloseable {
}
private
boolean
isOpen
()
{
return
state
.
get
()
==
STATE_OPEN
;
return
state
==
STATE_OPEN
;
}
/**
...
...
@@ -2817,27 +2818,17 @@ public class MVStore implements AutoCloseable {
if
(
isOpen
())
{
return
false
;
}
int
millis
=
1
;
while
(
state
.
get
()
!=
STATE_CLOSED
)
{
/*
* We need to wait for completion of close procedure. This is
* required because otherwise database may be closed too early while
* underlying storage still has unreleased resources. The quickly
* following connection attempts fail with The file is locked
* exception.
*/
try
{
Thread
.
sleep
(
millis
++);
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
break
;
}
storeLock
.
lock
();
try
{
assert
state
==
STATE_CLOSED
;
return
true
;
}
finally
{
storeLock
.
unlock
();
}
return
true
;
}
private
boolean
isOpenOrStopping
()
{
return
state
.
get
()
<=
STATE_STOPPING
;
return
state
<=
STATE_STOPPING
;
}
private
void
stopBackgroundThread
(
boolean
waitForIt
)
{
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论