2 * @brief TCP/IP replication client class.
4 /* Copyright (C) 2008,2010,2011,2015 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "replicatetcpclient.h"
25 #include "api/replication.h"
27 #include "socket_utils.h"
28 #include "tcpclient.h"
32 ReplicateTcpClient::ReplicateTcpClient(const string
& hostname
, int port
,
33 double timeout_connect
,
34 double socket_timeout
)
35 : socket(open_socket(hostname
, port
, timeout_connect
)),
38 set_socket_timeouts(socket
, socket_timeout
);
42 ReplicateTcpClient::open_socket(const string
& hostname
, int port
,
43 double timeout_connect
)
45 return TcpClient::open_socket(hostname
, port
, timeout_connect
, false);
49 ReplicateTcpClient::update_from_master(const std::string
& path
,
50 const std::string
& masterdb
,
51 Xapian::ReplicationInfo
& info
,
52 double reader_close_time
,
55 Xapian::DatabaseReplica
replica(path
);
56 remconn
.send_message('R',
57 force_copy
? string() : replica
.get_revision_info(),
59 remconn
.send_message('D', masterdb
, 0.0);
60 replica
.set_read_fd(socket
);
64 Xapian::ReplicationInfo subinfo
;
65 more
= replica
.apply_next_changeset(&subinfo
, reader_close_time
);
66 info
.changeset_count
+= subinfo
.changeset_count
;
67 info
.fullcopy_count
+= subinfo
.fullcopy_count
;
73 ReplicateTcpClient::~ReplicateTcpClient()