summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-16 16:53:43 (UTC)
committer zecke <zecke>2002-10-16 16:53:43 (UTC)
commitef5700ad4eda47e98b76467fa80dd6cd838c6391 (patch) (unidiff)
treedcd5d051824689cab42f036895959483fb5e690b
parentea11ae7dc31e23578d13f30315a3697cbce99c05 (diff)
downloadopie-ef5700ad4eda47e98b76467fa80dd6cd838c6391.zip
opie-ef5700ad4eda47e98b76467fa80dd6cd838c6391.tar.gz
opie-ef5700ad4eda47e98b76467fa80dd6cd838c6391.tar.bz2
some debug output
+ bugfix besides some problems with the server IPC is working on X11 too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--x11/ipc/client/ocopclient.cpp4
-rw-r--r--x11/ipc/server/ocopserver.cpp10
-rw-r--r--x11/ipc/server/ocopserver.pro1
3 files changed, 9 insertions, 6 deletions
diff --git a/x11/ipc/client/ocopclient.cpp b/x11/ipc/client/ocopclient.cpp
index ac6e4a3..c1def73 100644
--- a/x11/ipc/client/ocopclient.cpp
+++ b/x11/ipc/client/ocopclient.cpp
@@ -98,25 +98,25 @@ OCOPPacket OCOPClient::packet() const{
98 return pack; 98 return pack;
99} 99}
100/* 100/*
101 * we've blocking IO here on these sockets 101 * we've blocking IO here on these sockets
102 * so we send and go on read 102 * so we send and go on read
103 * this will be blocked 103 * this will be blocked
104 */ 104 */
105bool OCOPClient::isRegistered( const QCString& chan ) const{ 105bool OCOPClient::isRegistered( const QCString& chan ) const{
106 /* should I disconnect the socket notfier? */ 106 /* should I disconnect the socket notfier? */
107 OCOPPacket packe(OCOPPacket::IsRegistered, chan ); 107 OCOPPacket packe(OCOPPacket::IsRegistered, chan );
108 OCOPHead head = packe.head(); 108 OCOPHead head = packe.head();
109 write(m_socket, &head, sizeof(head) ); 109 write(m_socket, &head, sizeof(head) );
110 110 write(m_socket, chan.data(), chan.size() );
111 /* block */ 111 /* block */
112 OCOPPacket pack = packet(); 112 OCOPPacket pack = packet();
113 113
114 /* connect here again */ 114 /* connect here again */
115 if ( pack.channel() == chan ) { 115 if ( pack.channel() == chan ) {
116 QCString func = pack.header(); 116 QCString func = pack.header();
117 if (func[0] == 1 ) 117 if (func[0] == 1 )
118 return true; 118 return true;
119 } 119 }
120 120
121 return false; 121 return false;
122}; 122};
@@ -135,16 +135,16 @@ void OCOPClient::delChannel(const QCString& chan ) {
135void OCOPClient::call( const OCOPPacket& pack ) { 135void OCOPClient::call( const OCOPPacket& pack ) {
136 OCOPHead head = pack.head(); 136 OCOPHead head = pack.head();
137 write(m_socket, &head, sizeof(head) ); 137 write(m_socket, &head, sizeof(head) );
138 write(m_socket, pack.channel().data(), pack.channel().size() ); 138 write(m_socket, pack.channel().data(), pack.channel().size() );
139 write(m_socket, pack.header().data(), pack.header().size() ); 139 write(m_socket, pack.header().data(), pack.header().size() );
140 write(m_socket, pack.content().data(), pack.content().size() ); 140 write(m_socket, pack.content().data(), pack.content().size() );
141} 141}
142void OCOPClient::startUP() { 142void OCOPClient::startUP() {
143 qWarning("Start me up"); 143 qWarning("Start me up");
144 pid_t pi = fork(); 144 pid_t pi = fork();
145 if ( pi == 0 ) { 145 if ( pi == 0 ) {
146 setsid(); 146 setsid();
147 execlp("opie-ipc", "opie-ipc", NULL ); 147 execlp("ocopserver", "ocopserver", NULL );
148 _exit(1); 148 _exit(1);
149 } 149 }
150} 150}
diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp
index e76657e..421e49c 100644
--- a/x11/ipc/server/ocopserver.cpp
+++ b/x11/ipc/server/ocopserver.cpp
@@ -125,67 +125,67 @@ void OCopServer::newOnServer() {
125 125
126 126
127 registerClient( fd ); 127 registerClient( fd );
128} 128}
129int OCopServer::accept() { 129int OCopServer::accept() {
130 /* 130 /*
131 * accept it 131 * accept it
132 * the socket is currently blocking IIRC 132 * the socket is currently blocking IIRC
133 */ 133 */
134 return ::accept( m_serverfd, (struct sockaddr*)&m_address, &m_adrlaenge ); 134 return ::accept( m_serverfd, (struct sockaddr*)&m_address, &m_adrlaenge );
135} 135}
136void OCopServer::newOnClient( int fd ) { 136void OCopServer::newOnClient( int fd ) {
137 int bug[4096];
138 //qWarning("new stuff for client on fd %d", fd );
139 errno = 0; 137 errno = 0;
140 OCOPHead head; 138 OCOPHead head;
141 memset(&head, 0, sizeof(head) ); 139 memset(&head, 0, sizeof(head) );
142 int rea = ::read(fd, &head, sizeof(head) ); 140 int rea = ::read(fd, &head, sizeof(head) );
143 //qWarning("read %d %d", rea, errno); 141 //qWarning("read %d %d", rea, errno);
144 /* 142 /*
145 * I should get EPIPE but nothing like this happens 143 * I should get EPIPE but nothing like this happens
146 * so if rea == 0 and we were signaled by the notifier 144 * so if rea == 0 and we were signaled by the notifier
147 * we close it and drop the clients... 145 * we close it and drop the clients...
148 */ 146 */
149 if ( rea <= 0 ) { 147 if ( rea <= 0 ) {
150 deregisterClient( fd ); 148 deregisterClient( fd );
151 return; 149 return;
152 } 150 }
153 /* 151 /*
154 * OCOPHead 152 * OCOPHead
155 */ 153 */
156 qWarning("data %s %d", bug, rea ); 154 //qWarning("data %s %d", &bug, rea );
157 155
158 /* 156 /*
159 * Check the magic 157 * Check the magic
160 * if chcked read till EOF if magic does not match 158 * if chcked read till EOF if magic does not match
161 * otherwise do read 159 * otherwise do read
162 * channel 160 * channel
163 * func 161 * func
164 * data into mem 162 * data into mem
165 * and then send the OCOPPacket 163 * and then send the OCOPPacket
166 * 164 *
167 */ 165 */
168 if (head.magic == 47 ) { 166 if (head.magic == 47 ) {
169 qWarning("magic match"); 167 qWarning("magic match");
170 QCString channel( head.chlen+1 ); 168 QCString channel( head.chlen+1 );
171 QCString func( head.funclen+1 ); 169 QCString func( head.funclen+1 );
172 QByteArray data ( head.datalen ); 170 QByteArray data ( head.datalen );
173 171
174 /* 172 /*
175 * we do not check for errors 173 * we do not check for errors
176 */ 174 */
175 qWarning("read ");
177 int s = read(fd, channel.data(), head.chlen ); 176 int s = read(fd, channel.data(), head.chlen );
178 s = read(fd, func.data(), head.funclen ); 177 s = read(fd, func.data(), head.funclen );
179 s = read(fd, data.data(), head.datalen ); 178 s = read(fd, data.data(), head.datalen );
179 qWarning("read");
180 180
181 /* debug output */ 181 /* debug output */
182 qWarning("channel %s %d", channel.data(), head.chlen ); 182 qWarning("channel %s %d", channel.data(), head.chlen );
183 qWarning("func %s %d", func.data(), head.funclen ); 183 qWarning("func %s %d", func.data(), head.funclen );
184 /* debug end */ 184 /* debug end */
185 185
186 /* 186 /*
187 * now that we got the complete body 187 * now that we got the complete body
188 * we need to make a package 188 * we need to make a package
189 * and then we need to send it to clients 189 * and then we need to send it to clients
190 * making a package is done here 190 * making a package is done here
191 * dispatching it not 191 * dispatching it not
@@ -276,24 +276,25 @@ void OCopServer::dispatch( const OCOPPacket& packet, int sourceFD ) {
276 addChannel( packet.channel() , sourceFD ); 276 addChannel( packet.channel() , sourceFD );
277 break; 277 break;
278 case OCOPPacket::UnregisterChannel: 278 case OCOPPacket::UnregisterChannel:
279 delChannel( packet.channel(), sourceFD ); 279 delChannel( packet.channel(), sourceFD );
280 break; 280 break;
281 /* not implemented */ 281 /* not implemented */
282 case OCOPPacket::Return: 282 case OCOPPacket::Return:
283 break; 283 break;
284 /* not implemented :( */ 284 /* not implemented :( */
285 case OCOPPacket::Signal: 285 case OCOPPacket::Signal:
286 break; 286 break;
287 case OCOPPacket::IsRegistered: 287 case OCOPPacket::IsRegistered:
288 qWarning("IsRegistered");
288 isRegistered( packet.channel(), sourceFD ); 289 isRegistered( packet.channel(), sourceFD );
289 break; 290 break;
290 }; 291 };
291} 292}
292void OCopServer::errorOnServer() { 293void OCopServer::errorOnServer() {
293 /* 294 /*
294 * something is wrong on the server socket? 295 * something is wrong on the server socket?
295 * what should we do? 296 * what should we do?
296 * FIXME 297 * FIXME
297 */ 298 */
298} 299}
299QStringList OCopServer::channels() { 300QStringList OCopServer::channels() {
@@ -331,24 +332,25 @@ void OCopServer::delChannel( const QCString& channel,
331 332
332 QValueList<int> ints = it.data(); 333 QValueList<int> ints = it.data();
333 if ( ints.count() == 1 ) 334 if ( ints.count() == 1 )
334 m_channels.remove( it ); 335 m_channels.remove( it );
335 else{ 336 else{
336 QValueList<int> ints = it.data(); 337 QValueList<int> ints = it.data();
337 ints.remove( fd ); 338 ints.remove( fd );
338 m_channels.replace( it.key(), ints ); 339 m_channels.replace( it.key(), ints );
339 } 340 }
340 } 341 }
341} 342}
342void OCopServer::isRegistered( const QCString& channel, int fd) { 343void OCopServer::isRegistered( const QCString& channel, int fd) {
344 qWarning("isRegistered");
343 OCOPHead head; 345 OCOPHead head;
344 QCString func(2); 346 QCString func(2);
345 347
346 memset(&head, 0, sizeof(head ) ); 348 memset(&head, 0, sizeof(head ) );
347 head.magic = 47; 349 head.magic = 47;
348 head.type = OCOPPacket::IsRegistered; 350 head.type = OCOPPacket::IsRegistered;
349 head.chlen = channel.size(); 351 head.chlen = channel.size();
350 head.funclen = func.size(); 352 head.funclen = func.size();
351 head.datalen = 0; 353 head.datalen = 0;
352 354
353 if ( isChannelRegistered( channel ) ) { 355 if ( isChannelRegistered( channel ) ) {
354 //is registered 356 //is registered
@@ -360,25 +362,25 @@ void OCopServer::isRegistered( const QCString& channel, int fd) {
360 /** 362 /**
361 * write the head 363 * write the head
362 * and then channel 364 * and then channel
363 * success/failure inside func 365 * success/failure inside func
364 */ 366 */
365 write(fd, &head, sizeof(head) ); 367 write(fd, &head, sizeof(head) );
366 write(fd, channel.data(), channel.size() ); 368 write(fd, channel.data(), channel.size() );
367 write(fd, func.data(), func.size() ); 369 write(fd, func.data(), func.size() );
368} 370}
369QValueList<int> OCopServer::clients( const QCString& channel ) { 371QValueList<int> OCopServer::clients( const QCString& channel ) {
370 return m_channels[channel]; 372 return m_channels[channel];
371} 373}
372void OCopServer::call( const OCOPPacket& p, int fd ) { 374void OCopServer::call( const OCOPPacket& p, int ) {
373 QValueList<int> cli = clients( p.channel() ); 375 QValueList<int> cli = clients( p.channel() );
374 QValueList<int>::Iterator it; 376 QValueList<int>::Iterator it;
375 377
376 OCOPHead head = p.head(); 378 OCOPHead head = p.head();
377 for (it = cli.begin(); it != cli.end(); ++it ) { 379 for (it = cli.begin(); it != cli.end(); ++it ) {
378 write( (*it), &head, sizeof(head ) ); 380 write( (*it), &head, sizeof(head ) );
379 /* expl. shared! */ 381 /* expl. shared! */
380 write( (*it), p.channel().data(), p.channel().size() ); 382 write( (*it), p.channel().data(), p.channel().size() );
381 write( (*it), p.header().data(), p.header().size() ); 383 write( (*it), p.header().data(), p.header().size() );
382 write( (*it), p.content().data(), p.content().size() ); 384 write( (*it), p.content().data(), p.content().size() );
383 }; 385 };
384} 386}
diff --git a/x11/ipc/server/ocopserver.pro b/x11/ipc/server/ocopserver.pro
index 1776063..e0a928c 100644
--- a/x11/ipc/server/ocopserver.pro
+++ b/x11/ipc/server/ocopserver.pro
@@ -1,9 +1,10 @@
1 TEMPLATE= app 1 TEMPLATE= app
2DESTDIR = $(OPIEDIR)/bin
2 CONFIG = qt warn_on debug 3 CONFIG = qt warn_on debug
3 #CONFIG = qt warn_on release 4 #CONFIG = qt warn_on release
4 HEADERS = ../common/ocoppacket.h ocopclient.h ocopserver.h 5 HEADERS = ../common/ocoppacket.h ocopclient.h ocopserver.h
5 SOURCES = ../common/ocoppacket.cpp main.cpp ocopserver.cpp 6 SOURCES = ../common/ocoppacket.cpp main.cpp ocopserver.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include 7 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include 8 DEPENDPATH+= $(OPIEDIR)/include
8 TARGET = ocopserver 9 TARGET = ocopserver
9 10