Skip to content

Commit 9006c3c

Browse files
committed
Auto merge of #21287 - alexcrichton:issue-19872, r=huonw
cc #19872, this may help give some insight
2 parents e375a89 + 440d63b commit 9006c3c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/librustdoc/flock.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub use self::imp::Lock;
2222
mod imp {
2323
use std::ffi::CString;
2424
use libc;
25+
use std::os as stdos;
2526

2627
#[cfg(target_os = "linux")]
2728
mod os {
@@ -116,7 +117,8 @@ mod imp {
116117
libc::open(buf.as_ptr(), libc::O_RDWR | libc::O_CREAT,
117118
libc::S_IRWXU)
118119
};
119-
assert!(fd > 0);
120+
assert!(fd > 0, "failed to open lockfile: [{}] {}",
121+
stdos::errno(), stdos::last_os_error());
120122
let flock = os::flock {
121123
l_start: 0,
122124
l_len: 0,
@@ -129,8 +131,10 @@ mod imp {
129131
libc::fcntl(fd, os::F_SETLKW, &flock as *const os::flock)
130132
};
131133
if ret == -1 {
134+
let errno = stdos::errno();
132135
unsafe { libc::close(fd); }
133-
panic!("could not lock `{}`", p.display())
136+
panic!("could not lock `{}`: [{}] {}", p.display(),
137+
errno, stdos::error_string(errno))
134138
}
135139
Lock { fd: fd }
136140
}
@@ -199,17 +203,19 @@ mod imp {
199203
ptr::null_mut())
200204
};
201205
if handle == libc::INVALID_HANDLE_VALUE {
202-
panic!("create file error: {}", os::last_os_error());
206+
panic!("create file error: [{}] {}",
207+
os::errno(), os::last_os_error());
203208
}
204209
let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
205210
let ret = unsafe {
206211
LockFileEx(handle, LOCKFILE_EXCLUSIVE_LOCK, 0, 100, 0,
207212
&mut overlapped)
208213
};
209214
if ret == 0 {
215+
let errno = os::errno();
210216
unsafe { libc::CloseHandle(handle); }
211-
panic!("could not lock `{}`: {}", p.display(),
212-
os::last_os_error())
217+
panic!("could not lock `{}`: [{}] {}", p.display(),
218+
errno, os::error_string(errno));
213219
}
214220
Lock { handle: handle }
215221
}

0 commit comments

Comments
 (0)