From kde-windows Thu Dec 08 20:41:48 2005 From: Christian Ehrlicher Date: Thu, 08 Dec 2005 20:41:48 +0000 To: kde-windows Subject: [Kde-windows] dcopserver only accepts one coneection on win32 Message-Id: <43989A8C.10701 () gmx ! de> X-MARC-Message: https://marc.info/?l=kde-windows&m=113407460301729 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0711179086==" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --===============0711179086== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigFEF731C62AC3167544456746" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFEF731C62AC3167544456746 Content-Type: multipart/mixed; boundary="------------080906010206000504080202" This is a multi-part message in MIME format. --------------080906010206000504080202 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, we have a problem with dcopserver on win32 - it only accepts one connection. After a lot of debugging (I think I understand dcopserver now much better :-) ) I found out that there is a problem with QSocketNotifier. It just sends too much events and dcopserver gets into an endless loop in dcop/KDE-ICE/misc.c:259. The problem is the behaviour of WSAAsyncSelect used in qtcore to get notification that new data has arrived. I'll try to explain (or read http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/wsaasyncselect_2.asp) the problem: client sends data -> WSAAsyncSelect creates an event -> DCOPServer::processData() -> server reads data -> server and client are communicating without a need for a socketnotifier -> ready -> because new data arrived, an new event is created -> processData() is called but can't read anything from the socket -> endless loop WSAAsyncSelect stops sending events until it is reenabled by calling the specific function. This means that I don't get an event until I called recv(). But since DCOPServer::processData() sends and reads data, new events a created... My current hack is to disable the event notifier inside DCOPServer::processData() (see attached patch). I'm unsure if this is ok because I currently don't know what happens when new data arrives after I called recv() the last time but QSocketNotifier isn't enabled yet. If I get a notification, it will work, but if not, the server get out of sync/the client waits forever. I wonder how this worked with qt3 because there also WSAAsyncSelect is used (at least I use it for qt3/free because I found no solution how to get it working with select()) Christian --------------080906010206000504080202 Content-Type: text/x-diff; name="dcop2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dcop2.patch" Index: dcopserver.cpp =================================================================== --- dcopserver.cpp (revision 486802) +++ dcopserver.cpp (working copy) @@ -440,6 +440,7 @@ : QSocketNotifier( IceConnectionNumber( conn ), QSocketNotifier::Read, 0 ) { + setEnabled(false); iceConn = conn; notifyRegister = 0; _signalConnectionList = 0; @@ -1153,8 +1154,11 @@ void DCOPServer::processData( int /*socket*/ ) { - IceConn iceConn = static_cast(sender())->iceConn; + DCOPConnection *s = static_cast( sender() ); + IceConn iceConn = s->iceConn; + s->setEnabled(false); IceProcessMessagesStatus status = IceProcessMessages( iceConn, 0, 0 ); + s->setEnabled(true); if ( status == IceProcessMessagesIOError ) { deadConnections.removeAll(iceConn); if (deadConnections.isEmpty()) @@ -1191,6 +1195,7 @@ deadConnections.removeAll(iceConn); (void) IceCloseConnection (iceConn); } + clients.value( iceConn )->setEnabled(true); } void* DCOPServer::watchConnection( IceConn iceConn ) --------------080906010206000504080202-- --------------enigFEF731C62AC3167544456746 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFDmJqQHAIuqbOiZ+kRAqPEAJ4vZkkVcx1BgdMibfPjkFRelgIX+gCaAtSF nwGSomN8OpTV1TIbLC1PnJ8= =LzZ2 -----END PGP SIGNATURE----- --------------enigFEF731C62AC3167544456746-- --===============0711179086== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kde-windows mailing list Kde-windows@kde.org https://mail.kde.org/mailman/listinfo/kde-windows --===============0711179086==--