diff options
author | Pete Batard <pbatard@gmail.com> | 2010-01-14 01:26:34 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-01-14 01:26:34 +0000 |
commit | 762989c9ba538a860d202d7327e08db3fd1ddc8d (patch) | |
tree | 442578c84f85840f88e7f15ca60fcf2dc3293d57 /libusb/os/windows_compat.c | |
parent | 191930f7007f373144ee7ecfc098eb390a33265d (diff) | |
download | libusb-762989c9ba538a860d202d7327e08db3fd1ddc8d.tar.gz |
svn r44:
- fixed configure.ac for libusb handled timeouts
- fixed crash on invalid fds in windows_compat.c
- xusb improvements for mass storage test
Diffstat (limited to 'libusb/os/windows_compat.c')
-rw-r--r-- | libusb/os/windows_compat.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libusb/os/windows_compat.c b/libusb/os/windows_compat.c index 6259cbb..ea2455d 100644 --- a/libusb/os/windows_compat.c +++ b/libusb/os/windows_compat.c @@ -505,8 +505,10 @@ int poll(struct pollfd *fds, unsigned int nfds, int timeout) || (poll_fd[index].handle == 0) || (poll_fd[index].overlapped == NULL)) { fds[i].revents |= POLLNVAL | POLLERR; errno = EBADF; + if (index >= 0) { + pthread_mutex_unlock(&_poll_fd[index].mutex); + } printb("poll: invalid fd\n"); - pthread_mutex_unlock(&_poll_fd[index].mutex); return -1; } @@ -527,7 +529,7 @@ int poll(struct pollfd *fds, unsigned int nfds, int timeout) return -1; } - printb("windows_poll: fd[%d]=%d (overlapped = %p) got events %04X\n", i, poll_fd[index].fd, poll_fd[index].overlapped, fds[i].events); + printb("poll: fd[%d]=%d (overlapped = %p) got events %04X\n", i, poll_fd[index].fd, poll_fd[index].overlapped, fds[i].events); // The following macro only works if overlapped I/O was reported pending if (HasOverlappedIoCompleted(poll_fd[index].overlapped)) { @@ -558,7 +560,9 @@ int poll(struct pollfd *fds, unsigned int nfds, int timeout) index = _fd_to_index_and_lock(fds[i].fd);
fds[i].revents = fds[i].events; triggered++; - pthread_mutex_unlock(&_poll_fd[index].mutex); + if (index >= 0) { + pthread_mutex_unlock(&_poll_fd[index].mutex); + } } else if (ret == WAIT_TIMEOUT) { printb(" timed out\n"); return 0; // 0 = timeout @@ -624,7 +628,9 @@ ssize_t write_for_poll(int fd, const void *buf, size_t count) if ( (index < 0) || (poll_fd[index].overlapped == NULL) || (poll_fd[index].rw != RW_WRITE) ) { errno = EBADF; - pthread_mutex_unlock(&_poll_fd[index].mutex); + if (index >= 0) { + pthread_mutex_unlock(&_poll_fd[index].mutex); + } return -1; } |