pike.git / src / modules / _Stdio / buffer.cmod

version» Context lines:

pike.git/src/modules/_Stdio/buffer.cmod:491:    continue;       if( res <= 0 )    break;    nbytes -= res;    io->len += res;    bread += res;    if( res != 4096 )    break;    } -  io_unlock(io); +  fd->box.revents &= ~(PIKE_BIT_FD_READ|PIKE_BIT_FD_READ_OOB);    }    else    {    /* some other object. Just call read */    while( nbytes )    {    push_int( MINIMUM(4096,nbytes) );    safe_apply( f, "read", 1 );    if( TYPEOF(Pike_sp[-1]) != PIKE_T_STRING || Pike_sp[-1].u.string->len == 0 )    break;
pike.git/src/modules/_Stdio/buffer.cmod:530:    */    PIKEFUN int(0..) output_to( object f, int|void _nbytes )    {    IOBuffer *io = THIS;    size_t sz = io_len( io );    size_t written = 0, nbytes = (size_t)-1;    struct my_file *fd;    INT_TYPE *wr = &Pike_sp->u.integer;       if( !sz ) +  {    io_range_error(io, sz); -  +  sz = io_len(io); +  }    if( _nbytes )    nbytes = _nbytes->u.integer;       if( (fd = get_storage( f, file_program )) )    {    /* lock this object. */ -  io_lock(io); -  +     while( sz > written && nbytes )    {    size_t rd = MINIMUM(MINIMUM(sz-written,4096),nbytes);    unsigned char *ptr = io_read_pointer( io );    ssize_t res;    res = fd_write( fd->box.fd, ptr, rd );    if( res == -1 && errno == EINTR )    continue;    if( res <= 0 )    break;    io_consume( io, res );    written += res; -  +  nbytes-=res;    } -  +  fd->box.revents &= ~(PIKE_BIT_FD_WRITE|PIKE_BIT_FD_WRITE_OOB); +  if(!SAFE_IS_ZERO(&fd->event_cbs[PIKE_FD_WRITE]) +  && fd->box.backend) +  set_fd_callback_events(&fd->box, fd->box.events|PIKE_BIT_FD_WRITE, 0);    }    else    {    /* some other object. Just call write */    while( sz > written && nbytes)    {    size_t rd = MINIMUM(MINIMUM(sz-written,4096),nbytes);    struct pike_string *s = io_read_string( io, rd );    if( !s )    break;