Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
11abfba6
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看板
提交
11abfba6
编写于
9月 03, 2019
作者:
A
andrew
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8139965: Hang seen when using com.sun.jndi.ldap.search.replyQueueSize
Reviewed-by: dfuchs
上级
4485f040
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
100 deletion
+67
-100
src/share/classes/com/sun/jndi/ldap/BerDecoder.java
src/share/classes/com/sun/jndi/ldap/BerDecoder.java
+8
-4
src/share/classes/com/sun/jndi/ldap/Connection.java
src/share/classes/com/sun/jndi/ldap/Connection.java
+14
-53
src/share/classes/com/sun/jndi/ldap/LdapRequest.java
src/share/classes/com/sun/jndi/ldap/LdapRequest.java
+45
-43
未找到文件。
src/share/classes/com/sun/jndi/ldap/BerDecoder.java
浏览文件 @
11abfba6
...
...
@@ -186,12 +186,16 @@ public final class BerDecoder extends Ber {
*</pre></blockquote>
*/
private
int
parseIntWithTag
(
int
tag
)
throws
DecodeException
{
if
(
parseByte
()
!=
tag
)
{
// Ber could have been reset;
String
s
;
if
(
offset
>
0
)
{
s
=
Integer
.
toString
(
buf
[
offset
-
1
]
&
0xff
);
}
else
{
s
=
"Empty tag"
;
}
throw
new
DecodeException
(
"Encountered ASN.1 tag "
+
Integer
.
toString
(
buf
[
offset
-
1
]
&
0xff
)
+
" (expected tag "
+
Integer
.
toString
(
tag
)
+
")"
);
s
+
" (expected tag "
+
Integer
.
toString
(
tag
)
+
")"
);
}
int
len
=
parseLength
();
...
...
src/share/classes/com/sun/jndi/ldap/Connection.java
浏览文件 @
11abfba6
...
...
@@ -453,65 +453,29 @@ public final class Connection implements Runnable {
/**
* Reads a reply; waits until one is ready.
*/
BerDecoder
readReply
(
LdapRequest
ldr
)
throws
IOException
,
NamingException
{
BerDecoder
readReply
(
LdapRequest
ldr
)
throws
IOException
,
NamingException
{
BerDecoder
rber
;
// Track down elapsed time to workaround spurious wakeups
long
elapsedMilli
=
0
;
long
elapsedNano
=
0
;
while
(((
rber
=
ldr
.
getReplyBer
())
==
null
)
&&
(
readTimeout
<=
0
||
elapsedMilli
<
readTimeout
))
{
try
{
// If socket closed, don't even try
synchronized
(
this
)
{
if
(
sock
==
null
)
{
throw
new
ServiceUnavailableException
(
host
+
":"
+
port
+
"; socket closed"
);
}
}
synchronized
(
ldr
)
{
// check if condition has changed since our last check
rber
=
ldr
.
getReplyBer
();
if
(
rber
==
null
)
{
if
(
readTimeout
>
0
)
{
// Socket read timeout is specified
long
beginNano
=
System
.
nanoTime
();
// will be woken up before readTimeout if reply is
// available
ldr
.
wait
(
readTimeout
-
elapsedMilli
);
elapsedNano
+=
(
System
.
nanoTime
()
-
beginNano
);
elapsedMilli
+=
elapsedNano
/
1000_000
;
elapsedNano
%=
1000_000
;
}
else
{
// no timeout is set so we wait infinitely until
// a response is received
// https://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-ldap.html#PROP
ldr
.
wait
();
}
}
else
{
break
;
}
}
}
catch
(
InterruptedException
ex
)
{
throw
new
InterruptedNamingException
(
"Interrupted during LDAP operation"
);
}
try
{
// if no timeout is set so we wait infinitely until
// a response is received
// http://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-ldap.html#PROP
rber
=
ldr
.
getReplyBer
(
readTimeout
);
}
catch
(
InterruptedException
ex
)
{
throw
new
InterruptedNamingException
(
"Interrupted during LDAP operation"
);
}
if
(
(
rber
==
null
)
&&
(
elapsedMilli
>=
readTimeout
)
)
{
if
(
rber
==
null
)
{
abandonRequest
(
ldr
,
null
);
throw
new
NamingException
(
"LDAP response read timed out, timeout used:"
throw
new
NamingException
(
"LDAP response read timed out, timeout used:"
+
readTimeout
+
"ms."
);
}
return
rber
;
}
////////////////////////////////////////////////////////////////////////////
//
// Methods to add, find, delete, and abandon requests made to server
...
...
@@ -705,14 +669,11 @@ public final class Connection implements Runnable {
if
(
nparent
)
{
LdapRequest
ldr
=
pendingRequests
;
while
(
ldr
!=
null
)
{
synchronized
(
ldr
)
{
ldr
.
notify
();
ldr
.
close
();
ldr
=
ldr
.
next
;
}
}
}
}
if
(
nparent
)
{
parent
.
processConnectionClosure
();
}
...
...
@@ -800,7 +761,7 @@ public final class Connection implements Runnable {
* the safest thing to do is to shut it down.
*/
private
Object
pauseLock
=
new
Object
();
// lock for reader to wait on while paused
private
final
Object
pauseLock
=
new
Object
();
// lock for reader to wait on while paused
private
boolean
paused
=
false
;
// paused state of reader
/*
...
...
src/share/classes/com/sun/jndi/ldap/LdapRequest.java
浏览文件 @
11abfba6
...
...
@@ -29,55 +29,52 @@ import java.io.IOException;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
import
javax.naming.CommunicationException
;
import
java.util.concurrent.TimeUnit
;
final
class
LdapRequest
{
LdapRequest
next
;
// Set/read in synchronized Connection methods
int
msgId
;
// read-only
private
final
static
BerDecoder
EOF
=
new
BerDecoder
(
new
byte
[]{},
-
1
,
0
);
private
int
gotten
=
0
;
private
BlockingQueue
<
BerDecoder
>
replies
;
private
int
highWatermark
=
-
1
;
private
boolean
cancelled
=
false
;
private
boolean
pauseAfterReceipt
=
false
;
private
boolean
completed
=
false
;
LdapRequest
next
;
// Set/read in synchronized Connection methods
final
int
msgId
;
// read-only
LdapRequest
(
int
msgId
,
boolean
pause
)
{
this
(
msgId
,
pause
,
-
1
);
}
private
final
BlockingQueue
<
BerDecoder
>
replies
;
private
volatile
boolean
cancelled
;
private
volatile
boolean
closed
;
private
volatile
boolean
completed
;
private
final
boolean
pauseAfterReceipt
;
LdapRequest
(
int
msgId
,
boolean
pause
,
int
replyQueueCapacity
)
{
this
.
msgId
=
msgId
;
this
.
pauseAfterReceipt
=
pause
;
if
(
replyQueueCapacity
==
-
1
)
{
this
.
replies
=
new
LinkedBlockingQueue
<
BerDecoder
>();
this
.
replies
=
new
LinkedBlockingQueue
<>();
}
else
{
this
.
replies
=
new
LinkedBlockingQueue
<
BerDecoder
>(
replyQueueCapacity
);
highWatermark
=
(
replyQueueCapacity
*
80
)
/
100
;
// 80% capacity
this
.
replies
=
new
LinkedBlockingQueue
<>(
8
*
replyQueueCapacity
/
10
);
}
}
synchronized
void
cancel
()
{
void
cancel
()
{
cancelled
=
true
;
replies
.
offer
(
EOF
);
}
// Unblock reader of pending request
// Should only ever have atmost one waiter
notify
();
synchronized
void
close
()
{
closed
=
true
;
replies
.
offer
(
EOF
);
}
private
boolean
isClosed
()
{
return
closed
&&
(
replies
.
size
()
==
0
||
replies
.
peek
()
==
EOF
);
}
synchronized
boolean
addReplyBer
(
BerDecoder
ber
)
{
if
(
cancelled
)
{
// check the closed boolean value here as we don't want anything
// to be added to the queue after close() has been called.
if
(
cancelled
||
closed
)
{
return
false
;
}
// Add a new reply to the queue of unprocessed replies.
try
{
replies
.
put
(
ber
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
// peek at the BER buffer to check if it is a SearchResultDone PDU
try
{
ber
.
parseSeq
(
null
);
...
...
@@ -88,33 +85,38 @@ final class LdapRequest {
}
ber
.
reset
();
notify
();
// notify anyone waiting for reply
/*
* If a queue capacity has been set then trigger a pause when the
* queue has filled to 80% capacity. Later, when the queue has drained
* then the reader gets unpaused.
*/
if
(
highWatermark
!=
-
1
&&
replies
.
size
()
>=
highWatermark
)
{
return
true
;
// trigger the pause
// Add a new reply to the queue of unprocessed replies.
try
{
replies
.
put
(
ber
);
}
catch
(
InterruptedException
e
)
{
// ignore
}
return
pauseAfterReceipt
;
}
synchronized
BerDecoder
getReplyBer
()
throws
CommunicationException
{
BerDecoder
getReplyBer
(
long
millis
)
throws
CommunicationException
,
InterruptedException
{
if
(
cancelled
)
{
throw
new
CommunicationException
(
"Request: "
+
msgId
+
" cancelled"
);
}
if
(
isClosed
())
{
return
null
;
}
BerDecoder
result
=
millis
>
0
?
replies
.
poll
(
millis
,
TimeUnit
.
MILLISECONDS
)
:
replies
.
take
();
if
(
cancelled
)
{
throw
new
CommunicationException
(
"Request: "
+
msgId
+
" cancelled"
);
}
/*
* Remove a reply if the queue is not empty.
* poll returns null if queue is empty.
*/
BerDecoder
reply
=
replies
.
poll
();
return
reply
;
return
result
==
EOF
?
null
:
result
;
}
synchronized
boolean
hasSearchCompleted
()
{
boolean
hasSearchCompleted
()
{
return
completed
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录