mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
event_warn mmap format
This commit is contained in:
parent
9e89a40748
commit
5fbc00a3cc
23
buffer.c
23
buffer.c
@ -3077,6 +3077,14 @@ evbuffer_file_segment_materialize(struct evbuffer_file_segment *seg)
|
|||||||
#if defined(EVENT__HAVE_MMAP)
|
#if defined(EVENT__HAVE_MMAP)
|
||||||
if (!(flags & EVBUF_FS_DISABLE_MMAP)) {
|
if (!(flags & EVBUF_FS_DISABLE_MMAP)) {
|
||||||
off_t offset_rounded = 0, offset_leftover = 0;
|
off_t offset_rounded = 0, offset_leftover = 0;
|
||||||
|
int mmap_flags =
|
||||||
|
#ifdef MAP_NOCACHE
|
||||||
|
MAP_NOCACHE | /* ??? */
|
||||||
|
#endif
|
||||||
|
#ifdef MAP_FILE
|
||||||
|
MAP_FILE |
|
||||||
|
#endif
|
||||||
|
MAP_PRIVATE;
|
||||||
void *mapped;
|
void *mapped;
|
||||||
if (offset) {
|
if (offset) {
|
||||||
/* mmap implementations don't generally like us
|
/* mmap implementations don't generally like us
|
||||||
@ -3092,18 +3100,11 @@ evbuffer_file_segment_materialize(struct evbuffer_file_segment *seg)
|
|||||||
#else
|
#else
|
||||||
mapped = mmap(NULL, length + offset_leftover,
|
mapped = mmap(NULL, length + offset_leftover,
|
||||||
#endif
|
#endif
|
||||||
PROT_READ,
|
PROT_READ, mmap_flags, fd, offset_rounded);
|
||||||
#ifdef MAP_NOCACHE
|
|
||||||
MAP_NOCACHE | /* ??? */
|
|
||||||
#endif
|
|
||||||
#ifdef MAP_FILE
|
|
||||||
MAP_FILE |
|
|
||||||
#endif
|
|
||||||
MAP_PRIVATE,
|
|
||||||
fd, offset_rounded);
|
|
||||||
if (mapped == MAP_FAILED) {
|
if (mapped == MAP_FAILED) {
|
||||||
event_warn("%s: mmap(%d, %d, %zu) failed",
|
event_warn("%s: mmap(NULL, %zu, %d, %d, %d, %lld) failed", __func__,
|
||||||
__func__, fd, 0, (size_t)(offset + length));
|
(size_t)(length + offset_leftover), PROT_READ, mmap_flags, fd,
|
||||||
|
(long long)offset_rounded);
|
||||||
} else {
|
} else {
|
||||||
seg->mapping = mapped;
|
seg->mapping = mapped;
|
||||||
seg->contents = (char*)mapped+offset_leftover;
|
seg->contents = (char*)mapped+offset_leftover;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user