Hung thread in SmbTree.java

Rich Hammond <[email protected]> Wed, 18 Feb 2015 19:52:15 +0000
Newsgroups gmane.network.samba.java
Message-ID <D10A579E.1B2FF%[email protected]>
--_000_D10A579E1B2FFrichhammondvmturbocom_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I tried to search the archives and I do not see this issue.  If there is an=
other place I should search, please let me know.
I have a thread that has been hung for days at:

   java.lang.Thread.State: WAITING (on object monitor)

    at java.lang.Object.wait(Native Method)

    - waiting on <0x000000074edf9e60> (a jcifs.smb.SmbTransport)

    at java.lang.Object.wait(Object.java:503)

    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:143)

    - locked <0x000000074edf9e60> (a jcifs.smb.SmbTransport)

    at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)

    at jcifs.smb.SmbFile.connect(SmbFile.java:954)

    at jcifs.smb.SmbFile.connect0(SmbFile.java:880)

    at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:76)

    at jcifs.smb.SmbFileInputStream.<init>(SmbFileInputStream.java:65)

    at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)

    at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:91)

    at rpc.Stub.attach(Stub.java:106)

    at rpc.Stub.call(Stub.java:110)

    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.ja=
va:132)

    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:509)

    at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:414)

Looking at the sources for SmbTree I have a couple questions:

  1.  In the treeConnect method why does the catch bother to call treeDisco=
nnect?  The connectionState =3D 1 and treeDisconnect returns immediately in=
 that case, so why bother calling at all?
  2.  Should not the rule be that anyplace that one sets connectionState =
=3D 0; you also call session.transport.notifyAll()?  Why doesn't the catch =
block have a notifyAll()?
  3.  Alternatively, treeDisconnect() could be:    void treeDisconnect( boo=
lean inError ) {

synchronized (session.transport()) {

        if (connectionState =3D=3D 2) {
            connectionState =3D 3; // disconnecting

            if (!inError && tid !=3D 0) {
                try {
                    send( new SmbComTreeDisconnect(), null );
                } catch( SmbException se ) {
                    if (session.transport.log.level > 1) {
                        se.printStackTrace( session.transport.log );
                    }
                }
            }

        }
        inDfs =3D false;
        inDomainDfs =3D false;

        connectionState =3D 0;

        session.transport.notifyAll();
}
    }


This message and its attachments are intended only for the designated recip=
ient(s). It may contain confidential or proprietary information and may be =
subject to legal or other confidentiality protections. If you are not a des=
ignated recipient, you may not review, copy or distribute this message. If =
you receive this in error, please notify the sender by reply e-mail and del=
ete this message. Thank you.

--_000_D10A579E1B2FFrichhammondvmturbocom_
Content-Type: text/html; charset="iso-8859-1"
Content-ID: <[email protected]>
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
</head>
<body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-lin=
e-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-fami=
ly: Calibri, sans-serif;">
<div>I tried to search the archives and I do not see this issue. &nbsp;If t=
here is another place I should search, please let me know.</div>
<div>I have a thread that has been hung for days at:</div>
<div>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
;java.lang.Thread.State: WAITING (on object monitor)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at java.lang.Object.wait(Native Method)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; - waiting on &lt;0x000000074edf9e60&gt; (a jcifs.smb.SmbTransport)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at java.lang.Object.wait(Object.java:503)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at jcifs.smb.SmbTree.treeConnect(SmbTree.java:143)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; - locked &lt;0x000000074edf9e60&gt; (a jcifs.smb.SmbTransport)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at jcifs.smb.SmbFile.doConnect(SmbFile.java:911)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at jcifs.smb.SmbFile.connect(SmbFile.java:954)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at jcifs.smb.SmbFile.connect0(SmbFile.java:880)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at jcifs.smb.SmbFileInputStream.&lt;init&gt;(SmbFileInputStream.java:76)<=
/p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at jcifs.smb.SmbFileInputStream.&lt;init&gt;(SmbFileInputStream.java:65)<=
/p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at jcifs.smb.SmbFile.getInputStream(SmbFile.java:2844)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at rpc.ncacn_np.RpcTransport.attach(RpcTransport.java:91)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at rpc.Stub.attach(Stub.java:106)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at rpc.Stub.call(Stub.java:110)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKCR(JIWinRegStub.java=
:132)</p>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:509)</p=
>
<p style=3D"margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp=
; at org.jinterop.dcom.core.JIComServer.&lt;init&gt;(JIComServer.java:414)<=
/p>
</div>
<div><br>
</div>
<div>Looking at the sources for SmbTree I have a couple questions:</div>
<ol>
<li>In the treeConnect method why does the catch bother to call treeDisconn=
ect? &nbsp;The connectionState =3D 1 and treeDisconnect returns immediately=
 in that case, so why bother calling at all?</li><li>Should not the rule be=
 that anyplace that one sets connectionState =3D 0; you also call session.t=
ransport.notifyAll()? &nbsp;Why doesn&#8217;t the catch block have a notify=
All()?</li><li>Alternatively, treeDisconnect() could be: &nbsp; &nbsp;void =
treeDisconnect( boolean inError ) {
<pre>synchronized (session.transport()) {

        if (connectionState =3D=3D 2) {
            connectionState =3D 3; // disconnecting

            if (!inError &amp;&amp; tid !=3D 0) {
                try {
                    send( new SmbComTreeDisconnect(), null );
                } catch( SmbException se ) {
                    if (session.transport.log.level &gt; 1) {
                        se.printStackTrace( session.transport.log );
                    }
                }
            }</pre>
<pre>        }
        inDfs =3D false;
        inDomainDfs =3D false;

        connectionState =3D 0;

        session.transport.notifyAll();
}
    }
</pre>
</li></ol>
This message and its attachments are intended only for the designated recip=
ient(s). It may contain confidential or proprietary information and may be =
subject to legal or other confidentiality protections. If you are not a des=
ignated recipient, you may not review,
 copy or distribute this message. If you receive this in error, please noti=
fy the sender by reply e-mail and delete this message. Thank you.
</body>
</html>

--_000_D10A579E1B2FFrichhammondvmturbocom_--