This patch updates most users of b->data to use b_orig().
if (l1 < max) {
*len1 = l1;
*len2 = max - l1;
- *blk2 = buf->data;
+ *blk2 = b_orig(buf);
return 2;
}
*len1 = max;
/* Normalizes a pointer after an addition */
static inline char *buffer_wrap_add(const struct buffer *buf, char *ptr)
{
- if (ptr - buf->size >= buf->data)
+ if (ptr - buf->size >= b_orig(buf))
ptr -= buf->size;
return ptr;
}
*/
static inline const char *buffer_pointer(const struct buffer *buf, const char *ptr)
{
- if (ptr < buf->data)
+ if (ptr < b_orig(buf))
ptr += buf->size;
- else if (ptr - buf->size >= buf->data)
+ else if (ptr - buf->size >= b_orig(buf))
ptr -= buf->size;
return ptr;
}
if (*p++ != *r.ptr++)
return -1;
if (unlikely(p == end))
- p = b->data;
+ p = b_orig(b);
}
return ist.len;
}
while (r.len--) {
*p++ = *r.ptr++;
if (unlikely(p == end))
- p = b->data;
+ p = b_orig(b);
}
return ist.len;
}
while (r.len--) {
*p++ = *r.ptr++;
if (unlikely(p == end))
- p = b->data;
+ p = b_orig(b);
}
return ist.len;
}
bytes++;
ptr++;
if (ptr >= b_wrap(buf))
- ptr = buf->data;
+ ptr = b_orig(buf);
}
if (bytes > stop - start)
if (c < 0) /* not a hex digit anymore */
break;
if (unlikely(++ptr >= end))
- ptr = buf->data;
+ ptr = b_orig(buf);
if (unlikely(chunk & 0xF8000000)) /* integer overflow will occur if result >= 2GB */
goto error;
chunk = (chunk << 4) + c;
while (HTTP_IS_SPHT(*ptr)) {
if (++ptr >= end)
- ptr = buf->data;
+ ptr = b_orig(buf);
if (--stop == 0)
return 0;
}
/* we now have a CR or an LF at ptr */
if (likely(*ptr == '\r')) {
if (++ptr >= end)
- ptr = buf->data;
+ ptr = b_orig(buf);
if (--stop == 0)
return 0;
}
if (*ptr != '\n')
goto error;
if (++ptr >= end)
- ptr = buf->data;
+ ptr = b_orig(buf);
--stop;
/* done */
break;
else if (likely(*ptr == ';')) {
/* chunk extension, ends at next CRLF */
if (++ptr >= end)
- ptr = buf->data;
+ ptr = b_orig(buf);
if (--stop == 0)
return 0;
while (!HTTP_IS_CRLF(*ptr)) {
if (++ptr >= end)
- ptr = buf->data;
+ ptr = b_orig(buf);
if (--stop == 0)
return 0;
}
delta = len - (end - pos);
- if (b_tail(b) + delta > b->data + b->size)
+ if (b_tail(b) + delta > b_wrap(b))
return 0; /* no space left */
if (b_data(b) &&
delta = len + 2;
- if (b_tail(b) + delta >= b->data + b->size)
+ if (b_tail(b) + delta >= b_wrap(b))
return 0; /* no space left */
if (b_data(b) &&
max = b_contig_space(chn->buf);
memcpy(ci_tail(chn), blk, MIN(len, max));
if (len > max)
- memcpy(chn->buf->data, blk + max, len - max);
+ memcpy(b_orig(chn->buf), blk + max, len - max);
chn->buf->i += len;
chn->total += len;
return 0;
}
- if (unlikely(chn->buf->p + chn->buf->i > chn->buf->data + chn->buf->size)) {
+ if (unlikely(chn->buf->p + chn->buf->i > b_wrap(chn->buf))) {
*blk1 = chn->buf->p;
- *len1 = chn->buf->data + chn->buf->size - chn->buf->p;
- *blk2 = chn->buf->data;
+ *len1 = b_wrap(chn->buf) - chn->buf->p;
+ *blk2 = b_orig(chn->buf);
*len2 = chn->buf->i - *len1;
return 2;
}
static inline __maybe_unused void h2_get_buf_bytes(void *dst, size_t bytes,
const struct buffer *b, int o)
{
- readv_bytes(dst, bytes, b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
+ readv_bytes(dst, bytes, b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
}
static inline __maybe_unused uint16_t h2_get_n16(const struct buffer *b, int o)
{
- return readv_n16(b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
+ return readv_n16(b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
}
static inline __maybe_unused uint32_t h2_get_n32(const struct buffer *b, int o)
{
- return readv_n32(b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
+ return readv_n32(b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
}
static inline __maybe_unused uint64_t h2_get_n64(const struct buffer *b, int o)
{
- return readv_n64(b_peek(b, o), b_wrap(b) - b_peek(b, o), b->data);
+ return readv_n64(b_peek(b, o), b_wrap(b) - b_peek(b, o), b_orig(b));
}
* EINTR too.
*/
while (count > 0) {
- /* first check if we have some room after p+i */
- try = buf->data + buf->size - (buf->p + buf->i);
- /* otherwise continue between data and p-o */
- if (try <= 0) {
- try = buf->p - (buf->data + buf->o);
- if (try <= 0)
- break;
- }
+ try = b_contig_space(buf);
+ if (!try)
+ break;
+
if (try > count)
try = count;
while (count > 0) {
int need_out = 0;
- /* first check if we have some room after p+i */
- try = buf->data + buf->size - (buf->p + buf->i);
- /* otherwise continue between data and p-o */
- if (try <= 0) {
- try = buf->p - (buf->data + buf->o);
- if (try <= 0)
- break;
- }
+ try = b_contig_space(buf);
+ if (!try)
+ break;
+
if (try > count)
try = count;
+
if (((conn->flags & (CO_FL_EARLY_SSL_HS | CO_FL_EARLY_DATA)) == CO_FL_EARLY_SSL_HS) &&
conn->tmp_early_data != -1) {
*b_tail(buf) = conn->tmp_early_data;
human_time(TICKS_TO_MS(strm->req.wex - now_ms),
TICKS_TO_MS(1000)) : "<NEVER>",
strm->req.buf,
- strm->req.buf->data, (unsigned int)strm->req.buf->o,
- (int)(strm->req.buf->p - strm->req.buf->data),
- strm->txn ? strm->txn->req.next : 0, (unsigned int)strm->req.buf->i,
+ b_orig(strm->req.buf), (unsigned int)co_data(&strm->req),
+ (int)(strm->req.buf->p - b_orig(strm->req.buf)),
+ strm->txn ? strm->txn->req.next : 0, (unsigned int)ci_data(&strm->req),
(unsigned int)strm->req.buf->size);
chunk_appendf(&trash,
human_time(TICKS_TO_MS(strm->res.wex - now_ms),
TICKS_TO_MS(1000)) : "<NEVER>",
strm->res.buf,
- strm->res.buf->data, (unsigned int)strm->res.buf->o,
- (int)(strm->res.buf->p - strm->res.buf->data),
- strm->txn ? strm->txn->rsp.next : 0, (unsigned int)strm->res.buf->i,
+ b_orig(strm->res.buf), (unsigned int)co_data(&strm->res),
+ (int)(strm->res.buf->p - b_orig(strm->res.buf)),
+ strm->txn ? strm->txn->rsp.next : 0, (unsigned int)ci_data(&strm->res),
(unsigned int)strm->res.buf->size);
if (ci_putchk(si_ic(si), &trash) == -1) {