example/thread-pool/psi.c
static int
wake_up_streams(INKCont contp)
{
  INKVIO input_vio;
  ContData *data;
  int ntodo;
  INKReturnCode retval;

  data = INKContDataGet(contp);
  INKAssert(data->magic == MAGIC_ALIVE);

  input_vio = INKVConnWriteVIOGet(contp);
  if (input_vio == INK_ERROR_PTR) {
    INKError("[wake_up_streams] Error while getting input_vio");
    return 0;
  }

  ntodo = INKVIONTodoGet(input_vio);
  if (ntodo == INK_ERROR) {
    INKError("[wake_up_streams] Error while getting bytes left to read");
    return 0;
  }

  if (ntodo > 0) {
    retval = INKVIOReenable(data->output_vio);
    if (retval == INK_ERROR) {
      INKError("[wake_up_streams] Error while reenabling downstream vio");
      return 0;
    }
    INKContCall(INKVIOContGet(input_vio), INK_EVENT_VCONN_WRITE_READY, input_vio);
  } else {
    INKDebug(DBG_TAG, "Total bytes produced by transform = %d", data->transform_bytes);
    retval = INKVIONBytesSet(data->output_vio, data->transform_bytes);
    if (retval == INK_ERROR) {
      INKError("[wake_up_streams] Error while setting nbytes to downstream vio");
      return 0;
    }
    retval = INKVIOReenable(data->output_vio);
    if (retval == INK_ERROR) {
      INKError("[wake_up_streams] Error while reenabling downstream vio");
      return 0;
    }
    INKContCall(INKVIOContGet(input_vio), INK_EVENT_VCONN_WRITE_COMPLETE, input_vio);
  }

  return 1;
}
/*-------------------------------------------------------------------------
  wake_up_streams
  Send an event to the upstream vconnection to either
    - ask for more data
    - let it know we're done
  Reenable the downstream vconnection
  Input:
    contp      continuation for the current transaction
  Output :
  Return Value:
   0 if failure
   1 if success
  -------------------------------------------------------------------------*/
wake_up_streams
Send an event to the upstream vconnection to either
ask for more data
let it know we're done
Reenable the downstream vconnection
Input:
contp      continuation for the current transaction
Output :
Return Value:
0 if failure
1 if success
wake_up_streams Send an event to the upstream vconnection to either ask for more data let it know we ' re done Reenable the downstream vconnection Input : contp continuation for the current transaction Output : Return Value : 0 if failure 1 if success
static int
wake_up_streams(INKCont contp)
{
  INKVIO input_vio;
  ContData *data;
  int ntodo;
  INKReturnCode retval;
  data = INKContDataGet(contp);
  INKAssert(data->magic == MAGIC_ALIVE);
  input_vio = INKVConnWriteVIOGet(contp);
  if (input_vio == INK_ERROR_PTR) {
    INKError("[wake_up_streams] Error while getting input_vio");
    return 0;
  }
  ntodo = INKVIONTodoGet(input_vio);
  if (ntodo == INK_ERROR) {
    INKError("[wake_up_streams] Error while getting bytes left to read");
    return 0;
  }
  if (ntodo > 0) {
    retval = INKVIOReenable(data->output_vio);
    if (retval == INK_ERROR) {
      INKError("[wake_up_streams] Error while reenabling downstream vio");
      return 0;
    }
    INKContCall(INKVIOContGet(input_vio), INK_EVENT_VCONN_WRITE_READY, input_vio);
  } else {
    INKDebug(DBG_TAG, "Total bytes produced by transform = %d", data->transform_bytes);
    retval = INKVIONBytesSet(data->output_vio, data->transform_bytes);
    if (retval == INK_ERROR) {
      INKError("[wake_up_streams] Error while setting nbytes to downstream vio");
      return 0;
    }
    retval = INKVIOReenable(data->output_vio);
    if (retval == INK_ERROR) {
      INKError("[wake_up_streams] Error while reenabling downstream vio");
      return 0;
    }
    INKContCall(INKVIOContGet(input_vio), INK_EVENT_VCONN_WRITE_COMPLETE, input_vio);
  }
  return 1;
}
static int wake_up_streams ( INKCont contp ) { INKVIO input_vio ; ContData * data ; int ntodo ; INKReturnCode retval ; data = INKContDataGet ( contp ) ; INKAssert ( data -> magic == MAGIC_ALIVE ) ; input_vio = INKVConnWriteVIOGet ( contp ) ; if ( input_vio == INK_ERROR_PTR ) { INKError ( " " ) ; return 0 ; } ntodo = INKVIONTodoGet ( input_vio ) ; if ( ntodo == INK_ERROR ) { INKError ( " " ) ; return 0 ; } if ( ntodo > 0 ) { retval = INKVIOReenable ( data -> output_vio ) ; if ( retval == INK_ERROR ) { INKError ( " " ) ; return 0 ; } INKContCall ( INKVIOContGet ( input_vio ) , INK_EVENT_VCONN_WRITE_READY , input_vio ) ; } else { INKDebug ( DBG_TAG , " " , data -> transform_bytes ) ; retval = INKVIONBytesSet ( data -> output_vio , data -> transform_bytes ) ; if ( retval == INK_ERROR ) { INKError ( " " ) ; return 0 ; } retval = INKVIOReenable ( data -> output_vio ) ; if ( retval == INK_ERROR ) { INKError ( " " ) ; return 0 ; } INKContCall ( INKVIOContGet ( input_vio ) , INK_EVENT_VCONN_WRITE_COMPLETE , input_vio ) ; } return 1 ; }
wake_up_streams
Send an event to the upstream vconnection to either
 ask for more data
 let it know we're done
Reenable the downstream vconnection
Input:
contp      continuation for the current transaction
Output :
Return Value:
0 if failure
1 if success
wake_up_streams Send an event to the upstream vconnection to either ask for more data let it know we ' re done Reenable the downstream vconnection Input : contp continuation for the current transaction Output : Return Value : 0 if failure 1 if success