From: Marcus Brinkmann Date: Fri, 5 Oct 2007 00:20:43 +0000 (+0000) Subject: 2007-10-05 Marcus Brinkmann X-Git-Tag: gpgme-1.2.0@1385~111 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f4e2702c1cf13b14193a98120d1cf37a723e387b;p=gpgme.git 2007-10-05 Marcus Brinkmann * kdpipeiodevice.cpp, w32-qt-io.cpp: New versions from Frank Osterfeld. --- diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 77de5ea..91c202c 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,8 @@ +2007-10-05 Marcus Brinkmann + + * kdpipeiodevice.cpp, w32-qt-io.cpp: New versions from Frank + Osterfeld. + 2007-10-04 Marcus Brinkmann * kdpipeiodevice.h, kdpipeiodevice.cpp, kdpipeiodevice.moc, diff --git a/trunk/gpgme/kdpipeiodevice.cpp b/trunk/gpgme/kdpipeiodevice.cpp index 1fd0ef0..3e206c3 100644 --- a/trunk/gpgme/kdpipeiodevice.cpp +++ b/trunk/gpgme/kdpipeiodevice.cpp @@ -493,7 +493,7 @@ bool KDPipeIODevice::writeWouldBlock() const { d->startWriterThread(); LOCKED( d->writer ); - return d->writer->bufferFull() && !d->writer->error; + return !d->writer->bufferEmpty() && !d->writer->error; } @@ -684,6 +684,7 @@ void Reader::run() { 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(); diff --git a/trunk/gpgme/w32-qt-io.cpp b/trunk/gpgme/w32-qt-io.cpp index dd17e87..ba43913 100644 --- a/trunk/gpgme/w32-qt-io.cpp +++ b/trunk/gpgme/w32-qt-io.cpp @@ -85,8 +85,9 @@ using _gpgme_::KDPipeIODevice; #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; } @@ -152,7 +153,11 @@ _gpgme_io_read (int fd, void *buffer, size_t count) 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) { @@ -185,6 +190,11 @@ _gpgme_io_write (int fd, const void *buffer, size_t count) 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) @@ -323,8 +333,9 @@ _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, 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); }