author | zecke <zecke> | 2003-02-05 08:54:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-05 08:54:58 (UTC) |
commit | bbb3690f12191763a407e6a0edd521113b3c25ac (patch) (side-by-side diff) | |
tree | 39f90d71c7f085f5722382db4a5577bbda2e1618 /x11 | |
parent | 97b96e141fca844317e59ca5b99c1bf5fa52b1f0 (diff) | |
download | opie-bbb3690f12191763a407e6a0edd521113b3c25ac.zip opie-bbb3690f12191763a407e6a0edd521113b3c25ac.tar.gz opie-bbb3690f12191763a407e6a0edd521113b3c25ac.tar.bz2 |
Fix the IPC server and client
registering channel is done locally with refcounts
if the channel is already registered globally
Fix some sizes to allow proper communication..
-rw-r--r-- | x11/ipc/client/ocopclient.cpp | 8 | ||||
-rw-r--r-- | x11/ipc/server/ocopserver.cpp | 9 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qcopchannel_qws.cpp | 31 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qcopchannel_qws.h | 4 |
4 files changed, 39 insertions, 13 deletions
diff --git a/x11/ipc/client/ocopclient.cpp b/x11/ipc/client/ocopclient.cpp index 6085481..91827e7 100644 --- a/x11/ipc/client/ocopclient.cpp +++ b/x11/ipc/client/ocopclient.cpp @@ -101,2 +101,6 @@ OCOPPacket OCOPClient::packet() const{ if ( head.magic == 47 ) { + qWarning("Client:Magic Match"); + chan = QCString( head.chlen+1); + func = QCString( head.funclen+1 ); + ar = QByteArray( head.datalen); read(m_socket, chan.data(), head.chlen ); @@ -104,2 +108,3 @@ OCOPPacket OCOPClient::packet() const{ read(m_socket, ar.data(), head.datalen ); + qWarning("Client:%d %s",head.chlen,chan.data() ); } @@ -114,2 +119,3 @@ OCOPPacket OCOPClient::packet() const{ bool OCOPClient::isRegistered( const QCString& chan ) const{ + qWarning("OCopClient::isRegistered %s", chan.data() ); /* should I disconnect the socket notfier? */ @@ -121,2 +127,3 @@ bool OCOPClient::isRegistered( const QCString& chan ) const{ OCOPPacket pack = packet(); + qWarning("unblock %s %s", pack.channel().data(), chan.data() ); @@ -132,2 +139,3 @@ bool OCOPClient::isRegistered( const QCString& chan ) const{ void OCOPClient::send( const QCString& chan, const QCString& fu, const QByteArray& arr ) { + qWarning("ClientSending %s %s", chan.data(), fu.data() ); OCOPPacket pack(OCOPPacket::Call, chan, fu, arr ); diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp index 0f818b7..ee5ea18 100644 --- a/x11/ipc/server/ocopserver.cpp +++ b/x11/ipc/server/ocopserver.cpp @@ -169,3 +169,3 @@ void OCopServer::newOnClient( int fd ) { QCString func( head.funclen+1 ); - QByteArray data ( head.datalen ); + QByteArray data ( head.datalen+1 ); @@ -302,3 +302,3 @@ void OCopServer::dispatch( const OCOPPacket& packet, int sourceFD ) { case OCOPPacket::IsRegistered: - qWarning("IsRegistered"); + qWarning("Server:IsRegistered %s", packet.channel().data() ); isRegistered( packet.channel(), sourceFD ); @@ -367,3 +367,3 @@ void OCopServer::delChannel( const QCString& channel, void OCopServer::isRegistered( const QCString& channel, int fd) { -// qWarning("isRegistered"); + qWarning("Server:isRegistered %s", channel.data() ); OCOPHead head; @@ -381,4 +381,6 @@ void OCopServer::isRegistered( const QCString& channel, int fd) { func[0] = 1; + qWarning("Server:Channel is Registered %d", head.chlen); }else{ func[0] = 0; + qWarning("Server:Channel is NotRegistered"); } @@ -403,2 +405,3 @@ void OCopServer::call( const OCOPPacket& p, int ) { for (it = cli.begin(); it != cli.end(); ++it ) { + qWarning("Server:calling %d %s %s", (*it), p.channel().data(), p.header().data() ); write( (*it), &head, sizeof(head ) ); diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.cpp b/x11/libqpe-x11/qt/qcopchannel_qws.cpp index e90f056..1cea80c 100644 --- a/x11/libqpe-x11/qt/qcopchannel_qws.cpp +++ b/x11/libqpe-x11/qt/qcopchannel_qws.cpp @@ -6,2 +6,3 @@ QList<QCopChannel>* QCopChannel::m_list = 0; +QMap<QCString, int> QCopChannel::m_refCount; @@ -10,6 +11,15 @@ QCopChannel::QCopChannel( const QCString& channel, QObject* parent, : QObject( parent, name ),m_chan(channel) { - init(); if (!m_list ) { m_list = new QList<QCopChannel>; + /* only connect once */ + connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ), + this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) ); } + /* first registration or ref count is 0 for m_chan*/ + if (!m_refCount.contains( m_chan ) || !m_refCount[m_chan] ) { + m_refCount[m_chan] = 1; + OCOPClient::self()->addChannel( m_chan ); + }else + m_refCount[m_chan]++; + m_list->append(this); @@ -20,2 +30,9 @@ void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) { QCopChannel::~QCopChannel() { + if (m_refCount[m_chan] == 1 ) { + OCOPClient::self()->delChannel( m_chan ); + m_refCount[m_chan] = 0; + }else + m_refCount[m_chan]--; + + m_list->remove(this); @@ -25,8 +42,3 @@ QCopChannel::~QCopChannel() { } - OCOPClient::self()->delChannel( m_chan ); -} -void QCopChannel::init() { - OCOPClient::self()->addChannel( m_chan ); - connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ), - this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) ); + } @@ -49,2 +61,3 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, const QByteArray& ar ) { + qWarning("Client:sendLocally %s %s", chann.data(), msg.data() ); if (!m_list ) @@ -52,2 +65,3 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, QCopChannel* chan; + for ( chan = m_list->first(); chan; chan = m_list->next() ) { @@ -60,4 +74,3 @@ bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) { - if (chan == m_chan ) - emit received(msg, ar ); + sendLocally( chan, msg, ar ); } diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.h b/x11/libqpe-x11/qt/qcopchannel_qws.h index 94b199e..c1220cb 100644 --- a/x11/libqpe-x11/qt/qcopchannel_qws.h +++ b/x11/libqpe-x11/qt/qcopchannel_qws.h @@ -6,2 +6,3 @@ #include <qlist.h> +#include <qmap.h> @@ -32,4 +33,5 @@ private slots: private: - void init(); + bool isRegisteredLocally( const QCString& str); static QList<QCopChannel> *m_list; + static QMap<QCString, int> m_refCount; /* the channel */ |