[jcifs] readPacketType() / IO exception

Ang Chang ang_chng at yahoo.com
Wed Feb 23 09:05:42 GMT 2005


Hi,

Regarding this issue with HP-UX, is this happening only for HP-UX systems? What about 

Solaris, AIX or Linux, are they having the same problem against the same server? 

We use jcifs in Linux under really heavy load and this poblem did not turn up.

The problem is within this method in SessionServicePacket:

static int readPacketType( InputStream in,

byte[] buffer,

int bufferIndex )

throws IOException {

int n;

if(( n = in.read( buffer, bufferIndex, HEADER_LENGTH )) != HEADER_LENGTH ) {

if( n == -1 ) {

return -1;

}

throw new IOException( "unexpected EOF reading netbios session header" );

}

int t = buffer[bufferIndex] & 0xFF;

return t;

}

 

Michael, shouldn´t the following method in socketInputStream deal with this problem?if SmbTransport asks for the header (4 bytes) why less than four are returned? As far as I understand if we ask this method for 4 bytes, the method won´t return till len bytes have been read.

 

/* This method will not return until len bytes have been read

* or the stream has been closed.

*/



public synchronized int read( byte[] b, int off, int len ) throws IOException {

if( len == 0 ) {

return 0;

}

tot = 0;

while( true ) {

while( bip > 0 ) {

n = in.read( b, off, Math.min( len, bip ));

if( n == -1 ) {

return tot > 0 ? tot : -1;

}

tot += n;

off += n;

len -= n;

bip -= n;

if( len == 0 ) {

return tot;

}

}

switch( SessionServicePacket.readPacketType( in, header, 0 )) {

case SessionServicePacket.SESSION_KEEP_ALIVE:

break;

case SessionServicePacket.SESSION_MESSAGE:

bip = SessionServicePacket.readLength( header, 0 );

break;

case -1:

if( tot > 0 ) {

return tot;

}

return -1;

}

}

}

Regards,

Ang


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the jcifs mailing list