mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +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 (!(flags & EVBUF_FS_DISABLE_MMAP)) {
|
||||
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;
|
||||
if (offset) {
|
||||
/* mmap implementations don't generally like us
|
||||
@ -3092,18 +3100,11 @@ evbuffer_file_segment_materialize(struct evbuffer_file_segment *seg)
|
||||
#else
|
||||
mapped = mmap(NULL, length + offset_leftover,
|
||||
#endif
|
||||
PROT_READ,
|
||||
#ifdef MAP_NOCACHE
|
||||
MAP_NOCACHE | /* ??? */
|
||||
#endif
|
||||
#ifdef MAP_FILE
|
||||
MAP_FILE |
|
||||
#endif
|
||||
MAP_PRIVATE,
|
||||
fd, offset_rounded);
|
||||
PROT_READ, mmap_flags, fd, offset_rounded);
|
||||
if (mapped == MAP_FAILED) {
|
||||
event_warn("%s: mmap(%d, %d, %zu) failed",
|
||||
__func__, fd, 0, (size_t)(offset + length));
|
||||
event_warn("%s: mmap(NULL, %zu, %d, %d, %d, %lld) failed", __func__,
|
||||
(size_t)(length + offset_leftover), PROT_READ, mmap_flags, fd,
|
||||
(long long)offset_rounded);
|
||||
} else {
|
||||
seg->mapping = mapped;
|
||||
seg->contents = (char*)mapped+offset_leftover;
|
||||
|
Loading…
x
Reference in New Issue
Block a user