mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-02-04 06:08:39 +02:00
mmap: handle ENOMEM error
This commit causes a memory map strategy to fall back to a file backed strategy if the mmap call fails with an `ENOMEM` error. Fixes #852
This commit is contained in:
parent
9163aaac27
commit
dbf6f15625
@ -341,14 +341,17 @@ impl Worker {
|
|||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn mmap(&self, file: &File) -> Result<Option<Mmap>> {
|
fn mmap(&self, file: &File) -> Result<Option<Mmap>> {
|
||||||
use libc::{ENODEV, EOVERFLOW};
|
use libc::{EOVERFLOW, ENODEV, ENOMEM};
|
||||||
|
|
||||||
let err = match mmap_readonly(file) {
|
let err = match mmap_readonly(file) {
|
||||||
Ok(mmap) => return Ok(Some(mmap)),
|
Ok(mmap) => return Ok(Some(mmap)),
|
||||||
Err(err) => err,
|
Err(err) => err,
|
||||||
};
|
};
|
||||||
let code = err.raw_os_error();
|
let code = err.raw_os_error();
|
||||||
if code == Some(ENODEV) || code == Some(EOVERFLOW) {
|
if code == Some(EOVERFLOW)
|
||||||
|
|| code == Some(ENODEV)
|
||||||
|
|| code == Some(ENOMEM)
|
||||||
|
{
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
Err(From::from(err))
|
Err(From::from(err))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user