[PATCH] always keep one file-ioslave around

aleXXX alexander.neundorf at gmx.net
Thu May 2 23:21:18 BST 2002


On Thursday 02 May 2002 23:13, aleXXX wrote:
> On Thursday 02 May 2002 21:41, Waldo Bastian wrote:
> > On Wednesday 01 May 2002 02:51 pm, aleXXX wrote:
> > > Hi,
> > >
> > > since the file ioslave is a very basic element, I think it would be a
> > > good idea to keep at least one of them always around, so that it hasn't
> > > got to be restarted. The attached patch for
> > > kdelibs/kio/kio/scheduler.cpp does this.
> >
> > No, I don't like this. It would increase the memory usage because every
> > application that has used a file-slave once will stick to it till the end
> > of times. If you want to do something like this you should do it in the
> > slave pool maintained by klauncher:
> >
> > When a slave isn't used any more by the application it is send back to
> > klauncher. When another application needs a slave, klauncher will check
> > its pool of slaves first before starting a new one.
> >
> > Cheers,
> > Waldo
>
> Right, I should look more exactly at the code before sending patches.
>
> Bye
> Alex

So how about this one ?

RCS file: /home/kde/kdelibs/kinit/klauncher.h,v
retrieving revision 1.27
diff -b -u -r1.27 klauncher.h
--- klauncher.h 2002/02/28 20:35:29     1.27
+++ klauncher.h 2002/05/02 21:49:26
@@ -46,10 +46,11 @@
    IdleSlave(KSocket *socket);
    bool match( const QString &protocol, const QString &host, bool connected);
    void connect( const QString &app_socket);
-   pid_t pid() { return mPid;}
+   pid_t pid() const { return mPid;}
    int age(time_t now);
    void reparseConfiguration();
    bool onHold(const KURL &url);
+   QString protocol() const   {return mProtocol;}

RCS file: /home/kde/kdelibs/kinit/klauncher.cpp,v
retrieving revision 1.76
diff -b -u -r1.76 klauncher.cpp
--- klauncher.cpp       2002/03/08 18:56:03     1.76
+++ klauncher.cpp       2002/05/02 21:51:34
@@ -1207,11 +1207,14 @@
 void
 KLauncher::idleTimeout()
 {
+    bool keepOneFileSlave=true;
     time_t now = time(0);
     IdleSlave *slave;
     for(slave = mSlaveList.first(); slave; slave = mSlaveList.next())
     {
-        if (slave->age(now) > SLAVE_MAX_IDLE)
+        if ((slave->protocol()=="file") && (keepOneFileSlave))
+           keepOneFileSlave=false;
+        else if (slave->age(now) > SLAVE_MAX_IDLE)
         {
            // killing idle slave
            delete slave;

Bye
Alex




More information about the kde-core-devel mailing list