2007-10-05 Marcus Brinkmann <marcus@g10code.de>
* kdpipeiodevice.cpp, w32-qt-io.cpp: New versions from Frank Osterfeld.
This commit is contained in:
parent
a70248939f
commit
c8deb0385a
@ -1,3 +1,8 @@
|
|||||||
|
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>
|
2007-10-04 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* kdpipeiodevice.h, kdpipeiodevice.cpp, kdpipeiodevice.moc,
|
* kdpipeiodevice.h, kdpipeiodevice.cpp, kdpipeiodevice.moc,
|
||||||
|
@ -493,7 +493,7 @@ bool KDPipeIODevice::writeWouldBlock() const
|
|||||||
{
|
{
|
||||||
d->startWriterThread();
|
d->startWriterThread();
|
||||||
LOCKED( d->writer );
|
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 ) ) {
|
if ( !cancel && ( eof || error ) ) {
|
||||||
qDebug( "%p: Reader::run: received eof(%d) or error(%d), waking everyone", this, eof, error );
|
qDebug( "%p: Reader::run: received eof(%d) or error(%d), waking everyone", this, eof, error );
|
||||||
notifyReadyRead();
|
notifyReadyRead();
|
||||||
|
cancel = true;
|
||||||
} else if ( !cancel && !bufferFull() && !bufferEmpty() ) {
|
} else if ( !cancel && !bufferFull() && !bufferEmpty() ) {
|
||||||
qDebug( "%p: Reader::run: buffer no longer empty, waking everyone", this );
|
qDebug( "%p: Reader::run: buffer no longer empty, waking everyone", this );
|
||||||
notifyReadyRead();
|
notifyReadyRead();
|
||||||
|
@ -85,8 +85,9 @@ using _gpgme_::KDPipeIODevice;
|
|||||||
#define MAX_SLAFD 1024
|
#define MAX_SLAFD 1024
|
||||||
|
|
||||||
struct DeviceEntry {
|
struct DeviceEntry {
|
||||||
DeviceEntry() : iodev( 0 ), refCount( 1 ) {}
|
DeviceEntry() : iodev( 0 ), refCount( 1 ), blocking( true ) {}
|
||||||
KDPipeIODevice* iodev;
|
KDPipeIODevice* iodev;
|
||||||
|
bool blocking;
|
||||||
mutable int refCount;
|
mutable int refCount;
|
||||||
void ref() const { ++refCount; }
|
void ref() const { ++refCount; }
|
||||||
int unref() const { assert( refCount > 0 ); return --refCount; }
|
int unref() const { assert( refCount > 0 ); return --refCount; }
|
||||||
@ -152,6 +153,10 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
|
|||||||
return TRACE_SYSRES (-1);
|
return TRACE_SYSRES (-1);
|
||||||
}
|
}
|
||||||
TRACE_LOG1 ("channel %p", chan);
|
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);
|
nread = chan->read ((char *) buffer, count);
|
||||||
if (nread < 0)
|
if (nread < 0)
|
||||||
@ -185,6 +190,11 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( iodevice_table[fd] && !iodevice_table[fd]->blocking && chan->writeWouldBlock() )
|
||||||
|
{
|
||||||
|
errno = EAGAIN;
|
||||||
|
return TRACE_SYSRES( -1 );
|
||||||
|
}
|
||||||
nwritten = chan->write ((char *) buffer, count);
|
nwritten = chan->write ((char *) buffer, count);
|
||||||
|
|
||||||
if (nwritten < 0)
|
if (nwritten < 0)
|
||||||
@ -323,8 +333,9 @@ _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler,
|
|||||||
int
|
int
|
||||||
_gpgme_io_set_nonblocking (int fd)
|
_gpgme_io_set_nonblocking (int fd)
|
||||||
{
|
{
|
||||||
/* Qt always uses non-blocking IO, except for files, maybe, but who
|
DeviceEntry* const entry = iodevice_table[fd];
|
||||||
uses that? */
|
assert( entry );
|
||||||
|
entry->blocking = false;
|
||||||
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
|
TRACE_BEG (DEBUG_SYSIO, "_gpgme_io_set_nonblocking", fd);
|
||||||
return TRACE_SYSRES (0);
|
return TRACE_SYSRES (0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user