all authors of ioslaves: new wasKilled() for lengthy operations !
aleXXX
alexander.neundorf at gmx.net
Tue Jun 11 00:10:51 BST 2002
Hi,
for all of you who wrote an ioslave:
I just commited a patch to kio/kio/slavebase.cpp, which adds a function
Slavebase::wasKilled();
This returns true if the slave has been killed. From this moment on you have
5 seconds to cleanly exit your ioslave, i.e. to return from the function you
are currently in, back to dispatchLoop(). If you don't check, your ioslave
dtor will only be called if your slave is idle at this moment, if it is busy
your dtor won't be called without this check !
Therefor add a check in all potential lengthy operations, like
void FooSlave::get()
{
... do stuff
while (notAllDataReadYet)
{
...
select(maxFd, &fds,0,0,%tv);
if (wasKilled())
{
cleanUp();
return;
};
int bytesRead=::read(fd,buf,bufsize);
array.setRawData(buf, bytesRead);
data( array );
};
...
};
Bye
Alex
More information about the kde-core-devel
mailing list