xapian-core  2.0.0
remotetcpserver.cc
Go to the documentation of this file.
1 
4 /* Copyright 1999,2000,2001 BrightStation PLC
5  * Copyright 2002 Ananova Ltd
6  * Copyright 2002,2003,2004,2005,2006,2007,2008,2010,2015 Olly Betts
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of the
11  * License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, see
20  * <https://www.gnu.org/licenses/>.
21  */
22 
23 #include <config.h>
24 
25 #include "remotetcpserver.h"
26 
27 #include <xapian/error.h>
28 
29 #include "net/remoteserver.h"
30 
31 #include <iostream>
32 
33 using namespace std;
34 
36 RemoteTcpServer::RemoteTcpServer(const vector<std::string> &dbpaths_,
37  const std::string & host, int port,
38  double active_timeout_, double idle_timeout_,
39  bool writable_, bool verbose_)
40  : TcpServer(host, port, true, verbose_),
41  dbpaths(dbpaths_), writable(writable_),
42  active_timeout(active_timeout_), idle_timeout(idle_timeout_)
43 {
44 }
45 
46 void
48 {
49  try {
50  RemoteServer sserv(dbpaths, socket, socket,
52  sserv.set_registry(reg);
53  sserv.run();
54  } catch (const Xapian::NetworkTimeoutError &e) {
55  if (verbose)
56  cerr << "Connection timed out: " << e.get_description() << '\n';
57  } catch (const Xapian::Error &e) {
58  cerr << "Got exception " << e.get_description() << '\n';
59  } catch (...) {
60  // ignore other exceptions
61  }
62 }
Remote backend server base class.
Definition: remoteserver.h:36
void set_registry(const Xapian::Registry &reg_)
Set the registry used for (un)serialisation.
Definition: remoteserver.h:271
void run()
Repeatedly accept messages from the client and process them.
double active_timeout
Timeout between messages during a single operation (in seconds).
const std::vector< std::string > dbpaths
Paths to the databases we will open.
RemoteTcpServer(const RemoteTcpServer &)
Don't allow copying.
void handle_one_connection(int socket)
Handle a single connection on an already connected socket.
double idle_timeout
Timeout between operations (in seconds).
Xapian::Registry reg
Registry used for (un)serialisation.
bool writable
Is this a WritableDatabase?
All exceptions thrown by Xapian are subclasses of Xapian::Error.
Definition: error.h:41
std::string get_description() const
Return a string describing this object.
Definition: error.cc:93
Indicates a timeout expired while communicating with a remote database.
Definition: error.h:833
Hierarchy of classes which Xapian can throw as exceptions.
#define true
Definition: header.h:8
Xapian remote backend server base class.
TCP/IP socket based server for RemoteDatabase.
static int verbose
Definition: xapian-delve.cc:46