1
// message_server_port.cpp
3
/* Copyright 2009 10gen Inc.
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
21
#include "message_server.h"
27
MessagingPort * grab = 0;
28
MessageHandler * handler;
32
MessagingPort * p = grab;
41
log() << "end connection " << p->farEnd.toString() << endl;
46
handler->process( m , p );
50
problem() << "uncaught exception in PortMessageServer::threadRun, closing connection" << endl;
58
class PortMessageServer : public MessageServer , public Listener {
60
PortMessageServer( int port , MessageHandler * handler ) :
61
MessageServer( port , handler ) ,
64
uassert( 10275 , "multiple PortMessageServer not supported" , ! pms::handler );
65
pms::handler = handler;
68
virtual void accepted(MessagingPort * p) {
69
assert( ! pms::grab );
71
boost::thread thr( pms::threadRun );
84
MessageServer * createServer( int port , MessageHandler * handler ){
85
return new PortMessageServer( port , handler );