Skip to content

Commit

Permalink
Auto merge of rust-lang#21287 - alexcrichton:issue-19872, r=huonw
Browse files Browse the repository at this point in the history
cc rust-lang#19872, this may help give some insight
  • Loading branch information
bors committed Jan 20, 2015
2 parents e375a89 + 440d63b commit 9006c3c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/librustdoc/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub use self::imp::Lock;
mod imp {
use std::ffi::CString;
use libc;
use std::os as stdos;

#[cfg(target_os = "linux")]
mod os {
Expand Down Expand Up @@ -116,7 +117,8 @@ mod imp {
libc::open(buf.as_ptr(), libc::O_RDWR | libc::O_CREAT,
libc::S_IRWXU)
};
assert!(fd > 0);
assert!(fd > 0, "failed to open lockfile: [{}] {}",
stdos::errno(), stdos::last_os_error());
let flock = os::flock {
l_start: 0,
l_len: 0,
Expand All @@ -129,8 +131,10 @@ mod imp {
libc::fcntl(fd, os::F_SETLKW, &flock as *const os::flock)
};
if ret == -1 {
let errno = stdos::errno();
unsafe { libc::close(fd); }
panic!("could not lock `{}`", p.display())
panic!("could not lock `{}`: [{}] {}", p.display(),
errno, stdos::error_string(errno))
}
Lock { fd: fd }
}
Expand Down Expand Up @@ -199,17 +203,19 @@ mod imp {
ptr::null_mut())
};
if handle == libc::INVALID_HANDLE_VALUE {
panic!("create file error: {}", os::last_os_error());
panic!("create file error: [{}] {}",
os::errno(), os::last_os_error());
}
let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
let ret = unsafe {
LockFileEx(handle, LOCKFILE_EXCLUSIVE_LOCK, 0, 100, 0,
&mut overlapped)
};
if ret == 0 {
let errno = os::errno();
unsafe { libc::CloseHandle(handle); }
panic!("could not lock `{}`: {}", p.display(),
os::last_os_error())
panic!("could not lock `{}`: [{}] {}", p.display(),
errno, os::error_string(errno));
}
Lock { handle: handle }
}
Expand Down

0 comments on commit 9006c3c

Please sign in to comment.