Resyncing? Out of Phase

Sebastian Sickelmann <[email protected]>
Newsgroups gmane.network.samba.java
Message-ID <[email protected]>
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? There is some more improvement possible 
thought searching next possible resync point in the avaiable 35 bytes! I 
can try to create the improvement, or is this code only used very rare?


--Sebastian
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.