Commit cc202d5e authored by kelsey's avatar kelsey
Browse files

Updates following 2019 MSP Hackathon day 1

- Fixed off-by-one in template processing that resulted in
  minimum-size templates being treated as literal strings

- Enable time and size-based read queue draining

- Remove old pinpong.ucl file, correct template documentation in
  everything.ucl
parent 58d62bb8
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -899,6 +899,7 @@ demo_activity_process_read_queue(struct demo_connection *conn)
{
	struct demo_activity_match_state *match_state;
	struct demo_activity_match_state *selected_match_state;
	TLMSP_Container *container;
	unsigned int i;
	bool return_false;

@@ -965,6 +966,27 @@ demo_activity_process_read_queue(struct demo_connection *conn)
			return (false);
	} while ((selected_match_state != NULL) && (conn->read_queue.head != NULL));

	/*
	 * If the read queue has a size limit and we are over it, either
	 * drop (endpoint) or forward (middlebox) containers until we are
	 * back under the limit.
	 */
	if ((conn->read_queue.max_length != 0) &&
	    (conn->read_queue.length > conn->read_queue.max_length)) {
		demo_conn_log(2, conn, "Read queue is over limit with "
		    "nothing matching, %s containers in queue until under limit.",
		    (conn->splice != NULL) ? "forwarding" : "deleting");

		while (conn->read_queue.length > conn->read_queue.max_length) {
			container = container_queue_remove_head(&conn->read_queue);
			if (conn->splice != NULL)
				container_queue_add(&conn->other_side->write_queue,
				    container);
			else
				TLMSP_container_free(conn->ssl, container);
		}
	}
	
	/*
	 * We may have added data to the connection's write queue as a
	 * result of the match-action activity processed above, so ensure
+3 −5
Original line number Diff line number Diff line
@@ -17,19 +17,17 @@ static void container_queue_idle_cb(EV_P_ ev_timer *w, int revents);

void
container_queue_init(struct container_queue *q, struct demo_connection *conn,
    unsigned int max_idle, size_t max_depth)
    unsigned int max_idle_ms, size_t max_length_bytes)
{

	q->conn = conn;
	q->max_idle = max_idle;
	q->max_depth = max_depth;
	q->max_idle = max_idle_ms;
	q->max_length = max_length_bytes;
	q->head = NULL;
	q->tail = NULL;
	q->length = 0;
	q->container_counter = 0;

	/* XXX not yet */
	q->max_idle = 0;
	if (q->max_idle != 0) {
		ev_init(&q->idle_timer, container_queue_idle_cb);
		q->idle_timer.repeat = (double)q->max_idle / 1000.0;
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ struct container_queue {
	struct demo_connection *conn;
	ev_timer idle_timer;
	unsigned int max_idle;
	size_t max_depth;
	size_t max_length;
	struct container_queue_entry *head;
	struct container_queue_entry *tail;
	size_t length;  /* total number of payload bytes */
@@ -42,7 +42,7 @@ struct container_queue_range {
};

void container_queue_init(struct container_queue *q, struct demo_connection *conn,
                          unsigned int max_idle_ms, size_t max_depth_bytes);
                          unsigned int max_idle_ms, size_t max_length_bytes);
bool container_queue_add(struct container_queue *q,
                         TLMSP_Container *container);
TLMSP_Container *container_queue_head(struct container_queue *q);
+4 −3
Original line number Diff line number Diff line
@@ -98,9 +98,10 @@ activity {
        #
        #   template = <string>
        #   Send the data in the given string, which can contain
        #   substitution variables $0..$n.  $0 refers to all of the
        #   matched data.  In the case of a regex match, $1..$n refer
        #   to the corresponding capture group in the match regex.
        #   substitution variables ${0}..${n}.  ${0} refers to all of
        #   the matched data.  In the case of a regex match,
        #   ${1}..${n} refer to the corresponding capture group in the
        #   match regex.
        # }
        # 
        send-after {
+1 −1
Original line number Diff line number Diff line
@@ -1775,7 +1775,7 @@ find_first_match_reference(const uint8_t *buf, size_t len, size_t *ref_start,

	for (i = 0; i < len; i++) {
		if ((buf[i] == '$') &&       /* ref begins with $ */
		    ((len - 1) >= 4) &&  /* must be at least 4 chars */
		    (len  >= 4) &&           /* must be at least 4 chars */
		    (buf[i + 1] == '{')) {   /* ref begins with ${ */
			ref_end_found = false;
			for (j = i + 2; j < len; j++) {
Loading