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

List:       kde-commits
Subject:    kdebase/ksmserver
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2004-08-26 16:55:16
Message-ID: 20040826165516.330A09003 () office ! kde ! org
[Download RAW message or body]

CVS commit by lunakl: 

Don't use SmsGenerateClientId() at all, it tries to lookup the machine
IP, and that apparently sometimes doesn't quite work and causes
delays. Just fake some IP address using a hash from the hostname.
CCMAIL: bastian@kde.org


  M +23 -5     server.cpp   1.129


--- kdebase/ksmserver/server.cpp  #1.128:1.129
@@ -133,19 +133,37 @@ void KSMClient::resetState()
  */
 static KStaticDeleter<QString> smy_addr;
-char * safeSmsGenerateClientID( SmsConn c )
+char * safeSmsGenerateClientID( SmsConn /*c*/ )
 {
-    char *ret = SmsGenerateClientID(c);
+//  Causes delays with misconfigured network :-/.
+//    char *ret = SmsGenerateClientID(c);
+    char* ret = NULL;
     if (!ret) {
         static QString *my_addr = 0;
        if (!my_addr) {
-           qWarning("Can't get own host name. Your system is severely misconfigured\n");
+//           qWarning("Can't get own host name. Your system is severely misconfigured\n");
            smy_addr.setObject(my_addr,new QString);
 
            /* Faking our IP address, the 0 below is "unknown" address format
               (1 would be IP, 2 would be DEC-NET format) */
+           char hostname[ 256 ];
+           if( gethostname( hostname, 255 ) != 0 )
            my_addr->sprintf("0%.8x", KApplication::random());
+           else {
+               // create some kind of hash for the hostname
+               int addr[ 4 ] = { 0, 0, 0, 0 };
+               int pos = 0;
+               for( unsigned int i = 0;
+                    i < strlen( hostname );
+                    ++i, ++pos )
+                  addr[ pos % 4 ] += hostname[ i ];
+               *my_addr = "0";
+               for( int i = 0;
+                    i < 4;
+                    ++i )
+                  *my_addr += QString::number( addr[ i ], 16 );
+           }
        }
        /* Needs to be malloc(), to look the same as libSM */
-       ret = (char *)malloc(1+9+13+10+4+1 + /*safeness*/ 10);
+       ret = (char *)malloc(1+9+my_addr->length()+10+4+1 + /*safeness*/ 10);
        static int sequence = 0;
 


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

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