summaryrefslogtreecommitdiff
path: root/util/message_server_port.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-03-02 16:27:35 -0500
committerEliot Horowitz <eliot@10gen.com>2009-03-02 16:27:35 -0500
commit062213eaef50f266771c8dd622b9cd0d9ef68cfe (patch)
treee8896ae2cb019d63c80966f2eb54c49f741f5f0a /util/message_server_port.cpp
parent474d2c0d2465a686c01ed8a9f22deb485281563f (diff)
downloadmongo-062213eaef50f266771c8dd622b9cd0d9ef68cfe.tar.gz
work on old versions of boost
Diffstat (limited to 'util/message_server_port.cpp')
-rw-r--r--util/message_server_port.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/util/message_server_port.cpp b/util/message_server_port.cpp
index e73792c3047..321a849b3d5 100644
--- a/util/message_server_port.cpp
+++ b/util/message_server_port.cpp
@@ -7,16 +7,16 @@
namespace mongo {
- class PortMessageServer : public MessageServer , public Listener {
- public:
- PortMessageServer( int port , MessageHandler * handler ) :
- MessageServer( port , handler ) ,
- Listener( port ){
+ namespace pms {
- }
-
- void threadRun( MessagingPort * p ){
- assert( p );
+ MessagingPort * grab = 0;
+ MessageHandler * handler;
+
+ void threadRun(){
+ assert( grab );
+ MessagingPort * p = grab;
+ grab = 0;
+
Message m;
try {
while ( 1 ){
@@ -28,17 +28,34 @@ namespace mongo {
break;
}
- _handler->process( m , p );
+ handler->process( m , p );
}
}
catch ( ... ){
problem() << "uncaught exception in PortMessageServer::threadRun, closing connection" << endl;
delete p;
- }
+ }
+
+ }
+
+ }
+
+ class PortMessageServer : public MessageServer , public Listener {
+ public:
+ PortMessageServer( int port , MessageHandler * handler ) :
+ MessageServer( port , handler ) ,
+ Listener( port ){
+
+ uassert( "multiple PortMessageServer not supported" , ! pms::handler );
+ pms::handler = handler;
}
virtual void accepted(MessagingPort * p) {
- boost::thread thr( bind( &PortMessageServer::threadRun , this , p ) );
+ assert( ! pms::grab );
+ pms::grab = p;
+ boost::thread thr( pms::threadRun );
+ while ( pms::grab )
+ sleepmillis(1);
}
void run(){