hc->flags &= ~HTTP_CONN_F_HAS_REQUEST;
}
+/* Deschedule http session and wait for deq notification if underlying ts tx
+ * fifo almost full */
+static_always_inline void
+http1_check_and_deschedule (http_conn_t *hc, http_req_t *req,
+ transport_send_params_t *sp)
+{
+ if (http_io_ts_check_write_thresh (hc))
+ {
+ http_req_deschedule (req, sp);
+ http_io_ts_add_want_deq_ntf (hc);
+ }
+}
+
static void
http1_send_error (http_conn_t *hc, http_status_code_t ec,
transport_send_params_t *sp)
HTTP_DBG (3, "%v", data);
http_io_ts_write (hc, data, vec_len (data), sp);
vec_free (data);
- http_io_ts_after_write (hc, sp, 0, 1);
+ http_io_ts_after_write (hc, 0);
}
static int
if (max_enq == 0)
{
HTTP_DBG (1, "app's rx fifo full");
- http_io_as_want_deq_ntf (req);
+ http_io_as_add_want_deq_ntf (req);
return HTTP_SM_STOP;
}
if (max_enq == 0)
{
HTTP_DBG (1, "app's rx fifo full");
- http_io_as_want_deq_ntf (req);
+ http_io_as_add_want_deq_ntf (req);
return HTTP_SM_STOP;
}
max_read = clib_min (max_enq, max_deq);
if (http_io_as_max_write (req) < dgram_size)
{
HTTP_DBG (1, "app's rx fifo full");
- http_io_as_want_deq_ntf (req);
+ http_io_as_add_want_deq_ntf (req);
goto done;
}
http_req_state_change (req, next_state);
- http_io_ts_after_write (hc, sp, 0, 1);
+ http_io_ts_after_write (hc, 0);
return sm_result;
error:
http_req_state_change (req, next_state);
- http_io_ts_after_write (hc, sp, 0, 1);
+ http_io_ts_after_write (hc, 0);
goto done;
error:
HTTP_REQ_STATE_WAIT_TRANSPORT_REPLY);
http_buffer_free (hb);
}
+ http_io_ts_after_write (hc, finished);
check_fifo:
- http_io_ts_after_write (hc, sp, finished, !!n_written);
+ http1_check_and_deschedule (hc, req, sp);
return HTTP_SM_STOP;
}
http_io_as_read_segs (req, segs, &n_segs, max_read);
n_written = http_io_ts_write_segs (hc, segs, n_segs, sp);
http_io_as_drain (req, n_written);
+ http_io_ts_after_write (hc, 0);
check_fifo:
- http_io_ts_after_write (hc, sp, 0, !!n_written);
-
+ http1_check_and_deschedule (hc, req, sp);
return HTTP_SM_STOP;
}
}
done:
- http_io_ts_after_write (hc, sp, 0, written);
-
+ if (written)
+ http_io_ts_after_write (hc, 0);
+ http1_check_and_deschedule (hc, req, sp);
return HTTP_SM_STOP;
}
response = http_get_tx_buf (hc);
http2_frame_write_goaway (error, h2c->last_processed_stream_id, &response);
http_io_ts_write (hc, response, vec_len (response), sp);
- http_io_ts_after_write (hc, sp, 1, 1);
+ http_io_ts_after_write (hc, 1);
hash_foreach (stream_id, req_index, h2c->req_by_stream_id, ({
req = http2_req_get (req_index, hc->c_thread_index);
response = http_get_tx_buf (hc);
http2_frame_write_rst_stream (error, stream_id, &response);
http_io_ts_write (hc, response, vec_len (response), sp);
- http_io_ts_after_write (hc, sp, 1, 1);
+ http_io_ts_after_write (hc, 1);
}
/* send RST_STREAM frame and notify app */
response = http_get_tx_buf (hc);
http2_frame_write_settings (settings_list, &response);
http_io_ts_write (hc, response, vec_len (response), 0);
- http_io_ts_after_write (hc, 0, 0, 1);
+ http_io_ts_after_write (hc, 0);
}
/*************************************/
{ response, vec_len (response) } };
n_written = http_io_ts_write_segs (hc, segs, 2, sp);
ASSERT (n_written == (HTTP2_FRAME_HEADER_SIZE + vec_len (response)));
- http_io_ts_after_write (hc, sp, 0, 1);
+ http_io_ts_after_write (hc, 0);
return sm_result;
}
else
req->stream_state = HTTP2_STREAM_STATE_HALF_CLOSED;
}
+ http_io_ts_after_write (hc, finished);
check_fifo:
- http_io_ts_after_write (hc, sp, finished, !!n_written);
+ if (http_io_ts_check_write_thresh (hc))
+ {
+ http_io_ts_add_want_deq_ntf (hc);
+ http_req_deschedule (&req->base, sp);
+ }
return HTTP_SM_STOP;
}
http2_frame_write_settings_ack (&resp);
http_io_ts_write (hc, resp, vec_len (resp), 0);
vec_free (resp);
- http_io_ts_after_write (hc, 0, 0, 1);
+ http_io_ts_after_write (hc, 0);
}
return HTTP2_ERROR_NO_ERROR;
http2_frame_write_ping (1, rx_buf, &resp);
http_io_ts_write (hc, resp, vec_len (resp), 0);
vec_free (resp);
- http_io_ts_after_write (hc, 0, 1, 1);
+ http_io_ts_after_write (hc, 1);
return HTTP2_ERROR_NO_ERROR;
}
return 0;
}
+always_inline void
+http_req_deschedule (http_req_t *req, transport_send_params_t *sp)
+{
+ transport_connection_deschedule (&req->connection);
+ sp->flags |= TRANSPORT_SND_F_DESCHED;
+}
+
/* Abstraction of app session fifo operations */
always_inline void
-http_io_as_want_deq_ntf (http_req_t *req)
+http_io_as_add_want_deq_ntf (http_req_t *req)
{
session_t *as = session_get_from_handle (req->hr_pa_session_handle);
svm_fifo_add_want_deq_ntf (as->rx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
sp->max_burst_size);
}
+always_inline int
+http_io_ts_check_write_thresh (http_conn_t *hc)
+{
+ session_t *ts = session_get_from_handle (hc->hc_tc_session_handle);
+ return (svm_fifo_max_enqueue_prod (ts->tx_fifo) < HTTP_FIFO_THRESH);
+}
+
+always_inline void
+http_io_ts_add_want_deq_ntf (http_conn_t *hc)
+{
+ session_t *ts = session_get_from_handle (hc->hc_tc_session_handle);
+ svm_fifo_add_want_deq_ntf (ts->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
+}
+
always_inline u32
http_io_ts_read (http_conn_t *hc, u8 *buf, u32 len, u8 peek)
{
}
always_inline void
-http_io_ts_after_write (http_conn_t *hc, transport_send_params_t *sp, u8 flush,
- u8 written)
+http_io_ts_after_write (http_conn_t *hc, u8 flush)
{
session_t *ts = session_get_from_handle (hc->hc_tc_session_handle);
if (!flush)
{
- if (written && svm_fifo_set_event (ts->tx_fifo))
+ if (svm_fifo_set_event (ts->tx_fifo))
session_program_tx_io_evt (ts->handle, SESSION_IO_EVT_TX);
-
- if (sp && (svm_fifo_max_enqueue (ts->tx_fifo) < HTTP_FIFO_THRESH))
- {
- /* Deschedule http session and wait for deq notification if
- * underlying ts tx fifo almost full */
- svm_fifo_add_want_deq_ntf (ts->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
- transport_connection_deschedule (&hc->connection);
- sp->flags |= TRANSPORT_SND_F_DESCHED;
- }
}
else
{
- if (written && svm_fifo_set_event (ts->tx_fifo))
+ if (svm_fifo_set_event (ts->tx_fifo))
session_program_tx_io_evt (ts->handle, SESSION_IO_EVT_TX_FLUSH);
}
}