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

version» Context lines:

pike.git/src/modules/_Stdio/sendfile.c:147:   /*    * Globals    */      static struct program *pike_sendfile_prog = NULL;      /*    * Struct init code.    */    - static void init_pike_sendfile(struct object *UNUSED(o)) - { -  memset(THIS, 0, sizeof(struct pike_sendfile)); -  -  /* callback doesn't actually need to be initialized since it is a -  * mapped variable, but since we just zapped it with zeroes we need -  * to set the type to T_INT again.. /Hubbe -  */ -  SET_SVAL(THIS->callback, T_INT, NUMBER_NUMBER, integer, 0); - } -  +    static void exit_pike_sendfile(struct object *UNUSED(o))   {    SF_DFPRINTF((stderr, "sendfile: Exiting...\n"));    -  if (THIS->iovs) { +  if (THIS->iovs)    free(THIS->iovs); -  THIS->iovs = NULL; -  } -  if (THIS->buffer) { +  +  if (THIS->buffer)    free(THIS->buffer); -  THIS->buffer = NULL; -  } -  if (THIS->headers) { +  +  if (THIS->headers)    free_array(THIS->headers); -  THIS->headers = NULL; -  } -  if (THIS->trailers) { +  +  if (THIS->trailers)    free_array(THIS->trailers); -  THIS->trailers = NULL; -  } -  if (THIS->from_file) { +  +  if (THIS->from_file)    free_object(THIS->from_file); -  THIS->from_file = NULL; -  } -  if (THIS->to_file) { +  +  if (THIS->to_file)    free_object(THIS->to_file); -  THIS->to_file = NULL; -  } -  if (THIS->args) { -  free_array(THIS->args); -  THIS->args = NULL; -  } -  if (THIS->self) { +     /* This can occur if Pike exits before the backend has started. */ -  +  if (THIS->self)    free_object(THIS->self); -  THIS->self = NULL; -  } -  /* This is not required since this is a mapped variable. -  * /Hubbe -  * But we do it anyway for paranoia reasons. -  * /grubba 1999-10-14 -  */ -  free_svalue(&(THIS->callback)); -  SET_SVAL(THIS->callback, T_INT, NUMBER_NUMBER, integer, 0); -  if (THIS->backend_callback) { +  +  if (THIS->backend_callback)    remove_callback (THIS->backend_callback); -  THIS->backend_callback = NULL; +    } - } +       /*    * Fallback code    */      #ifndef HAVE_WRITEV   #define writev my_writev   static size_t writev(int fd, struct iovec *iov, int n)   {    if (n) {
pike.git/src/modules/_Stdio/sendfile.c:892:    free_svalue(&(THIS->callback));    SET_SVAL(THIS->callback, T_INT, NUMBER_NUMBER, integer, 0);       /* NOTE: The references to the stuff in sf are held by the stack.    * This means that we can throw errors without needing to clean up.    */       memset(&sf, 0, sizeof(struct pike_sendfile));    SET_SVAL(sf.callback, T_INT, NUMBER_NUMBER, integer, 0);    -  get_all_args("sendfile", args, "%A%O%l%l%A%o%*", +  get_all_args(NULL, args, "%A%O%l%l%A%o%*",    &(sf.headers), &(sf.from_file), &offset,    &len, &(sf.trailers), &(sf.to_file), &cb);       sf.offset = offset;    sf.len = len;       /* We need to give 'cb' another reference /Hubbe */    /* No, we don't. We steal the reference from the stack.    * /grubba    */
pike.git/src/modules/_Stdio/sendfile.c:1183:    /* The worker will have a ref. */    th_farm(worker, THIS);   #if 0    {    /* Failure */    sf.to->flags &= ~FILE_LOCK_FD;    if (sf.from) {    sf.from->flags &= ~FILE_LOCK_FD;    }    free_object(THIS->self); -  resource_error("Stdio.sendfile", sp, 0, "threads", 1, -  "Failed to create thread.\n"); +  Pike_error("Failed to create thread.\n");    }   #endif /* 0 */    }    return;   }      /*! @endclass    */      #endif /* _REENTRANT */
pike.git/src/modules/_Stdio/sendfile.c:1214: Inside #if defined(_REENTRANT)
   PIKE_MAP_VARIABLE("_args", OFFSETOF(pike_sendfile, args),    tArray, T_ARRAY, 0);    PIKE_MAP_VARIABLE("_callback", OFFSETOF(pike_sendfile, callback),    tFuncV(tInt,tMix,tVoid), T_MIXED, 0);       /* function(array(string),object,int,int,array(string),object,function(int,mixed...:void),mixed...:void) */    ADD_FUNCTION("create", sf_create,    tFuncV(tArr(tStr) tObj tInt tInt tArr(tStr) tObj    tFuncV(tInt, tMix, tVoid), tMix, tVoid), 0);    -  set_init_callback(init_pike_sendfile); +     set_exit_callback(exit_pike_sendfile);       pike_sendfile_prog = end_program();    add_program_constant("sendfile", pike_sendfile_prog, 0);   #endif /* _REENTRANT */   }      void exit_stdio_sendfile(void)   {   #ifdef _REENTRANT    if (pike_sendfile_prog) {    free_program(pike_sendfile_prog);    pike_sendfile_prog = NULL;    }   #endif /* _REENTRANT */   }      /*! @endmodule    */