[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    all authors of ioslaves: new wasKilled() for lengthy operations !
From:       aleXXX <alexander.neundorf () gmx ! net>
Date:       2002-06-10 22:39:24
[Download RAW message or body]

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
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic