pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:732:    case FILE_READ | FILE_WRITE: ret=fd_RDWR; break;    }    if(flags & FILE_APPEND) ret|=fd_APPEND;    if(flags & FILE_CREATE) ret|=fd_CREAT;    if(flags & FILE_TRUNC) ret|=fd_TRUNC;    if(flags & FILE_EXCLUSIVE) ret|=fd_EXCL;    ret |= fd_LARGEFILE;    return ret;   }    - static void free_dynamic_buffer(dynamic_buffer *b) { free(b->s.str); } -  +    static struct pike_string *do_read(int fd,    INT32 r,    int all,    INT_TYPE *err)   {    ONERROR ebuf;    ptrdiff_t bytes_read, i;    INT32 try_read;    bytes_read=0;    *err=0;
pike.git/src/modules/_Stdio/file.c:832:    /* For some reason, 8k seems to work faster than 64k.    * (4k seems to be about 2% faster than 8k when using linux though)    * /Hubbe (Per pointed it out to me..)    *    * The slowdowns most likely are because of memory validation    * done by the kernel for buffer space which is later unused    * (short read) /srb    */    dynamic_buffer b;    -  b.s.str=0; +     initialize_buf(&b); -  SET_ONERROR(ebuf, free_dynamic_buffer, &b); +  SET_ONERROR(ebuf, buffer_free, &b);    i = all && !INT32_MUL_OVERFLOW(r, 2) ? DIRECT_BUFSIZE : READ_BUFFER;    do{    int e;    char *buf;       try_read = i;       buf = low_make_buf_space(try_read, &b);       THREADS_ALLOW();
pike.git/src/modules/_Stdio/file.c:867:    if(!all || !i) break;    }    else    {    low_make_buf_space(-try_read, &b);    if(e != EINTR)    {    *err=e;    if(!bytes_read)    { -  free(b.s.str); +  buffer_free(&b);    UNSET_ONERROR(ebuf);    return 0;    }    break;    }    }       /* See explanation in previous loop above */    if( i < try_read )    i += SMALL_NETBUF;
pike.git/src/modules/_Stdio/file.c:1173:       }else{    /* For some reason, 8k seems to work faster than 64k.    * (4k seems to be about 2% faster than 8k when using linux though)    * /Hubbe (Per pointed it out to me..)    */   #define CHUNK ( 1024 * 8 )    INT32 try_read;    dynamic_buffer b;    -  b.s.str=0; +     initialize_buf(&b); -  SET_ONERROR(ebuf, free_dynamic_buffer, &b); +  SET_ONERROR(ebuf, buffer_free, &b);    do{    int e;    try_read=MINIMUM(CHUNK,r);      #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL    message.msg.msg_control = &message.cmsgbuf;    message.msg.msg_controllen = sizeof(message.cmsgbuf);   #else    message.msg.msg_accrights = (void *)&message.cmsgbuf;    message.msg.msg_accrightslen = sizeof(message.cmsgbuf);
pike.git/src/modules/_Stdio/file.c:1228:    break;    }    else    {    low_make_buf_space(-try_read, &b);    if(e != EINTR)    {    ERRNO=e;    if(!bytes_read)    { -  free(b.s.str); +  buffer_free(&b);    UNSET_ONERROR(ebuf);    return 0;    }    break;    }    }    }while(r);       UNSET_ONERROR(ebuf);