Ticket #781: tst-remote-leak.cc

File tst-remote-leak.cc, 1.1 KB (added by Olly Betts, 5 years ago)

C++ helper

Line 
1/*
2c++ -Iinclude -std=c++14 -o tst-xapian_remote .libs/libxapian-1.5.so -Wl,-rpath ~+/.libs -pthread tst-xapian_remote.cc && ./tst-xapian_remote
3*/
4
5#include <iostream>
6#include <string>
7#include <cstdio>
8#include <cstring>
9#include <cassert>
10#include <thread>
11
12#include <errno.h>
13#include <unistd.h>
14#include <netdb.h>
15#include <sys/socket.h>
16#include <netinet/in.h>
17
18#include <xapian.h>
19
20constexpr const int port = 5050;
21
22int main() {
23 char buf[80];
24 {
25 int fd = dup(1);
26 std::cerr << "First unused fd = " << fd << std::endl;
27 close(fd);
28 sprintf(buf, "%ld", (long)getpid());
29 system(("ls -l /proc/" + std::string(buf) + "/fd").c_str());
30 try {
31 auto wsdb = Xapian::Remote::open_writable("localhost", port, 1000, 1000, Xapian::DB_CREATE_OR_OPEN);
32 std::cerr << "Opened OK" << std::endl;
33 } catch (const Xapian::Error& exc) {
34 std::cerr << exc.get_description() << std::endl;
35 }
36 }
37
38 int fd = dup(1);
39 std::cerr << "First unused fd = " << fd << std::endl;
40 close(fd);
41 sprintf(buf, "%ld", (long)getpid());
42 system(("ls -l /proc/" + std::string(buf) + "/fd").c_str());
43
44 return 0;
45}