Revision: 34219
http://sourceforge.net/p/opalvoip/code/34219
Author: rjongbloed
Date: 2015-10-21 13:30:47 +0000 (Wed, 21 Oct 2015)
Log Message:
-----------
Attempt to fix random closing of a channel (TCP socket in particular) when Linux under very heavy load.
Modified Paths:
--------------
ptlib/trunk/src/ptlib/unix/tlibthrd.cxx
Modified: ptlib/trunk/src/ptlib/unix/tlibthrd.cxx
===================================================================
--- ptlib/trunk/src/ptlib/unix/tlibthrd.cxx 2015-10-21 09:59:43 UTC (rev 34218)
+++ ptlib/trunk/src/ptlib/unix/tlibthrd.cxx 2015-10-21 13:30:47 UTC (rev 34219)
@@ -931,9 +931,8 @@
retval = ::poll(pfd, PARRAYSIZE(pfd), timeout.GetInterval());
} while (retval < 0 && errno == EINTR);
- if (retval > 0 && pfd[1].revents != 0) {
- BYTE ch;
- PAssertOS(::read(unblockPipe[0], &ch, 1) != -1);
+ BYTE dummy;
+ if (retval > 0 && pfd[1].revents != 0 && ::read(unblockPipe[0], &dummy, 1) == 1) {
errno = ECANCELED;
retval = -1;
PTRACE(6, "PTLib\tUnblocked I/O fd=" << unblockPipe[0]);
@@ -985,9 +984,8 @@
);
} while (retval < 0 && errno == EINTR);
- if ((retval == 1) && read_fds.IsPresent(unblockPipe[0])) {
- BYTE ch;
- PAssertOS(::read(unblockPipe[0], &ch, 1) != -1);
+ BYTE dummy;
+ if (retval > 0 && read_fds.IsPresent(unblockPipe[0]) && ::read(unblockPipe[0], &ch, 1) == 1) {
errno = ECANCELED;
retval = -1;
PTRACE(6, "PTLib\tUnblocked I/O fd=" << unblockPipe[0]);
@@ -1001,7 +999,7 @@
void PThread::PXAbortBlock() const
{
static BYTE ch = 0;
- PAssertOS(::write(unblockPipe[1], &ch, 1) != -1);
+ PAssertOS(::write(unblockPipe[1], &ch, 1) == 1);
PTRACE(6, "PTLib\tUnblocking I/O fd=" << unblockPipe[0] << " thread=" << GetThreadName());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|