------------------------------------------------------------------------- dump_psi Dump the psi_output to the downstream vconnection. Input: contp continuation for the current transaction Output : Return Value: 0 if failure 1 if success -------------------------------------------------------------------------*/
| 692 | 1 if success |
| 693 | -------------------------------------------------------------------------*/ |
| 694 | static int |
| 695 | dump_psi(TSCont contp) |
| 696 | { |
| 697 | ContData *data; |
| 698 | |
| 699 | data = contDataGet(contp); |
| 700 | TSAssert(data->magic == MAGIC_ALIVE); |
| 701 | |
| 702 | /* If script exec succeeded, copy its output to the downstream vconn */ |
| 703 | if (data->psi_success == 1) { |
| 704 | int psi_output_len = TSIOBufferReaderAvail(data->psi_reader); |
| 705 | |
| 706 | if (psi_output_len > 0) { |
| 707 | data->transform_bytes += psi_output_len; |
| 708 | |
| 709 | Dbg(dbg_ctl, "Inserting %d bytes from include file", psi_output_len); |
| 710 | /* TODO: Should we check the return value of TSIOBufferCopy() ? */ |
| 711 | TSIOBufferCopy(TSVIOBufferGet(data->output_vio), data->psi_reader, psi_output_len, 0); |
| 712 | /* Consume all the output data */ |
| 713 | TSIOBufferReaderConsume(data->psi_reader, psi_output_len); |
| 714 | |
| 715 | /* Reenable the output connection so it can read the data we've produced. */ |
| 716 | TSVIOReenable(data->output_vio); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | /* Change state to finish up reading upstream data */ |
| 721 | data->state = STATE_READ_DATA; |
| 722 | return 0; |
| 723 | } |
| 724 | |
| 725 | /*------------------------------------------------------------------------- |
| 726 | transform_handler |
no test coverage detected