+2007-10-05 Marcus Brinkmann <marcus@g10code.de>
+
+ * kdpipeiodevice.cpp, w32-qt-io.cpp: New versions from Frank
+ Osterfeld.
+
2007-10-04 Marcus Brinkmann <marcus@g10code.de>
* kdpipeiodevice.h, kdpipeiodevice.cpp, kdpipeiodevice.moc,
{
d->startWriterThread();
LOCKED( d->writer );
- return d->writer->bufferFull() && !d->writer->error;
+ return !d->writer->bufferEmpty() && !d->writer->error;
}
if ( !cancel && ( eof || error ) ) {
qDebug( "%p: Reader::run: received eof(%d) or error(%d), waking everyone", this, eof, error );
notifyReadyRead();
+ cancel = true;
} else if ( !cancel && !bufferFull() && !bufferEmpty() ) {
qDebug( "%p: Reader::run: buffer no longer empty, waking everyone", this );
notifyReadyRead();
#define MAX_SLAFD 1024
struct DeviceEntry {
- DeviceEntry() : iodev( 0 ), refCount( 1 ) {}
+ DeviceEntry() : iodev( 0 ), refCount( 1 ), blocking( true ) {}
KDPipeIODevice* iodev;
+ bool blocking;
mutable int refCount;
void ref() const { ++refCount; }
int unref() const { assert( refCount > 0 ); return --refCount; }
return TRACE_SYSRES (-1);
}
TRACE_LOG1 ("channel %p", chan);
-
+ if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->readWouldBlock() ) {
+ errno = EAGAIN;
+ return TRACE_SYSRES( -1 );
+ }
+
nread = chan->read ((char *) buffer, count);
if (nread < 0)
{
return -1;
}
+ if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->writeWouldBlock() )
+ {
+ errno = EAGAIN;
+ return TRACE_SYSRES( -1 );
+ }
nwritten = chan->write ((char *) buffer, count);
if (nwritten < 0)
int
_gpgme_io_set_nonblocking (int fd)
{
- /* Qt always uses non-blocking IO, except for files, maybe, but who
- uses that? */
+ DeviceEntry* const entry = iodevice_table[fd];
+ assert( entry );
+ entry->blocking = false;
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
return TRACE_SYSRES (0);
}