diff --git a/include/lighttpd/chunk.h b/include/lighttpd/chunk.h index 9e4e72c..36c6ae0 100644 --- a/include/lighttpd/chunk.h +++ b/include/lighttpd/chunk.h @@ -83,9 +83,9 @@ LI_API liHandlerResult li_chunkfile_open(liVRequest *vr, liChunkFile *cf); * chunk iterator * ******************/ -INLINE liChunk* chunkiter_chunk(liChunkIter iter); -INLINE gboolean chunkiter_next(liChunkIter *iter); -INLINE goffset chunkiter_length(liChunkIter iter); +INLINE liChunk* li_chunkiter_chunk(liChunkIter iter); +INLINE gboolean li_chunkiter_next(liChunkIter *iter); +INLINE goffset li_chunkiter_length(liChunkIter iter); /* get the data from a chunk; easy in case of a STRING_CHUNK, * but needs to do io in case of FILE_CHUNK; the data is _not_ marked as "done" @@ -102,7 +102,7 @@ LI_API liHandlerResult li_chunkiter_read_mmap(liVRequest *vr, liChunkIter iter, * chunk * ******************/ -INLINE goffset chunk_length(liChunk *c); +INLINE goffset li_chunk_length(liChunk *c); /****************** * cqlimit * @@ -172,9 +172,9 @@ LI_API goffset li_chunkqueue_skip_all(liChunkQueue *cq); /* if the chunk an iterator refers gets stolen/skipped/..., * the iterator isn't valid anymore */ -INLINE liChunkIter chunkqueue_iter(liChunkQueue *cq); +INLINE liChunkIter li_chunkqueue_iter(liChunkQueue *cq); -INLINE liChunk* chunkqueue_first_chunk(liChunkQueue *cq); +INLINE liChunk* li_chunkqueue_first_chunk(liChunkQueue *cq); LI_API gboolean li_chunkqueue_extract_to(liVRequest *vr, liChunkQueue *cq, goffset len, GString *dest); LI_API gboolean li_chunkqueue_extract_to_bytearr(liVRequest *vr, liChunkQueue *cq, goffset len, GByteArray *dest); @@ -183,21 +183,21 @@ LI_API gboolean li_chunkqueue_extract_to_bytearr(liVRequest *vr, liChunkQueue *c * Inline functions * ********************/ -INLINE liChunk* chunkiter_chunk(liChunkIter iter) { +INLINE liChunk* li_chunkiter_chunk(liChunkIter iter) { if (!iter.element) return NULL; return (liChunk*) iter.element->data; } -INLINE gboolean chunkiter_next(liChunkIter *iter) { +INLINE gboolean li_chunkiter_next(liChunkIter *iter) { if (!iter || !iter->element) return FALSE; return NULL != (iter->element = g_list_next(iter->element)); } -INLINE goffset chunkiter_length(liChunkIter iter) { - return chunk_length(chunkiter_chunk(iter)); +INLINE goffset li_chunkiter_length(liChunkIter iter) { + return li_chunk_length(li_chunkiter_chunk(iter)); } -INLINE goffset chunk_length(liChunk *c) { +INLINE goffset li_chunk_length(liChunk *c) { if (!c) return 0; switch (c->type) { case UNUSED_CHUNK: @@ -212,13 +212,13 @@ INLINE goffset chunk_length(liChunk *c) { return 0; } -INLINE liChunkIter chunkqueue_iter(liChunkQueue *cq) { +INLINE liChunkIter li_chunkqueue_iter(liChunkQueue *cq) { liChunkIter i; i.element = g_queue_peek_head_link(cq->queue); return i; } -INLINE liChunk* chunkqueue_first_chunk(liChunkQueue *cq) { +INLINE liChunk* li_chunkqueue_first_chunk(liChunkQueue *cq) { return (liChunk*) g_queue_peek_head(cq->queue); } diff --git a/include/lighttpd/chunk_parser.h b/include/lighttpd/chunk_parser.h index cbd29a8..ce0abe1 100644 --- a/include/lighttpd/chunk_parser.h +++ b/include/lighttpd/chunk_parser.h @@ -34,19 +34,19 @@ LI_API void li_chunk_parser_done(liChunkParserCtx *ctx, goffset len); LI_API gboolean li_chunk_extract_to(liVRequest *vr, liChunkParserMark from, liChunkParserMark to, GString *dest); LI_API GString* li_chunk_extract(liVRequest *vr, liChunkParserMark from, liChunkParserMark to); -INLINE liChunkParserMark chunk_parser_getmark(liChunkParserCtx *ctx, const char *fpc); +INLINE liChunkParserMark li_chunk_parser_getmark(liChunkParserCtx *ctx, const char *fpc); /******************** * Inline functions * ********************/ -INLINE liChunkParserMark chunk_parser_getmark(liChunkParserCtx *ctx, const char *fpc) { +INLINE liChunkParserMark li_chunk_parser_getmark(liChunkParserCtx *ctx, const char *fpc) { liChunkParserMark m; m.ci = ctx->curi; m.pos = ctx->start + fpc - ctx->buf; return m; } -#define GETMARK(FPC) (chunk_parser_getmark(&ctx->chunk_ctx, FPC)) +#define GETMARK(FPC) (li_chunk_parser_getmark(&ctx->chunk_ctx, FPC)) #endif diff --git a/src/main/chunk.c b/src/main/chunk.c index c71126a..bfbc3b1 100644 --- a/src/main/chunk.c +++ b/src/main/chunk.c @@ -84,14 +84,14 @@ liHandlerResult li_chunkfile_open(liVRequest *vr, liChunkFile *cf) { * may return HANDLER_GO_ON, HANDLER_ERROR */ liHandlerResult li_chunkiter_read(liVRequest *vr, liChunkIter iter, off_t start, off_t length, char **data_start, off_t *data_len) { - liChunk *c = chunkiter_chunk(iter); + liChunk *c = li_chunkiter_chunk(iter); off_t we_have, our_start; liHandlerResult res = LI_HANDLER_GO_ON; if (!c) return LI_HANDLER_ERROR; if (!data_start || !data_len) return LI_HANDLER_ERROR; - we_have = chunk_length(c) - start; + we_have = li_chunk_length(c) - start; if (length > we_have) length = we_have; if (length <= 0) return LI_HANDLER_ERROR; @@ -159,7 +159,7 @@ read_chunk: * as accessing mmap()-ed areas may result in SIGBUS, you have to handle that signal somehow. */ liHandlerResult li_chunkiter_read_mmap(liVRequest *vr, liChunkIter iter, off_t start, off_t length, char **data_start, off_t *data_len) { - liChunk *c = chunkiter_chunk(iter); + liChunk *c = li_chunkiter_chunk(iter); off_t we_want, we_have, our_start, our_offset; liHandlerResult res = LI_HANDLER_GO_ON; int mmap_errno = 0; @@ -167,7 +167,7 @@ liHandlerResult li_chunkiter_read_mmap(liVRequest *vr, liChunkIter iter, off_t s if (!c) return LI_HANDLER_ERROR; if (!data_start || !data_len) return LI_HANDLER_ERROR; - we_have = chunk_length(c) - start; + we_have = li_chunk_length(c) - start; if (length > we_have) length = we_have; if (length <= 0) return LI_HANDLER_ERROR; @@ -586,8 +586,8 @@ goffset li_chunkqueue_steal_len(liChunkQueue *out, liChunkQueue *in, goffset len goffset bytes = 0, meminbytes = 0, memoutbytes = 0; goffset we_have; - while ( (NULL != (c = chunkqueue_first_chunk(in))) && length > 0 ) { - we_have = chunk_length(c); + while ( (NULL != (c = li_chunkqueue_first_chunk(in))) && length > 0 ) { + we_have = li_chunk_length(c); if (!we_have) { /* remove empty chunks */ if (c->type == STRING_CHUNK) meminbytes -= c->str->len; else if (c->type == MEM_CHUNK) meminbytes -= c->mem->len; @@ -700,7 +700,7 @@ goffset li_chunkqueue_steal_chunk(liChunkQueue *out, liChunkQueue *in) { g_queue_push_tail_link(out->queue, l); c = (liChunk*) l->data; - length = chunk_length(c); + length = li_chunk_length(c); in->bytes_out += length; in->length -= length; out->bytes_in += length; @@ -723,7 +723,7 @@ goffset li_chunkqueue_skip(liChunkQueue *cq, goffset length) { goffset bytes = 0; goffset we_have; - while ( (NULL != (c = chunkqueue_first_chunk(cq))) && (0 == (we_have = chunk_length(c)) || length > 0) ) { + while ( (NULL != (c = li_chunkqueue_first_chunk(cq))) && (0 == (we_have = li_chunk_length(c)) || length > 0) ) { if (we_have <= length) { /* skip (delete) complete chunk */ if (c->type == STRING_CHUNK) cqlimit_update(cq, - (goffset)c->str->len); @@ -762,11 +762,11 @@ gboolean li_chunkqueue_extract_to(liVRequest *vr, liChunkQueue *cq, goffset len, g_string_set_size(dest, 0); if (len > cq->length) return FALSE; - ci = chunkqueue_iter(cq); + ci = li_chunkqueue_iter(cq); while (len > 0) { coff = 0; - clen = chunkiter_length(ci); + clen = li_chunkiter_length(ci); while (coff < clen) { gchar *buf; off_t we_have; @@ -776,7 +776,7 @@ gboolean li_chunkqueue_extract_to(liVRequest *vr, liChunkQueue *cq, goffset len, len -= we_have; if (len <= 0) return TRUE; } - chunkiter_next(&ci); + li_chunkiter_next(&ci); } return TRUE; @@ -795,11 +795,11 @@ gboolean li_chunkqueue_extract_to_bytearr(liVRequest *vr, liChunkQueue *cq, goff g_byte_array_set_size(dest, len); g_byte_array_set_size(dest, 0); - ci = chunkqueue_iter(cq); + ci = li_chunkqueue_iter(cq); while (len > 0) { coff = 0; - clen = chunkiter_length(ci); + clen = li_chunkiter_length(ci); while (coff < clen) { gchar *buf; off_t we_have; @@ -809,7 +809,7 @@ gboolean li_chunkqueue_extract_to_bytearr(liVRequest *vr, liChunkQueue *cq, goff len -= we_have; if (len <= 0) return TRUE; } - chunkiter_next(&ci); + li_chunkiter_next(&ci); } return TRUE; diff --git a/src/main/chunk_parser.c b/src/main/chunk_parser.c index a59ace3..f9d926c 100644 --- a/src/main/chunk_parser.c +++ b/src/main/chunk_parser.c @@ -16,7 +16,7 @@ void li_chunk_parser_reset(liChunkParserCtx *ctx) { liHandlerResult li_chunk_parser_prepare(liChunkParserCtx *ctx) { if (NULL == ctx->curi.element) { - ctx->curi = chunkqueue_iter(ctx->cq); + ctx->curi = li_chunkqueue_iter(ctx->cq); if (NULL == ctx->curi.element) return LI_HANDLER_WAIT_FOR_EVENT; } return LI_HANDLER_GO_ON; @@ -28,10 +28,10 @@ liHandlerResult li_chunk_parser_next(liVRequest *vr, liChunkParserCtx *ctx, char if (NULL == ctx->curi.element) return LI_HANDLER_WAIT_FOR_EVENT; - while (ctx->start >= (l = chunkiter_length(ctx->curi))) { + while (ctx->start >= (l = li_chunkiter_length(ctx->curi))) { liChunkIter i = ctx->curi; /* Wait at the end of the last chunk if it gets extended */ - if (!chunkiter_next(&i)) return LI_HANDLER_WAIT_FOR_EVENT; + if (!li_chunkiter_next(&i)) return LI_HANDLER_WAIT_FOR_EVENT; ctx->curi = i; ctx->start -= l; } @@ -57,8 +57,8 @@ gboolean li_chunk_extract_to(liVRequest *vr, liChunkParserMark from, liChunkPars g_string_set_size(dest, 0); - for ( i = from; i.ci.element != to.ci.element; chunkiter_next(&i.ci) ) { - goffset len = chunkiter_length(i.ci); + for ( i = from; i.ci.element != to.ci.element; li_chunkiter_next(&i.ci) ) { + goffset len = li_chunkiter_length(i.ci); while (i.pos < len) { char *buf; off_t we_have; diff --git a/src/main/network_sendfile.c b/src/main/network_sendfile.c index dc8722f..98670b4 100644 --- a/src/main/network_sendfile.c +++ b/src/main/network_sendfile.c @@ -161,9 +161,9 @@ static liNetworkStatus network_backend_sendfile(liVRequest *vr, int fd, liChunkQ if (0 == cq->length) return LI_NETWORK_STATUS_FATAL_ERROR; do { - ci = chunkqueue_iter(cq); + ci = li_chunkqueue_iter(cq); - if (FILE_CHUNK != (c = chunkiter_chunk(ci))->type) { + if (FILE_CHUNK != (c = li_chunkiter_chunk(ci))->type) { return did_write_something ? LI_NETWORK_STATUS_SUCCESS : LI_NETWORK_STATUS_FATAL_ERROR; } @@ -222,7 +222,7 @@ liNetworkStatus li_network_write_sendfile(liVRequest *vr, int fd, liChunkQueue * if (cq->length == 0) return LI_NETWORK_STATUS_FATAL_ERROR; do { - switch (chunkqueue_first_chunk(cq)->type) { + switch (li_chunkqueue_first_chunk(cq)->type) { case MEM_CHUNK: case STRING_CHUNK: LI_NETWORK_FALLBACK(li_network_backend_writev, write_max); diff --git a/src/main/network_write.c b/src/main/network_write.c index 09706c1..85d1cbc 100644 --- a/src/main/network_write.c +++ b/src/main/network_write.c @@ -13,7 +13,7 @@ liNetworkStatus li_network_backend_write(liVRequest *vr, int fd, liChunkQueue *c if (0 == cq->length) return did_write_something ? LI_NETWORK_STATUS_SUCCESS : LI_NETWORK_STATUS_FATAL_ERROR; - ci = chunkqueue_iter(cq); + ci = li_chunkqueue_iter(cq); /* TODO: handle SIGBUS */ switch (li_chunkiter_read_mmap(vr, ci, 0, blocksize, &block_data, &block_len)) { case LI_HANDLER_GO_ON: diff --git a/src/main/network_writev.c b/src/main/network_writev.c index d561d93..3a7a964 100644 --- a/src/main/network_writev.c +++ b/src/main/network_writev.c @@ -38,9 +38,9 @@ liNetworkStatus li_network_backend_writev(liVRequest *vr, int fd, liChunkQueue * if (0 == cq->length) goto cleanup; /* FATAL ERROR */ do { - ci = chunkqueue_iter(cq); + ci = li_chunkqueue_iter(cq); - if (STRING_CHUNK != (c = chunkiter_chunk(ci))->type && MEM_CHUNK != c->type) { + if (STRING_CHUNK != (c = li_chunkiter_chunk(ci))->type && MEM_CHUNK != c->type) { res = did_write_something ? LI_NETWORK_STATUS_SUCCESS : LI_NETWORK_STATUS_FATAL_ERROR; goto cleanup; } @@ -48,7 +48,7 @@ liNetworkStatus li_network_backend_writev(liVRequest *vr, int fd, liChunkQueue * we_have = 0; do { guint i = chunks->len; - off_t len = chunk_length(c); + off_t len = li_chunk_length(c); struct iovec *v; g_array_set_size(chunks, i + 1); v = &g_array_index(chunks, struct iovec, i); @@ -60,8 +60,8 @@ liNetworkStatus li_network_backend_writev(liVRequest *vr, int fd, liChunkQueue * v->iov_len = len; we_have += len; } while (we_have < *write_max && - chunkiter_next(&ci) && - (STRING_CHUNK == (c = chunkiter_chunk(ci))->type || MEM_CHUNK == c->type) && + li_chunkiter_next(&ci) && + (STRING_CHUNK == (c = li_chunkiter_chunk(ci))->type || MEM_CHUNK == c->type) && chunks->len < UIO_MAXIOV); while (-1 == (r = writev(fd, (struct iovec*) chunks->data, chunks->len))) { @@ -114,7 +114,7 @@ cleanup: liNetworkStatus li_network_write_writev(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max) { if (cq->length == 0) return LI_NETWORK_STATUS_FATAL_ERROR; do { - switch (chunkqueue_first_chunk(cq)->type) { + switch (li_chunkqueue_first_chunk(cq)->type) { case STRING_CHUNK: LI_NETWORK_FALLBACK(li_network_backend_writev, write_max); break; diff --git a/src/modules/mod_cache_disk_etag.c b/src/modules/mod_cache_disk_etag.c index 0620d42..a95546b 100644 --- a/src/modules/mod_cache_disk_etag.c +++ b/src/modules/mod_cache_disk_etag.c @@ -154,7 +154,7 @@ static liHandlerResult cache_etag_filter_miss(liVRequest *vr, liFilter *f) { ssize_t res; gchar *buf; off_t buflen; - liChunkIter citer = chunkqueue_iter(f->in); + liChunkIter citer = li_chunkqueue_iter(f->in); UNUSED(vr); if (0 == f->in->length) return LI_HANDLER_GO_ON; diff --git a/src/modules/mod_openssl.c b/src/modules/mod_openssl.c index b1ae121..2953e8d 100644 --- a/src/modules/mod_openssl.c +++ b/src/modules/mod_openssl.c @@ -98,7 +98,7 @@ static liNetworkStatus openssl_con_write(liConnection *con, goffset write_max) { if (0 == cq->length) return LI_NETWORK_STATUS_SUCCESS; - ci = chunkqueue_iter(cq); + ci = li_chunkqueue_iter(cq); switch (li_chunkiter_read(con->mainvr, ci, 0, blocksize, &block_data, &block_len)) { case LI_HANDLER_GO_ON: break;