#define CF_WAKE_ONCE 0x10000000 /* pretend there is activity on this channel (one-shoot) */
#define CF_FLT_ANALYZE 0x20000000 /* at least one filter is still analyzing this channel */
-/* unuse 0x40000000 */
+/* unused 0x40000000 */
#define CF_ISRESP 0x80000000 /* 0 = request channel, 1 = response channel */
/* Masks which define input events for stream analysers */
* without waking the parent up. The special value CHN_INFINITE_FORWARD is
* never decreased nor increased.
*
- * The buf->o parameter says how many bytes may be consumed from the visible
- * buffer. This parameter is updated by any buffer_write() as well as any data
- * forwarded through the visible buffer. Since the ->to_forward attribute
- * applies to data after buf->p, an analyser will not see a buffer which has a
- * non-null ->to_forward with buf->i > 0. A producer is responsible for raising
- * buf->o by min(to_forward, buf->i) when it injects data into the buffer.
+ * The channel's consumed data count (b_data(chn->buf)) says how many bytes may
+ * be consumed from the visible buffer. This is updated by any buffer_write()
+ * as well as any data forwarded through the visible buffer. Since the
+ * ->to_forward attribute applies to data beyond what's already been accounted
+ * for, an analyser will not see a buffer which has a non-null ->to_forward
+ * with additional unprocessed data. A producer is responsible for raising the
+ * consumed count by min(to_forward, available_data) when it injects data into
+ * the buffer.
*
- * The consumer is responsible for decreasing ->buf->o when it sends data
- * from the visible buffer, and ->pipe->data when it sends data from the
- * invisible buffer.
+ * The consumer is responsible for advancing the consumed count (via
+ * b_ack()) when it sends data from the visible buffer, and for updating
+ * ->pipe->data when it sends data from the invisible buffer.
*
* A real-world example consists in part in an HTTP response waiting in a
* buffer to be forwarded. We know the header length (300) and the amount of
* data to forward (content-length=9000). The buffer already contains 1000
* bytes of data after the 300 bytes of headers. Thus the caller will set
- * buf->o to 300 indicating that it explicitly wants to send those data, and
- * set ->to_forward to 9000 (content-length). This value must be normalised
- * immediately after updating ->to_forward : since there are already 1300 bytes
- * in the buffer, 300 of which are already counted in buf->o, and that size
- * is smaller than ->to_forward, we must update buf->o to 1300 to flush the
- * whole buffer, and reduce ->to_forward to 8000. After that, the producer may
+ * the consumed count to 300 indicating that it explicitly wants to send those
+ * data, and set ->to_forward to 9000 (content-length). This value must be
+ * normalised immediately after updating ->to_forward : since there are already
+ * 1300 bytes in the buffer, 300 of which are already counted in the consumed
+ * count, and that size is smaller than ->to_forward, we must update the
+ * consumed count to 1300 to flush the whole buffer, and reduce ->to_forward to
+ * 8000. After that, the producer may
* try to feed the additional data through the invisible buffer using a
* platform-specific method such as splice().
*
* buf->size - global.maxrewrite + ->to_forward.
*
* A buffer may contain up to 5 areas :
- * - the data waiting to be sent. These data are located between buf->p-o and
- * buf->p ;
- * - the data to process and possibly transform. These data start at
- * buf->p and may be up to ->i bytes long.
- * - the data to preserve. They start at ->p and stop at ->p+i. The limit
- * between the two solely depends on the protocol being analysed.
+ * - the data already consumed (acknowledged). These data are located between
+ * b_lim(b) and b_head(b) ;
+ * - the data available to process and possibly transform. These data start at
+ * b_head(b) and may be up to b_data(b) bytes long.
+ * - the data to preserve. They start at b_head(b) and stop at
+ * b_lim(b) + b_data(b). The limit between the two solely depends on the
+ * protocol being analysed.
* - the spare area : it is the remainder of the buffer, which can be used to
- * store new incoming data. It starts at ->p+i and is up to ->size-i-o long.
- * It may be limited by global.maxrewrite.
+ * store new incoming data. It starts at b_lim(b) + b_data(b) and is up to
+ * b->size - b_data(b) long. It may be limited by global.maxrewrite.
* - the reserved area : this is the area which must not be filled and is
* reserved for possible rewrites ; it is up to global.maxrewrite bytes
* long.
return (IS_HTX_STRM(chn_strm(chn)) ? htx_used_space(htxbuf(&chn->buf)) : c_data(chn));
}
-/* Returns the amount of input data in a channel, taking he HTX streams into
+/* Returns the amount of input data in a channel, taking the HTX streams into
* account. This function relies on channel_data().
*/
static inline size_t channel_input_data(const struct channel *chn)
return channel_data(chn) - co_data(chn);
}
-/* Returns 1 if the channel is empty, taking he HTX streams into account */
+/* Returns 1 if the channel is empty, taking the HTX streams into account */
static inline size_t channel_empty(const struct channel *chn)
{
return (IS_HTX_STRM(chn) ? htx_is_empty(htxbuf(&chn->buf)) : c_empty(chn));
chn->flags &= ~(CF_STREAMER | CF_STREAMER_FAST);
}
else if (chn->xfer_small >= 2) {
- /* if the buffer has been at least half full twchne,
+ /* if the buffer has been at least half full times,
* we receive faster than we send, so at least it
* is not a "fast streamer".
*/
/*
- * include/haproxy/filteers-t.h
+ * include/haproxy/filters-t.h
* This file defines everything related to stream filters.
*
* Copyright (C) 2015 Qualys Inc., Christopher Faulet <cfaulet@qualys.com>
/*
- * include/haproxy/http_htx-t.h
+ * include/haproxy/http_htx.h
* This file defines function prototypes for HTTP manipulation using the
* internal representation.
*
*/
#define HTX_SL_F_NONE 0x00000000
#define HTX_SL_F_IS_RESP 0x00000001 /* It is the response start-line (unset means the request one) */
-#define HTX_SL_F_XFER_LEN 0x00000002 /* The message xfer size can be dertermined */
+#define HTX_SL_F_XFER_LEN 0x00000002 /* The message xfer size can be determined */
#define HTX_SL_F_XFER_ENC 0x00000004 /* The transfer-encoding header was found in message */
#define HTX_SL_F_CLEN 0x00000008 /* The content-length header was found in message */
#define HTX_SL_F_CHNK 0x00000010 /* The message payload is chunked */
#define HTX_SL_F_HAS_AUTHORITY 0x00000400 /* The request authority is explicitly specified */
#define HTX_SL_F_NORMALIZED_URI 0x00000800 /* The received URI is normalized (an implicit absolute-uri form) */
#define HTX_SL_F_CONN_UPG 0x00001000 /* The message contains "connection: upgrade" header */
-#define HTX_SL_F_BODYLESS_RESP 0x00002000 /* The response to this message is bodyloess (only for reqyest) */
+#define HTX_SL_F_BODYLESS_RESP 0x00002000 /* The response to this message is bodyloess (only for request) */
#define HTX_SL_F_NOT_HTTP 0x00004000 /* Not an HTTP message (e.g "RTSP", only possible if invalid message are accepted) */
/* This function is used to report flags in debugging tools. Please reflect
return 0;
}
-/* set port in host byte order */
+/* set port in network byte order (use htons() before calling) */
static inline int set_net_port(struct sockaddr_storage *addr, int port)
{
switch (addr->ss_family) {
return 0;
}
-/* set port in network byte order */
+/* set port in host byte order */
static inline int set_host_port(struct sockaddr_storage *addr, int port)
{
switch (addr->ss_family) {
* cfg_free_cond_term(). An error will be set in <err> on error, and only
* in this case. In this case the first bad character will be reported in
* <errptr>. <maxdepth> corresponds to the maximum recursion depth permitted,
- * it is decremented on each recursive call and the parsing will fail one
+ * it is decremented on each recursive call and the parsing will fail upon
* reaching <= 0.
*/
int cfg_parse_cond_term(const char **text, struct cfg_cond_term **term, char **err, const char **errptr, int maxdepth)
* success. <expr> is filled with the parsed info, and <text> is updated on
* success to point to the first unparsed character, or is left untouched
* on failure. On success, the caller will have to free all lower-level
- * allocated structs using cfg_free_cond_expr(). An error will be set in
+ * allocated structs using cfg_free_cond_and(). An error will be set in
* <err> on error, and only in this case. In this case the first bad
* character will be reported in <errptr>. <maxdepth> corresponds to the
* maximum recursion depth permitted, it is decremented on each recursive
- * call and the parsing will fail one reaching <= 0.
+ * call and the parsing will fail upon reaching <= 0.
*/
int cfg_parse_cond_and(const char **text, struct cfg_cond_and **expr, char **err, const char **errptr, int maxdepth)
{
return ret;
}
-/* Parse an indirect input text as a possible config condition term.
+/* Parse an indirect input text as a possible config condition expression.
* Returns <0 on parsing error, 0 if the parser is desynchronized, or >0 on
* success. <expr> is filled with the parsed info, and <text> is updated on
* success to point to the first unparsed character, or is left untouched
* <err> on error, and only in this case. In this case the first bad
* character will be reported in <errptr>. <maxdepth> corresponds to the
* maximum recursion depth permitted, it is decremented on each recursive call
- * and the parsing will fail one reaching <= 0.
+ * and the parsing will fail upon reaching <= 0.
*/
int cfg_parse_cond_expr(const char **text, struct cfg_cond_expr **expr, char **err, const char **errptr, int maxdepth)
{
return ret;
}
-/* evaluate an sub-expression on a .if/.elif line. The expression is valid and
+/* evaluate a sub-expression on a .if/.elif line. The expression is valid and
* was already parsed in <expr>. Returns -1 on error (in which case err is
* filled with a message, and only in this case), 0 if the condition is false,
* 1 if it's true.
}
/* evaluate a condition on a .if/.elif line. The condition is already tokenized
- * in <err>. Returns -1 on error (in which case err is filled with a message,
+ * in <args>. Returns -1 on error (in which case err is filled with a message,
* and only in this case), 0 if the condition is false, 1 if it's true. If
* <errptr> is not NULL, it's set to the first invalid character on error.
*/
if (!budget)
return forwarded;
- /* Now we must ensure chn->to_forward sats below CHN_INFINITE_FORWARD,
+ /* Now we must ensure chn->to_forward stays below CHN_INFINITE_FORWARD,
* which also implies it won't overflow. It's less operations in 64-bit.
*/
bytes = (unsigned long long)chn->to_forward + budget;
* controls. The chn->o and to_forward pointers are updated. If the channel
* input is closed, -2 is returned. If there is not enough room left in the
* buffer, -1 is returned. Otherwise the number of bytes copied is returned
- * (1). Channel flag READ_PARTIAL is updated if some data can be transferred.
+ * (1). Channel flag CF_READ_EVENT is set if some data can be transferred.
*/
int ci_putchr(struct channel *chn, char c)
{
* input is closed, -2 is returned. If the block is too large for this buffer,
* -3 is returned. If there is not enough room left in the buffer, -1 is
* returned. Otherwise the number of bytes copied is returned (0 being a valid
- * number). Channel flag READ_PARTIAL is updated if some data can be
+ * number). Channel flag CF_READ_EVENT is set if some data can be
* transferred.
*/
int ci_putblk(struct channel *chn, const char *blk, int len)
htx_compression_buffer_init(struct htx *htx, struct buffer *out)
{
/* output stream requires at least 10 bytes for the gzip header, plus
- * at least 8 bytes for the gzip trailer (crc+len), plus a possible
- * plus at most 5 bytes per 32kB block and 2 bytes to close the stream.
+ * at least 8 bytes for the gzip trailer (crc+len), plus at most
+ * 5 bytes per 32kB block and 2 bytes to close the stream.
*/
if (htx_free_space(htx) < 20 + 5 * ((htx->data + 32767) >> 15))
return -1;
}
/* Produces an HTX message from an http reply. Depending on the http reply type,
- * a, errorfile, an raw file or a log-format string is used. On success, it
+ * an errorfile, a raw file or a log-format string is used. On success, it
* returns 0. If an error occurs -1 is returned. If it fails, this function only
* exits. It is the caller responsibility to do the cleanup.
*/
/* Find the block's position. First, we try to get the next position in
* the message, increasing the tail by one. If this position is not
* available with some holes, we try to defrag the blocks without
- * touching their paylood. If it is impossible, we fully defrag the
+ * touching their payload. If it is impossible, we fully defrag the
* message.
*/
tail = htx->tail + 1;
}
/* If possible, transfer HTX blocks from <src> to a large buffer. This function
- * allocate the small buffer and makes <dst> point on it. If <dst> is not empty
+ * allocates the large buffer and makes <dst> point on it. If <dst> is not empty
* or if <src> contains to many data, NULL is returned. If the allocation
* failed, NULL is returned. Otherwise <dst> is returned. <flags> instructs how
* the transfer must be performed.
};
/* Checks the first byte of a message to read the fixed header and extract the
- * packet type and flags. <parser> is supposed to point to the fix header byte.
+ * packet type and flags. <parser> is supposed to point to the fixed header byte.
*
* Fix header looks like:
* +-------+-----------+-----------+-----------+---------+----------+----------+---------+------------+
{
struct proxy *px = h1s->h1c->px;
- /* Don't update "Connection:" header in TUNNEL mode or if "Upgrage"
+ /* Don't update "Connection:" header in TUNNEL mode or if "Upgrade"
* token is found
*/
if (h1s->flags & H1S_F_WANT_TUN || h1m->flags & H1_MF_CONN_UPG)
static void h1_update_res_conn_value(struct h1s *h1s, struct h1m *h1m, struct ist *conn_val)
{
- /* Don't update "Connection:" header in TUNNEL mode or if "Upgrage"
+ /* Don't update "Connection:" header in TUNNEL mode or if "Upgrade"
* token is found
*/
if (h1s->flags & H1S_F_WANT_TUN || h1m->flags & H1_MF_CONN_UPG)
pmatch[i].rm_eo = matches[(i*2)+1];
continue;
}
- /* Set the unmatvh flag (-1). */
+ /* Set the unmatched flag (-1). */
pmatch[i].rm_so = -1;
pmatch[i].rm_eo = -1;
}
#endif
}
-/* This function apply regex. It take a "char *" ans length as input. The
+/* This function applies a regex. It takes a "char *" and length as input. The
* <subject> can be modified during the processing. If the function doesn't
* match, it returns false, else it returns true.
* When it is compiled with standard POSIX regex or PCRE, this function add
pmatch[i].rm_eo = matches[(i*2)+1];
continue;
}
- /* Set the unmatvh flag (-1). */
+ /* Set the unmatched flag (-1). */
pmatch[i].rm_so = -1;
pmatch[i].rm_eo = -1;
}
stats_fill_sv_computestate(sv, ref, &state);
}
- /* compue time values for later use */
+ /* compute time values for later use */
if (index == NULL || *index == ST_I_PX_QTIME ||
*index == ST_I_PX_CTIME || *index == ST_I_PX_RTIME ||
*index == ST_I_PX_TTIME) {