This commit is contained in:
Mackenzie Clark
2019-03-22 16:57:29 -07:00
parent b7c5f27b37
commit e75a23602a
3 changed files with 40 additions and 4 deletions

View File

@ -97,7 +97,12 @@ impl EmscriptenVfs {
pub fn get_host_socket_fd(&self, vfd: &VirtualFd) -> Option<Fd> {
match self.fd_map.get(&vfd) {
Some(FileHandle::Socket(fd)) => Some(*fd),
Some(FileHandle::Socket(fd)) => {
if *fd < 0 {
panic!()
}
Some(*fd)
},
_ => None,
}
}
@ -119,6 +124,9 @@ impl EmscriptenVfs {
pub fn new_socket_fd(&mut self, host_fd: Fd) -> VirtualFd {
let vfd = self.next_lowest_fd();
if host_fd < 0 {
panic!()
}
self.fd_map.insert(vfd.clone(), FileHandle::Socket(host_fd));
vfd
}