Lines Matching refs:len

479 …_chunk(chunkqueue * const restrict cq, const buffer * const restrict fn, off_t offset, off_t len) {  in __attribute_nonnull__()
484 c->file.length = offset + len; in __attribute_nonnull__()
485 cq->bytes_in += len; in __attribute_nonnull__()
497 …hunkqueue * const restrict cq, const buffer * const restrict fn, int fd, off_t offset, off_t len) { in chunkqueue_append_file_fd() argument
498 if (len > 0) { in chunkqueue_append_file_fd()
499 (chunkqueue_append_file_chunk(cq, fn, offset, len))->file.fd = fd; in chunkqueue_append_file_fd()
506 …d_file(chunkqueue * const restrict cq, const buffer * const restrict fn, off_t offset, off_t len) { in chunkqueue_append_file() argument
507 if (len > 0) { in chunkqueue_append_file()
508 chunkqueue_append_file_chunk(cq, fn, offset, len); in chunkqueue_append_file()
513 …end_mem_extend_chunk(chunkqueue * const restrict cq, const char * const restrict mem, size_t len) { in chunkqueue_append_mem_extend_chunk() argument
515 if (0 == len) return 1; in chunkqueue_append_mem_extend_chunk()
517 && buffer_string_space(c->mem) >= len) { in chunkqueue_append_mem_extend_chunk()
518 buffer_append_string_len(c->mem, mem, len); in chunkqueue_append_mem_extend_chunk()
519 cq->bytes_in += len; in chunkqueue_append_mem_extend_chunk()
528 const size_t len = buffer_clen(mem); in chunkqueue_append_buffer() local
529 if (len < 1024 && chunkqueue_append_mem_extend_chunk(cq, mem->ptr, len)) { in chunkqueue_append_buffer()
535 cq->bytes_in += len; in chunkqueue_append_buffer()
540 …hunkqueue_append_mem(chunkqueue * const restrict cq, const char * const restrict mem, size_t len) { in chunkqueue_append_mem() argument
542 if (len < chunk_buf_sz && chunkqueue_append_mem_extend_chunk(cq, mem, len)) in chunkqueue_append_mem()
545 c = chunkqueue_append_mem_chunk(cq, len+1); in chunkqueue_append_mem()
546 cq->bytes_in += len; in chunkqueue_append_mem()
547 buffer_copy_string_len(c->mem, mem, len); in chunkqueue_append_mem()
551 …queue_append_mem_min(chunkqueue * const restrict cq, const char * const restrict mem, size_t len) { in chunkqueue_append_mem_min() argument
553 if (len < chunk_buf_sz && chunkqueue_append_mem_extend_chunk(cq, mem, len)) in chunkqueue_append_mem_min()
556 c = chunk_init_sz(len+1); in chunkqueue_append_mem_min()
558 cq->bytes_in += len; in chunkqueue_append_mem_min()
559 buffer_copy_string_len(c->mem, mem, len); in chunkqueue_append_mem_min()
612 char * chunkqueue_get_memory(chunkqueue * const restrict cq, size_t * const restrict len) { in chunkqueue_get_memory() argument
613 size_t sz = *len ? *len : (chunk_buf_sz >> 1); in chunkqueue_get_memory()
620 *len = avail; in chunkqueue_get_memory()
628 *len = buffer_string_space(b); in chunkqueue_get_memory()
632 void chunkqueue_use_memory(chunkqueue * const restrict cq, chunk *ckpt, size_t len) { in chunkqueue_use_memory() argument
635 if (__builtin_expect( (len > 0), 1)) { in chunkqueue_use_memory()
636 buffer_commit(b, len); in chunkqueue_use_memory()
637 cq->bytes_in += len; in chunkqueue_use_memory()
639 || len > buffer_string_space(ckpt->mem)) return; in chunkqueue_use_memory()
653 void chunkqueue_update_file(chunkqueue * const restrict cq, chunk *c, off_t len) { in chunkqueue_update_file() argument
655 c->file.length += len; in chunkqueue_update_file()
656 cq->bytes_in += len; in chunkqueue_update_file()
698 …ial_file_chunk(chunkqueue * const restrict dest, const chunk * const restrict c, const off_t len) { in chunkqueue_steal_partial_file_chunk() argument
699 chunkqueue_append_file(dest, c->mem, c->offset, len); in chunkqueue_steal_partial_file_chunk()
703 void chunkqueue_steal(chunkqueue * const restrict dest, chunkqueue * const restrict src, off_t len)… in chunkqueue_steal() argument
713 if (len >= clen) { in chunkqueue_steal()
729 chunkqueue_append_mem(dest, c->mem->ptr + c->offset, len); in chunkqueue_steal()
733 chunkqueue_steal_partial_file_chunk(dest, c, len); in chunkqueue_steal()
737 c->offset += len; in chunkqueue_steal()
738 clen = len; in chunkqueue_steal()
742 } while ((len -= clen)); in chunkqueue_steal()
745 static int chunkqueue_get_append_mkstemp(buffer * const b, const char *path, const uint32_t len) { in chunkqueue_get_append_mkstemp() argument
746 buffer_copy_path_len2(b,path,len,CONST_STR_LEN("lighttpd-upload-XXXXXX")); in chunkqueue_get_append_mkstemp()
867 …mpfile(chunkqueue * const restrict dest, const char * restrict mem, size_t len, log_error_st * con… in chunkqueue_append_mem_to_tempfile() argument
892 const ssize_t written =pwrite(dst_c->file.fd, mem, len, dst_c->file.length); in chunkqueue_append_mem_to_tempfile()
895 const ssize_t written = write(dst_c->file.fd, mem, len); in chunkqueue_append_mem_to_tempfile()
898 if ((size_t) written == len) { in chunkqueue_append_mem_to_tempfile()
899 dst_c->file.length += len; in chunkqueue_append_mem_to_tempfile()
900 dest->bytes_in += len; in chunkqueue_append_mem_to_tempfile()
907 len -= (size_t)written; in chunkqueue_append_mem_to_tempfile()
913 } while (len); in chunkqueue_append_mem_to_tempfile()
941 …e(chunkqueue * const restrict dest, chunkqueue * const restrict src, off_t len, log_error_st * con… in chunkqueue_append_cqmem_to_tempfile() argument
972 if (clen > len) clen = len; in chunkqueue_append_cqmem_to_tempfile()
975 len -= clen; in chunkqueue_append_cqmem_to_tempfile()
977 if (0 == len) break; in chunkqueue_append_cqmem_to_tempfile()
1024 …n_pipe_tempfile(chunkqueue * const restrict cq, const int fd, unsigned int len, log_error_st * con… in chunkqueue_append_drain_pipe_tempfile() argument
1039 } while ((len -= (unsigned int)rd)); in chunkqueue_append_drain_pipe_tempfile()
1041 if (0 == len) in chunkqueue_append_drain_pipe_tempfile()
1053 …e_pipe_tempfile(chunkqueue * const restrict cq, const int fd, unsigned int len, log_error_st * con… in chunkqueue_append_splice_pipe_tempfile() argument
1069 ssize_t wr = splice(fd, NULL, c->file.fd, &off, len, in chunkqueue_append_splice_pipe_tempfile()
1072 if (__builtin_expect(((size_t)wr == len), 1)) { in chunkqueue_append_splice_pipe_tempfile()
1073 c->file.length += len; in chunkqueue_append_splice_pipe_tempfile()
1074 cq->bytes_in += len; in chunkqueue_append_splice_pipe_tempfile()
1075 return total + len; in chunkqueue_append_splice_pipe_tempfile()
1082 len -= (size_t)wr; in chunkqueue_append_splice_pipe_tempfile()
1101 wr = chunkqueue_append_drain_pipe_tempfile(cq, fd, len, errh); in chunkqueue_append_splice_pipe_tempfile()
1102 return (0 == wr) ? total + (ssize_t)len : wr; in chunkqueue_append_splice_pipe_tempfile()
1109 } while (len); in chunkqueue_append_splice_pipe_tempfile()
1146 …e_sock_tempfile(chunkqueue * const restrict cq, const int fd, unsigned int len, log_error_st * con… in chunkqueue_append_splice_sock_tempfile() argument
1153 ssize_t wr = splice(fd, NULL, pipes[1], NULL, len, in chunkqueue_append_splice_sock_tempfile()
1157 len = (unsigned int)wr; in chunkqueue_append_splice_sock_tempfile()
1160 wr = chunkqueue_append_splice_pipe_tempfile(cq, pipes[0], len, errh); in chunkqueue_append_splice_sock_tempfile()
1168 …s(chunkqueue * const restrict dest, chunkqueue * const restrict src, off_t len, log_error_st * con… in chunkqueue_steal_with_tempfiles() argument
1179 clen = chunkqueue_append_cqmem_to_tempfile(dest, src, len, errh); in chunkqueue_steal_with_tempfiles()
1185 if (len < clen) clen = len; in chunkqueue_steal_with_tempfiles()
1192 if (len < clen) clen = len; in chunkqueue_steal_with_tempfiles()
1211 } while ((len -= clen)); in chunkqueue_steal_with_tempfiles()
1216 …e_append_cq_range (chunkqueue * const dst, const chunkqueue * const src, off_t offset, off_t len) { in chunkqueue_append_cq_range() argument
1221 for (const chunk *c = src->first; len > 0 && c != NULL; c = c->next) { in chunkqueue_append_cq_range()
1229 if (len < clen) clen = len; in chunkqueue_append_cq_range()
1230 len -= clen; in chunkqueue_append_cq_range()
1245 void chunkqueue_mark_written(chunkqueue *cq, off_t len) { in chunkqueue_mark_written() argument
1246 cq->bytes_out += len; in chunkqueue_mark_written()
1250 if (len >= c_len) { /* chunk got finished */ in chunkqueue_mark_written()
1253 len -= c_len; in chunkqueue_mark_written()
1257 c->offset += len; in chunkqueue_mark_written()
1292 size_t len = buffer_clen(b) - c->offset; in chunkqueue_compact_mem_offset() local
1293 memmove(b->ptr, b->ptr+c->offset, len); in chunkqueue_compact_mem_offset()
1295 buffer_truncate(b, len); in chunkqueue_compact_mem_offset()
1303 size_t len = buffer_clen(b) - c->offset; in chunkqueue_compact_mem() local
1304 if (len >= clen) return; in chunkqueue_compact_mem()
1306 if (buffer_string_space(b) < clen - len) in chunkqueue_compact_mem()
1311 buffer_append_string_len(b, c->mem->ptr + c->offset, len); in chunkqueue_compact_mem()
1318 for (chunk *fc = c; ((clen -= len) && (c = fc->next)); ) { in chunkqueue_compact_mem()
1319 len = buffer_clen(c->mem) - c->offset; in chunkqueue_compact_mem()
1320 if (len > clen) { in chunkqueue_compact_mem()
1325 buffer_append_string_len(b, c->mem->ptr + c->offset, len); in chunkqueue_compact_mem()
1367 chunkqueue_write_data (const int fd, const void *buf, size_t len) in chunkqueue_write_data() argument
1370 if (len) in chunkqueue_write_data()
1371 do { wr = write(fd, buf, len); } while (-1 == wr && errno == EINTR); in chunkqueue_write_data()
1385 const off_t len = c->file.length - c->offset; in chunkqueue_write_chunk_file_intermed() local
1386 uint32_t dlen = len < (off_t)sizeof(buf) ? (uint32_t)len : sizeof(buf); in chunkqueue_write_chunk_file_intermed()
1409 const off_t len = c->file.length - c->offset; in chunkqueue_write_chunk_file() local
1410 if (0 == len) return 0; /*(sanity check)*/ in chunkqueue_write_chunk_file()
1418 sendfile(fd, c->file.fd, &offset, len < INT32_MAX ? len : INT32_MAX); in chunkqueue_write_chunk_file()
1425 chunkqueue_chunk_file_view(c, len, errh); in chunkqueue_write_chunk_file()
1429 len <= mmap_avail ? len : mmap_avail); in chunkqueue_write_chunk_file()
1441 const size_t len = buffer_clen(c->mem) - (size_t)c->offset; in chunkqueue_write_chunk_mem() local
1442 return chunkqueue_write_data(fd, buf, len); in chunkqueue_write_chunk_mem()
1469 const size_t len = (size_t)(c->file.length - c->offset); in chunkqueue_write_chunk_to_pipe() local
1471 if (__builtin_expect( (0 == len), 0)) return 0; in chunkqueue_write_chunk_to_pipe()
1473 ? splice(c->file.fd, &abs_offset, fd, NULL, len, SPLICE_F_NONBLOCK) in chunkqueue_write_chunk_to_pipe()
1504 off_t len = filec->file.length - filec->offset; in chunkqueue_small_resp_optim() local
1505 if ((size_t)len > buffer_string_space(c->mem)) { in chunkqueue_small_resp_optim()
1506 c->next = chunk_acquire((size_t)len+1); in chunkqueue_small_resp_optim()
1516 char * const ptr = buffer_extend(c->mem, len); in chunkqueue_small_resp_optim()
1518 rd = chunk_file_pread(filec->file.fd, ptr+offset, (size_t)len, in chunkqueue_small_resp_optim()
1520 } while (rd > 0 && (offset += rd, len -= rd)); in chunkqueue_small_resp_optim()
1522 if (__builtin_expect( (0 == len), 1)) in chunkqueue_small_resp_optim()
1541 chunk_setjmp_memcpy_cb (void *dst, const void *src, off_t len)
1544 memcpy(dst, src, (size_t)len);
1545 return len;
1580 off_t len = c->file.length - c->offset; in chunkqueue_peek_data() local
1581 if (len > (off_t)space) in chunkqueue_peek_data()
1582 len = (off_t)space; in chunkqueue_peek_data()
1583 if (__builtin_expect( (0 == len), 0)) in chunkqueue_peek_data()
1602 ? chunkqueue_chunk_file_view(c, len, errh) in chunkqueue_peek_data()
1604 if (cfv && chunk_file_view_dlen(cfv, c->offset) >= len) { in chunkqueue_peek_data()
1609 data_in+*dlen, mdata, len) < 0) { in chunkqueue_peek_data()
1616 memcpy(data_in+*dlen, mdata, (size_t)len); in chunkqueue_peek_data()
1619 *dlen += (uint32_t)len; in chunkqueue_peek_data()
1626 (size_t)len, c->offset); in chunkqueue_peek_data()
1665 uint32_t len = dlen; in chunkqueue_read_data() local
1666 if (chunkqueue_peek_data(cq, &ptr, &len, errh) < 0 || len != dlen) in chunkqueue_read_data()
1668 if (data != ptr) memcpy(data, ptr, len); in chunkqueue_read_data()
1669 chunkqueue_mark_written(cq, len); in chunkqueue_read_data()