Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
90cfeed8
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
90cfeed8
编写于
2月 26, 2018
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8197518: Kerberos krb5 authentication: AuthList's put method leads to performance issue
Reviewed-by: coffeys, xuelei
上级
b854cb26
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
37 deletion
+33
-37
src/share/classes/sun/security/krb5/internal/rcache/AuthList.java
...e/classes/sun/security/krb5/internal/rcache/AuthList.java
+25
-18
src/share/classes/sun/security/krb5/internal/rcache/MemoryCache.java
...lasses/sun/security/krb5/internal/rcache/MemoryCache.java
+8
-19
未找到文件。
src/share/classes/sun/security/krb5/internal/rcache/AuthList.java
浏览文件 @
90cfeed8
/*
* Copyright (c) 2000, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
8
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -55,6 +55,9 @@ public class AuthList {
private
final
LinkedList
<
AuthTimeWithHash
>
entries
;
private
final
int
lifespan
;
// entries.getLast().ctime, updated after each cleanup.
private
volatile
int
oldestTime
=
Integer
.
MIN_VALUE
;
/**
* Constructs a AuthList.
*/
...
...
@@ -67,11 +70,13 @@ public class AuthList {
* Puts the authenticator timestamp into the cache in descending order,
* and throw an exception if it's already there.
*/
public
void
put
(
AuthTimeWithHash
t
,
KerberosTime
currentTime
)
public
synchronized
void
put
(
AuthTimeWithHash
t
,
KerberosTime
currentTime
)
throws
KrbApErrException
{
if
(
entries
.
isEmpty
())
{
entries
.
addFirst
(
t
);
oldestTime
=
t
.
ctime
;
return
;
}
else
{
AuthTimeWithHash
temp
=
entries
.
getFirst
();
int
cmp
=
temp
.
compareTo
(
t
);
...
...
@@ -106,24 +111,26 @@ public class AuthList {
// let us cleanup while we are here
long
timeLimit
=
currentTime
.
getSeconds
()
-
lifespan
;
ListIterator
<
AuthTimeWithHash
>
it
=
entries
.
listIterator
(
0
);
AuthTimeWithHash
temp
=
null
;
int
index
=
-
1
;
while
(
it
.
hasNext
())
{
// search expired timestamps.
temp
=
it
.
next
();
if
(
temp
.
ctime
<
timeLimit
)
{
index
=
entries
.
indexOf
(
temp
);
break
;
}
// Only trigger a cleanup when the earliest entry is
// lifespan + 5 sec ago. This ensures a cleanup is done
// at most every 5 seconds so that we don't always
// addLast(removeLast).
if
(
oldestTime
>
timeLimit
-
5
)
{
return
;
}
// It would be nice if LinkedList has a method called truncate(index).
if
(
index
>
-
1
)
{
do
{
// remove expired timestamps from the list.
entries
.
removeLast
();
}
while
(
entries
.
size
()
>
index
);
// and we remove the *enough* old ones (1 lifetime ago)
while
(!
entries
.
isEmpty
())
{
AuthTimeWithHash
removed
=
entries
.
removeLast
();
if
(
removed
.
ctime
>=
timeLimit
)
{
entries
.
addLast
(
removed
);
oldestTime
=
removed
.
ctime
;
return
;
}
}
oldestTime
=
Integer
.
MIN_VALUE
;
}
public
boolean
isEmpty
()
{
...
...
src/share/classes/sun/security/krb5/internal/rcache/MemoryCache.java
浏览文件 @
90cfeed8
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2018,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -31,7 +31,9 @@
package
sun.security.krb5.internal.rcache
;
import
java.util.*
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
sun.security.krb5.internal.KerberosTime
;
import
sun.security.krb5.internal.KrbApErrException
;
import
sun.security.krb5.internal.ReplayCache
;
...
...
@@ -48,31 +50,18 @@ public class MemoryCache extends ReplayCache {
private
static
final
int
lifespan
=
KerberosTime
.
getDefaultSkew
();
private
static
final
boolean
DEBUG
=
sun
.
security
.
krb5
.
internal
.
Krb5
.
DEBUG
;
private
final
Map
<
String
,
AuthList
>
content
=
new
HashMap
<>();
private
final
Map
<
String
,
AuthList
>
content
=
new
Concurrent
HashMap
<>();
@Override
public
synchronized
void
checkAndStore
(
KerberosTime
currTime
,
AuthTimeWithHash
time
)
throws
KrbApErrException
{
String
key
=
time
.
client
+
"|"
+
time
.
server
;
AuthList
rc
=
content
.
get
(
key
);
content
.
computeIfAbsent
(
key
,
k
->
new
AuthList
(
lifespan
))
.
put
(
time
,
currTime
);
if
(
DEBUG
)
{
System
.
out
.
println
(
"MemoryCache: add "
+
time
+
" to "
+
key
);
}
if
(
rc
==
null
)
{
rc
=
new
AuthList
(
lifespan
);
rc
.
put
(
time
,
currTime
);
if
(!
rc
.
isEmpty
())
{
content
.
put
(
key
,
rc
);
}
}
else
{
if
(
DEBUG
)
{
System
.
out
.
println
(
"MemoryCache: Existing AuthList:\n"
+
rc
);
}
rc
.
put
(
time
,
currTime
);
if
(
rc
.
isEmpty
())
{
content
.
remove
(
key
);
}
}
// TODO: clean up AuthList entries with only expired AuthTimeWithHash objects.
}
public
String
toString
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录