On Thu, Oct 26, 2000 at 01:58:03PM -0700, David Schwartz wrote:

>> You have to include that BIO_write(bio_io, ...) in this loop!

>       Why? I have to data to write. If I had data to write, I would have already
> written it before I entered the loop. If I get more data to write later,
> I'll enter the loop again.

If you enter the loop again later, then you *do* have a loop that
includes this BIO_write() call.  None of the calls in your example
code can block when using BIO pairs, so the deadlock cannot
have occured in there, and I had to make guesses about what goes
on outside that piece of code.  If you always send all available
network data to BIO_write(bio_io, ...) and send out all data
obtained by BIO_read(bio_io, ...) via the network, then there
cannot be a deadlock.


>> Either check if data is available from the network and the call
>> BIO_write() (but don't try to write more the
>> BIO_get_write_guarantee(bio_io) bytes because that's all the buffer
>> can take),

>       Is it harmful to try to write more than the buffer can take? Won't it just
> fail to take it?

It's harmless to write more, you'll just get a 'short write' -- i.e.
BIO_write() returns the number of bytes that fit into the buffer.
Limiting writes to BIO_get_write_guarantee(bio_io) bytes is often more
convenient, depending on what the interface looks like that you use to
obtain the network data which you forward to BIO_write():

If you don't look at BIO_get_write_guarantee(bio_io)
(or BIO_get_read_request(bio_io), which is never returns a
larger number than BIO_get_write_guarantee(bio_io)), then if

     BIO_write(bio_io, buf, n)

returns some i where 0 < i < n, then you'll have to call

     BIO_write(bio_io, buf+i, ...)

later after giving the SSL library a chance to process the data from
the first BIO_write.  On the other hand, if you avoid short writes,
then you don't have to worry about this, and you're done with
this buffer after just one call to BIO_write().


-- 
Bodo M�ller <[EMAIL PROTECTED]>
PGP http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/moeller/0x36d2c658.html
* TU Darmstadt, Theoretische Informatik, Alexanderstr. 10, D-64283 Darmstadt
* Tel. +49-6151-16-6628, Fax +49-6151-16-6036
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to