pike.git / src / modules / Pipe / pipe.c

version» Context lines:

pike.git/src/modules/Pipe/pipe.c:19: Inside #if defined(HAVE_MMAP)
  #else   #ifdef HAVE_MMAP   /* sys/mman.h is _probably_ there anyway. */   #include <sys/mman.h>   #endif   #endif   #endif      #include <fcntl.h>    - RCSID("$Id: pipe.c,v 1.34 1999/07/29 16:47:34 grubba Exp $"); + RCSID("$Id: pipe.c,v 1.35 2000/07/02 16:52:19 grubba Exp $");      #include "threads.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "error.h"   #include "builtin_functions.h" -  + #include "fdlib.h"      #ifndef S_ISREG   #ifdef S_IFREG   #define S_ISREG(mode) (((mode) & (S_IFMT)) == (S_IFREG))   #else   #define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG))   #endif   #endif      /*
pike.git/src/modules/Pipe/pipe.c:285:    * scheduled for output. Return 1 if we have more bytes in buffers    * than allowed afterwards.    */   static INLINE int append_buffer(struct pike_string *s)    /* 1=buffer full */   {    struct buffer *b;       if(THIS->fd!= -1)    { -  lseek(THIS->fd, THIS->pos, SEEK_SET); -  write(THIS->fd, s->str, s->len); +  fd_lseek(THIS->fd, THIS->pos, SEEK_SET); +  fd_write(THIS->fd, s->str, s->len);    THIS->pos+=s->len;    return 0;    }    else    {    nbuffers++;    b=ALLOC_STRUCT(buffer);    b->next=NULL;    b->s=s;    sbuffers += s->len;
pike.git/src/modules/Pipe/pipe.c:441:       /* We have a file cache, read from it */    if (this->fd!=-1)    {    char buffer[READ_BUFFER_SIZE];       if (this->pos<=pos) return NULL; /* no data */    len=this->pos-pos;    if (len>READ_BUFFER_SIZE) len=READ_BUFFER_SIZE;    THREADS_ALLOW(); -  lseek(this->fd, pos, SEEK_SET); +  fd_lseek(this->fd, pos, SEEK_SET);    THREADS_DISALLOW();    do {    THREADS_ALLOW(); -  len = read(this->fd, buffer, len); +  len = fd_read(this->fd, buffer, len);    THREADS_DISALLOW();    if (len < 0) {    if (errno != EINTR) {    return(NULL);    }    }    } while(len < 0);    /*    * FIXME: What if len is 0?    */
pike.git/src/modules/Pipe/pipe.c:692: Inside #if defined(HAVE_MMAP) && defined(HAVE_MUNMAP)
      /* We do not handle mmaps if we have a buffer */    if(THIS->fd == -1)    {    apply(obj, "query_fd", 0);    if(sp[-1].type == T_INT) fd=sp[-1].u.integer;    pop_stack();       if (fd != -1 && fstat(fd,&s)==0)    { -  int filep=lseek(fd, 0L, SEEK_CUR); /* keep the file pointer */ +  int filep=fd_lseek(fd, 0L, SEEK_CUR); /* keep the file pointer */    if(S_ISREG(s.st_mode) /* regular file */    && ((long)(m=(char *)mmap(0,s.st_size - filep,PROT_READ,    MAP_FILE|MAP_SHARED,fd,filep))!=-1))    {   #ifdef HAVE_GETEUID    int ou = 0;   #endif    mmapped += s.st_size;       i->type=I_MMAP;
pike.git/src/modules/Pipe/pipe.c:851:       if (THIS->fd==-1) /* no buffer */    {    /* test if usable as buffer */    apply(sp[-args].u.object,"query_fd",0);       if ((sp[-1].type==T_INT)    && (fd=sp[-1].u.integer)>=0    && (fstat(fd,&s)==0)    && S_ISREG(s.st_mode) -  && (THIS->fd=dup(fd))!=-1 ) +  && (THIS->fd=fd_dup(fd))!=-1 )    {    /* keep the file pointer of the duped fd */ -  THIS->pos=lseek(fd, 0L, SEEK_CUR); +  THIS->pos=fd_lseek(fd, 0L, SEEK_CUR);      #if 0    /* This won't work if the spider-module is dynamically linked. */    push_int(THIS->fd);    push_string(make_shared_string("pipe.c: file buffer"));    f_mark_fd(2);    pop_stack();   #endif /* 0 */       THIS->living_outputs++;       while (THIS->firstbuffer)    {    b=THIS->firstbuffer;    THIS->firstbuffer=b->next; -  lseek(THIS->fd, THIS->pos, SEEK_SET); -  write(THIS->fd,b->s->str,b->s->len); +  fd_lseek(THIS->fd, THIS->pos, SEEK_SET); +  fd_write(THIS->fd,b->s->str,b->s->len);    sbuffers-=b->s->len;    nbuffers--;    free_string(b->s);    free((char *)b);    }    THIS->lastbuffer=NULL;       /* keep the file pointer of the duped fd    THIS->pos=0; */    push_int(0);
pike.git/src/modules/Pipe/pipe.c:1156:    while (p->firstoutput)    {    obj=p->firstoutput;    o=(struct output *)(obj->storage);    p->firstoutput=o->next;    output_finish(obj);    free_object(obj);    }    if (p->fd!=-1)    { -  close(p->fd); +  fd_close(p->fd);    p->fd=-1;    }       p->living_outputs=0;       if (thisobj)    free_object(thisobj);       free_svalue(& p->done_callback);    free_svalue(& p->output_closed_callback);