xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexis Agahi ...@agahi.com>
Subject [crimson/(xerces)] blocking I/O on InputEntity problem
Date Sun, 28 Oct 2001 18:34:42 GMT
Hi,

I've notice that fillbuf() method in
org.apache.crimson.parser.InputEntity 
when reading the 'Reader' can block on IO.
In fact, the way the code is implemented avoids input stream
parsing on the fly.

to be precise
=>  len = reader.read(buf, finish, len );
attempt to read 8Ko of data, and if the stream just send less
than 8k (it could happen on 2 ways communication protocol, such
as Jabber.org protocol), it blocks on this instruction.


To avoid this case I've rapidly hacked a dirty work:

=========
len = buf.length - len;
int appended = 0;

do{
int val = reader.read();
if( val == -1 ) close();
else{
    char c = (char)val;
    if( Character.isDefined( c ) ){
	buf[finish++] = c;
	appended++;
    }

}
}while( reader.ready() && finish<=buf.length && appended<=len );

len = appended;
===========

in this approach I use a combination of

do{
    int val = reader.read()
    ...
}while( reader.ready() ...);

to be sure the execution wont freeze in an IO operation.

I know this is clearly not an optimised work.

Hope this could help

-- 
Al

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message