src/dps8/fnpuv.c
//
// fuv_write_cb: libuv write complete callback
//
//   Cleanup on error
//   Free buffers
//
libuv write complete callback
Cleanup on error
Free buffers
libuv write complete callback Cleanup on error Free buffers
static void fuv_write_cb (uv_write_t * req, int status)
  {
    if (status < 0)
      {
        if (status == -ECONNRESET || status == -ECANCELED ||
            status == -EPIPE)
          {
          }
        else
          {
            sim_warn ("fuv_write_cb status %d (%s)\n", -status, strerror (-status));
          }
        close_connection (req->handle);
      }
#ifdef USE_REQ_DATA
    free (req->data);
#else
    unsigned int nbufs = req->nbufs;
    uv_buf_t * bufs = req->bufs;
#if 0
    if (nbufs > ARRAY_SIZE(req->bufsml))
      bufs = req->bufsml;
#endif
    for (unsigned int i = 0; i < nbufs; i ++)
      {
        if (bufs && bufs[i].base)
          {
            free (bufs[i].base);
          }
        if (req->bufsml[i].base)
          {
            free (req->bufsml[i].base);
          }
      }
#endif
    free (req);
  }
static void fuv_write_cb ( uv_write_t * req , int status ) { if ( status < 0 ) { if ( status == - ECONNRESET || status == - ECANCELED || status == - EPIPE ) { } else { sim_warn ( " \n " , - status , strerror ( - status ) ) ; } close_connection ( req -> handle ) ; } #ifdef USE_REQ_DATA free ( req -> data ) ; #else unsigned int nbufs = req -> nbufs ; uv_buf_t * bufs = req -> bufs ; #if 0 if ( nbufs > ARRAY_SIZE ( req -> bufsml ) ) bufs = req -> bufsml ; #endif for ( unsigned int i = 0 ; i < nbufs ; i ++ ) { if ( bufs && bufs [ i ] . base ) { free ( bufs [ i ] . base ) ; } if ( req -> bufsml [ i ] . base ) { free ( req -> bufsml [ i ] . base ) ; } } #endif free ( req ) ; }
fuv_write_cb: libuv write complete callback
Cleanup on error
Free buffers
fuv_write_cb : libuv write complete callback Cleanup on error Free buffers
// This occurs when the other end disconnects; not an "error" // connection reset by peer //sim_printf ("freeing bufs %p\n", req->data); //if (! bufs) //sim_printf ("fuv_write_cb req %p req->data %p bufs %p nbufs %u\n", req, req->data, bufs, nbufs);  //sim_printf ("freeing bufs%d %p\n", i, bufs[i].base); //bufp -> base = NULL; //sim_printf ("freeing bufsml%d %p@%p\n", i, req->bufsml[i].base, & req->bufsml[i].base); // the buf structure is copied; do not free. //sim_printf ("freeing req %p\n", req);