From: Howard Chu Date: Thu, 1 Aug 2002 07:09:11 +0000 (+0000) Subject: Revert previous commit. Fix needs more design. X-Git-Tag: NO_SLAP_OP_BLOCKS~1297 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=91aff0b3e24e7bb4b55f9e59707f7d03c6e0da56;p=openldap Revert previous commit. Fix needs more design. --- diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c index 3d19c3a4f6..ae5c07c8c1 100644 --- a/libraries/liblber/sockbuf.c +++ b/libraries/liblber/sockbuf.c @@ -288,7 +288,7 @@ ber_pvt_sb_copy_out( Sockbuf_Buf *sbb, char *buf, ber_len_t len ) ber_slen_t ber_pvt_sb_do_write( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out ) { - ber_len_t to_go, done = 0; + ber_len_t to_go; ber_slen_t ret; assert( sbiod != NULL ); @@ -300,32 +300,24 @@ ber_pvt_sb_do_write( Sockbuf_IO_Desc *sbiod, Sockbuf_Buf *buf_out ) for(;;) { ret = LBER_SBIOD_WRITE_NEXT( sbiod, buf_out->buf_base + buf_out->buf_ptr, to_go ); - if ( ret < 0 ) { - if (errno==EAGAIN #ifdef EINTR - || errno==EINTR + if ((ret<0) && (errno==EINTR)) continue; #endif - ) continue; - - return ret; - } + break; + } - if ( ret == 0 ) return ret; + if ( ret <= 0 ) return ret; - buf_out->buf_ptr += ret; - done += ret; + buf_out->buf_ptr += ret; + if (buf_out->buf_ptr == buf_out->buf_end) { + buf_out->buf_end = buf_out->buf_ptr = 0; + } - if (buf_out->buf_ptr == buf_out->buf_end) { - buf_out->buf_end = buf_out->buf_ptr = 0; - ret = done; - break; - } else if (buf_out->buf_ptr > buf_out->buf_end) { - /* impossible */ - return -1; - } else { - to_go -= ret; - } + if ( (ber_len_t)ret < to_go ) { + /* not enough data, so pretend no data was sent. */ + return -1; } + return ret; }