Re: Resyncing? Out of Phase

Michael B Allen <[email protected]>
Newsgroups gmane.network.samba.java
Message-ID <CAGMFw4hYJXyg63BBFniRZoRcQ9-G0G+RixbcD8nnguWjG2iZxg@mail.gmail.com>
On Wed, Aug 10, 2011 at 4:21 PM, Sebastian Sickelmann
<[email protected]> wrote:
> Hi,
>
> In SMBTransport there is the following code fragment
>                                        /* out of phase maybe? */
>                          /* inch forward 1 byte and try again */
>            for (int i = 0; i < 35; i++) {
>                sbuf[i] = sbuf[i + 1];
>            }
>            int b;
>            if ((b = in.read()) == -1) return null;
>            sbuf[35] = (byte)b;
>
>
> which maybe can be replaced by
>
>                                        /* out of phase maybe? */
>                          /* inch forward 1 byte and try again */
>            if (log.level >= 5) {
>                log.println( "maybe we are out of phase. Try resyncing" );
>            }
>            System.arraycopy( sbuf, 1, sbuf, 0, 35 );
>            if (log.level >= 6) {
>                jcifs.util.Hexdump.hexdump( log, sbuf, 4, 31 );
>            }
>            if (readn( in, sbuf, 35, 1 ) == -1) {
>                return null;
>            }
>
> Is "out of phase" an often case?

Hi Sebastian,

No. It should never happen. I'm not sure if that code has ever even
been tested. I think the purpose of that code is to gracefully handle
skipping a message that JCIFS could not decode for some reason. So
there is really no reason for "improvement" here.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.