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

version» Context lines:

pike.git/src/modules/Pipe/pipe.c:15: Inside #if defined(HAVE_MMAP)
  #ifdef HAVE_MMAP   /* sys/mman.h is _probably_ there anyway. */   #include <sys/mman.h>   #endif   #endif   #endif      #include <fcntl.h>      #include "global.h" - RCSID("$Id: pipe.c,v 1.20 1998/04/06 20:40:04 hubbe Exp $"); + RCSID("$Id: pipe.c,v 1.21 1998/04/20 18:53:46 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"
pike.git/src/modules/Pipe/pipe.c:151:   void close_and_free_everything(struct object *o,struct pipe *);   static INLINE void output_finish(struct object *obj);   static INLINE void output_try_write_some(struct object *obj);      /********** internal ********************************************************/      /* Push a callback to this object given the internal function number.    */   static void push_callback(int no)   { -  sp->u.object=THISOBJ; -  THISOBJ->refs++; +  add_ref(sp->u.object=THISOBJ);    sp->subtype=no+fp->context.identifier_level;    sp->type=T_FUNCTION;    sp++;   }      /* Allocate a new struct input, link it last in the linked list */   static INLINE struct input *new_input(void)   {    struct input *i;    ninputs++;
pike.git/src/modules/Pipe/pipe.c:271:    THIS->pos+=s->len;    return 0;    }    else    {    nbuffers++;    b=ALLOC_STRUCT(buffer);    b->next=NULL;    b->s=s;    sbuffers += s->len; -  s->refs++; +  add_ref(s);       if (THIS->lastbuffer)    THIS->lastbuffer->next=b;    else    THIS->firstbuffer=b;       THIS->lastbuffer=b;       THIS->bytes_in_buffer+=s->len;    }    return THIS->bytes_in_buffer > MAX_BYTES_IN_BUFFER;   }      /* Wake up the sleepers */   static void low_start(void)   {    struct object *obj, *next;    struct output *o;       -  THISOBJ->refs++; /* dont kill yourself now */ +  add_ref(THISOBJ); /* dont kill yourself now */    for(obj=THIS->firstoutput;obj;obj=next)    { -  obj->refs++; /* Hang on PLEASE!! /hubbe */ +  add_ref(obj); /* Hang on PLEASE!! /hubbe */    o=(struct output *)(obj->storage);    if (o->obj && o->mode==O_SLEEP)    {    if (!o->obj->prog)    {    output_finish(obj);    }    else    {   #if 0
pike.git/src/modules/Pipe/pipe.c:511:    {    /* FIXME: What about I_BLOCKING_OBJ? */    input_finish(); /* shouldn't be anything else ... maybe a finished object */    }    }    return NULL; /* no data */    }       if (pos==this->pos)    { -  this->firstbuffer->s->refs++; +  add_ref(this->firstbuffer->s);    return this->firstbuffer->s;    }    return make_shared_binary_string(this->firstbuffer->s->str+    pos-this->pos,    this->firstbuffer->s->len-    pos+this->pos);   }         /*
pike.git/src/modules/Pipe/pipe.c:710:    push_int(0);    return;    }    }    }   #endif       i->u.obj=obj;    nobjects++;    i->type=I_OBJ; -  i->u.obj->refs++; +  add_ref(i->u.obj);    i->set_nonblocking_offset=find_identifier("set_nonblocking",i->u.obj->prog);    i->set_blocking_offset=find_identifier("set_blocking",i->u.obj->prog);       if (i->set_nonblocking_offset<0 ||    i->set_blocking_offset<0)    {    if (find_identifier("read", i->u.obj->prog) < 0) {    /* Not even a read function */    free_object(i->u.obj);    i->u.obj=NULL;
pike.git/src/modules/Pipe/pipe.c:777:    {    append_buffer(sp[-args].u.string);    pop_n_elems(args);    push_int(0);    return;    }       i=new_input();    i->type=I_STRING;    nstrings++; -  i->u.str=sp[-args].u.string; -  i->u.str->refs++; +  add_ref(i->u.str=sp[-args].u.string);    pop_n_elems(args-1);   }      void f_mark_fd(INT32 args);      static void pipe_output(INT32 args)   {    struct object *obj;    struct output *o;    int fd;
pike.git/src/modules/Pipe/pipe.c:846:    THIS->pos=0; */    push_int(0);    apply(sp[-args-2].u.object,"set_id", 1);    pop_n_elems(args+2); /* ... and from apply x 2 */    return;    }    pop_stack(); /* from apply */    }       THIS->living_outputs++; -  THISOBJ->refs++; /* Weird */ +  add_ref(THISOBJ); /* Weird */       /* Allocate a new struct output */    obj=clone_object(output_program,0);    o=(struct output *)(obj->storage);    o->next=THIS->firstoutput;    THIS->firstoutput=obj;    noutputs++;    o->obj=NULL;    -  o->obj=sp[-args].u.object; -  o->obj->refs++; +  add_ref(o->obj=sp[-args].u.object);       o->write_offset=find_identifier("write",o->obj->prog);    o->set_nonblocking_offset=find_identifier("set_nonblocking",o->obj->prog);    o->set_blocking_offset=find_identifier("set_blocking",o->obj->prog);       if (o->write_offset<0 || o->set_nonblocking_offset<0 ||    o->set_blocking_offset<0)    {    free_object(o->obj);    error("illegal file object%s%s%s\n",    ((o->write_offset<0)?"; no write":""),    ((o->set_nonblocking_offset<0)?"; no set_nonblocking":""),    ((o->set_blocking_offset<0)?"; no set_blocking":""));    }       o->mode=O_RUN;    /* keep the file pointer of the duped fd    o->pos=0; */    o->pos=THIS->pos;    -  push_object(obj); -  obj->refs++; +  ref_push_object(obj);    apply(o->obj,"set_id",1);    pop_stack();       push_int(0);    push_callback(offset_output_write_callback);    push_callback(offset_output_close_callback);    apply_low(o->obj,o->set_nonblocking_offset,3);    pop_stack();       pop_n_elems(args-1);
pike.git/src/modules/Pipe/pipe.c:1072:   void close_and_free_everything(struct object *thisobj,struct pipe *p)   {    struct buffer *b;    struct input *i;    struct output *o;    struct object *obj;       p->done=1;       if (thisobj) -  thisobj->refs++; /* don't kill object during this */ +  add_ref(thisobj); /* don't kill object during this */       while (p->firstbuffer)    {    b=p->firstbuffer;    p->firstbuffer=b->next;    sbuffers-=b->s->len;    nbuffers--;    free_string(b->s);    b->next=NULL;    free((char *)b); /* Hubbe */