[Xapian-tickets] [Xapian] #781: Sockets never closed on RemoteDatabase errors

Xapian nobody at xapian.org
Wed May 1 07:49:19 BST 2019


#781: Sockets never closed on RemoteDatabase errors
----------------------------+-------------------------
 Reporter:  Kronuz          |             Owner:  olly
     Type:  defect          |            Status:  new
 Priority:  high            |         Milestone:
Component:  Backend-Remote  |           Version:
 Severity:  blocker         |        Resolution:
 Keywords:                  |        Blocked By:
 Blocking:                  |  Operating System:  All
----------------------------+-------------------------

Comment (by olly):

 Indeed it seems to be - this shows the first unused fd increasing by 2
 each time (the `sleep(1)` is to allow the server thread time to exit):

 {{{
 --- tst-xapian_remote.cc.orig   2019-05-01 18:37:20.246441957 +1200
 +++ tst-xapian_remote.cc        2019-05-01 18:45:34.599309013 +1200
 @@ -5,6 +5,7 @@
  #include <iostream>
  #include <string>
  #include <cstdio>
 +#include <cstring>
  #include <cassert>
  #include <thread>

 @@ -58,7 +59,7 @@
         }

         struct sockaddr_in serv_addr;
 -       memset(&serv_addr, 0, sizeof(serv_addr));
 +       std::memset(&serv_addr, 0, sizeof(serv_addr));
         serv_addr.sin_family = AF_INET;
         serv_addr.sin_addr.s_addr = INADDR_ANY;
         serv_addr.sin_port = htons(port);
 @@ -86,12 +87,16 @@
  int main() {
         std::thread server(fake_server);

 -       while (true) {
 +       for (int i = 0; i < 10; ++i) {
                 try {
                         auto wsdb =
 Xapian::Remote::open_writable("localhost", port, 10000, 10000,
 Xapian::DB_CREATE_OR_OPEN);
                 } catch (const Xapian::Error& exc) {
                         std::cerr << exc.get_description() << std::endl;
                 }
 +               sleep(1);
 +               int fd = dup(1);
 +               std::cerr << "First unused fd = " << fd << std::endl;
 +               close(fd);
         }

         return 0;
 }}}

--
Ticket URL: <https://trac.xapian.org/ticket/781#comment:11>
Xapian <https://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list