Commit 7f9d75c2 authored by Pawel Polanski's avatar Pawel Polanski Committed by Paweł Polański
Browse files

Turn off notifier when reading and setting up port

Change-Id: I6f2de72d7a85626d7436f225bbbac43d9dd9816d
Reviewed-on: http://codereview.qt.nokia.com/81

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarPaweł Polański <jaggernod@gmail.com>
parent 9d5a094c
......@@ -136,7 +136,10 @@ qint64 VirtualSerialDevice::bytesAvailable() const
if (!isOpen()) return 0;
int avail = 0;
if (ioctl(d->portHandle, FIONREAD, &avail) == -1) {
d->readNotifier->setEnabled(false);
int res = ioctl(d->portHandle, FIONREAD, &avail);
d->readNotifier->setEnabled(true);
if (res == -1) {
return 0;
}
return (qint64)avail + QIODevice::bytesAvailable();
......@@ -145,7 +148,9 @@ qint64 VirtualSerialDevice::bytesAvailable() const
qint64 VirtualSerialDevice::readData(char *data, qint64 maxSize)
{
QMutexLocker locker(&lock);
d->readNotifier->setEnabled(false);
int result = ::read(d->portHandle, data, maxSize);
d->readNotifier->setEnabled(true);
if (result == -1 && errno == EAGAIN)
result = 0; // To Qt, 0 here means nothing ready right now, and -1 is reserved for permanent errors
return result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment