示例#1
0
void nxd_http_client_proto_rearm(nxd_http_client_proto* hcp) {
  assert(hcp->nxb);
  nxb_empty(hcp->nxb);
  nxp_free(hcp->nxb_pool, hcp->nxb);
  hcp->nxb=0;
  memset(&hcp->_req, 0, sizeof(hcp->_req));
  hcp->_req.nxb=hcp->nxb;
  hcp->_req.host=0;
  hcp->resp.nxb=hcp->nxb;
  while (hcp->events_pub.sub) nxe_unsubscribe(&hcp->events_pub, hcp->events_pub.sub);
  if (hcp->req_body_in.pair) nxe_disconnect_streams(hcp->req_body_in.pair, &hcp->req_body_in);
  if (hcp->resp_body_out.pair) nxe_disconnect_streams(&hcp->resp_body_out, hcp->resp_body_out.pair);
  nxe_ostream_unset_ready(&hcp->req_body_in);
  nxe_istream_unset_ready(&hcp->resp_body_out);
  nxe_ostream_unset_ready(&hcp->data_in);
  nxe_istream_unset_ready(&hcp->data_out);
}
示例#2
0
void nxd_http_client_proto_finalize(nxd_http_client_proto* hcp) {
  nxe_loop* loop=hcp->data_in.super.loop;
  nxe_unset_timer(loop, NXWEB_TIMER_KEEP_ALIVE, &hcp->timer_keep_alive);
  nxe_unset_timer(loop, NXWEB_TIMER_READ, &hcp->timer_read);
  nxe_unset_timer(loop, NXWEB_TIMER_WRITE, &hcp->timer_write);
  nxe_unset_timer(loop, NXWEB_TIMER_100CONTINUE, &hcp->timer_100_continue);
  if (hcp->data_error.pub) nxe_unsubscribe(hcp->data_error.pub, &hcp->data_error);
  while (hcp->events_pub.sub) nxe_unsubscribe(&hcp->events_pub, hcp->events_pub.sub);
  if (hcp->data_in.pair) nxe_disconnect_streams(hcp->data_in.pair, &hcp->data_in);
  if (hcp->data_out.pair) nxe_disconnect_streams(&hcp->data_out, hcp->data_out.pair);
  if (hcp->req_body_in.pair) nxe_disconnect_streams(hcp->req_body_in.pair, &hcp->req_body_in);
  if (hcp->resp_body_out.pair) nxe_disconnect_streams(&hcp->resp_body_out, hcp->resp_body_out.pair);
  if (hcp->nxb) {
    nxb_empty(hcp->nxb);
    nxp_free(hcp->nxb_pool, hcp->nxb);
    hcp->nxb=0;
  }
}
示例#3
0
static void retry_proxy_request(nxweb_http_proxy_request_data* rdata) {

  nxweb_log_debug("retry_proxy_request");

  nxd_http_proxy* hpx=rdata->hpx;
  nxweb_http_server_connection* conn=rdata->conn;

  enum nxd_http_server_proto_state state=conn->hsp.state;
  assert(state==HSP_RECEIVING_HEADERS || state==HSP_RECEIVING_BODY || state==HSP_HANDLING);

  nxd_http_proxy_pool_return(hpx, 1);
  if (rdata->rb_resp.data_in.pair) nxe_disconnect_streams(rdata->rb_resp.data_in.pair, &rdata->rb_resp.data_in);
  if (rdata->rb_resp.data_out.pair) nxe_disconnect_streams(&rdata->rb_resp.data_out, rdata->rb_resp.data_out.pair);
  if (rdata->rb_req.data_in.pair) nxe_disconnect_streams(rdata->rb_req.data_in.pair, &rdata->rb_req.data_in);
  if (rdata->rb_req.data_out.pair) nxe_disconnect_streams(&rdata->rb_req.data_out, rdata->rb_req.data_out.pair);
  if (rdata->proxy_events_sub.pub) nxe_unsubscribe(rdata->proxy_events_sub.pub, &rdata->proxy_events_sub);
  rdata->hpx=0;
  rdata->retry_count++;
  start_proxy_request(conn, &conn->hsp.req, rdata);
}
示例#4
0
static void ssi_finalize(nxweb_filter* filter, nxweb_http_server_connection* conn, nxweb_http_request* req, nxweb_http_response* resp, nxweb_filter_data* fdata) {
  ssi_filter_data* sfdata=(ssi_filter_data*)fdata;
  if (sfdata->ssib.data_in.pair) nxe_disconnect_streams(sfdata->ssib.data_in.pair, &sfdata->ssib.data_in);
  if (sfdata->input_fd) {
    close(sfdata->input_fd);
    sfdata->input_fd=0;
  }
  if (sfdata->ssib.nxb) {
    nxb_empty(sfdata->ssib.nxb);
    nxp_free(conn->hsp.nxb_pool, sfdata->ssib.nxb);
  }
}
示例#5
0
static void nxweb_http_proxy_request_finalize(nxd_http_server_proto* hsp, void* req_data) {

  nxweb_log_debug("nxweb_http_proxy_request_finalize");

  nxweb_http_proxy_request_data* rdata=req_data;
  nxweb_http_server_connection* conn=rdata->conn;
  nxe_loop* loop=conn->tdata->loop;
  nxe_unset_timer(loop, NXWEB_TIMER_BACKEND, &rdata->timer_backend);
  if (rdata->rb_resp.data_in.pair) nxe_disconnect_streams(rdata->rb_resp.data_in.pair, &rdata->rb_resp.data_in);
  if (rdata->rb_resp.data_out.pair) nxe_disconnect_streams(&rdata->rb_resp.data_out, rdata->rb_resp.data_out.pair);
  if (rdata->rb_req.data_in.pair) nxe_disconnect_streams(rdata->rb_req.data_in.pair, &rdata->rb_req.data_in);
  if (rdata->rb_req.data_out.pair) nxe_disconnect_streams(&rdata->rb_req.data_out, rdata->rb_req.data_out.pair);
  if (rdata->proxy_events_sub.pub) nxe_unsubscribe(rdata->proxy_events_sub.pub, &rdata->proxy_events_sub);
  if (rdata->hpx) {
    nxd_http_proxy_pool_return(rdata->hpx, rdata->proxy_request_error);
    rdata->hpx=0;
  }
  if (rdata->rbuf) {
    if (rdata->rbuf) nxp_free(conn->tdata->free_rbuf_pool, rdata->rbuf);
    rdata->rbuf=0;
  }
}
示例#6
0
void nxd_fbuffer_finalize(nxd_fbuffer* fb) {
  if (fb->data_out.pair) nxe_disconnect_streams(&fb->data_out, fb->data_out.pair);
  nx_file_reader_finalize(&fb->fr);
  fb->fd=0;
}