[jcifs] Resyncing? Out of Phase

Sebastian Sickelmann sebastian.sickelmann at gmx.de
Wed Aug 10 14:21:46 MDT 2011


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


More information about the jCIFS mailing list