Bug 84717 - Clients should not exit when dcopserver crashes or exits
Summary: Clients should not exit when dcopserver crashes or exits
Status: RESOLVED UNMAINTAINED
Alias: None
Product: dcop
Classification: Frameworks and Libraries
Component: dcopserver (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-08 12:12 UTC by Erwin Burgstaller
Modified: 2010-01-20 21:15 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erwin Burgstaller 2004-07-08 12:12:52 UTC
Version:            (using KDE KDE 3.2.3)
Installed from:    Debian testing/unstable Packages

Instead of shuting down a dcop-client could try to reconnect to a new upcoming 
dcopserver. 

This can be done by implementing a slot like reAttch() shown below, which is 
then called on Error in DCOPClient::processSocketData(int fd).

Of course it makes no big sense if dcopserver isn't respawned 
automatically. In my special case I've put the dcopserver with option --nofork
for respawn into /etc/inittab, because I'll never have anything else than 
DISPLAY=:0 (specialiced production environment).

void DCOPClient::reAttach()
{
   static QTimer *timer = NULL;
   static QCString appId; 
			      
   if (timer == NULL)
   {
      // first call after connection brake down

      // first we'll create a new timer for subsequent retries
      timer = new QTimer(this);
      connect(timer, SIGNAL(timeout()), this, SLOT(reAttach()) );
      timer->start(2000, false); // 2 seconds periodic timer

      appId = d->appId; // remember how we were called before we'll
		        // destroy it.
   }

   // now trying to put connection down clean, most code taken from
   // destructor and constructor

   detach();
   d->iceConn = 0L;

   if (d->registered)
      unregisterLocalClient(d->appId);

   delete d->notifier;
   delete d->transactionList;
   delete d;

   if (mainClient() == this)
      setMainClient(0);

   d = new DCOPClientPrivate;
   d->parent = this;
   d->iceConn = 0L;
   d->majorOpcode = 0;
   d->key = 0;
   d->currentKey = 0;
   d->appId = 0;
   d->notifier = 0L;
   d->non_blocking_call_lock = false;
   d->registered = false;
   d->foreign_server = true;
   d->accept_calls = true;
   d->accept_calls_override = false;
   d->qt_bridge_enabled = true;
   d->transactionList = 0L;
   d->transactionId = 0;

   // Static pointer is not touched by destrutor or constructor, but we
   // need to get the new servers address.
   d->serverAddr = 0L;

   QObject::connect( &d->postMessageTimer, SIGNAL( timeout() ), 
		     this, SLOT( processPostedMessagesInternal() ) );

   qWarning("Trying to reconnect to dcopserver.");

   if ( !mainClient() )
      setMainClient( this );
   
   extern int _kde_IceLastMajorOpcode; // from libICE

   _kde_IceLastMajorOpcode = 0;

   attachInternal(false);

   if (isAttached())
   {
      registerAs(appId, false);

      qWarning("Now we're attached to dcopserver: %s", 
	       d->serverAddr ? d->serverAddr : "NULL");

      delete timer;
      timer = NULL;
   }
}
Comment 1 Dario Andres 2010-01-20 21:15:27 UTC
Closing as DCOP is unmaintained.