[Xapian-tickets] [Xapian] #229: Stub databases should be read with msvc_posix_open

Xapian nobody at xapian.org
Tue Dec 27 05:23:00 GMT 2011


#229: Stub databases should be read with msvc_posix_open
-------------------------------+--------------------------------------------
 Reporter:  richard            |        Owner:  richard  
     Type:  defect             |       Status:  assigned 
 Priority:  normal             |    Milestone:           
Component:  Other              |      Version:  SVN trunk
 Severity:  normal             |   Resolution:           
 Keywords:                     |    Blockedby:           
 Platform:  Microsoft Windows  |     Blocking:           
-------------------------------+--------------------------------------------

Old description:

> Currently, stub databases are read using a standard C++ ifstream.  (See
> backends/database.cc, function open_stub())  This works fine, except that
> if a
> user (or the database replication code) tries, on Windows, to atomically
> rename
> a new stub db file over an existing one, it will receive an error if the
> old
> stub DB file was open.
>
> This can be avoided if we instead use msvc_posix_open() (or just open()
> on unix)
> in open_stub() to get a file handle for the stub database, and access it
> using C
> file-handling routines.

New description:

 Currently, stub databases are read using a standard C++ ifstream.  (See
 backends/database.cc, function open_stub())  This works fine, except that
 if a
 user (or the database replication code) tries, on Windows, to atomically
 rename
 a new stub db file over an existing one, it will receive an error if the
 old
 stub DB file was open.

 This can be avoided if we instead use msvc_posix_open() (or just open() on
 unix)
 in open_stub() to get a file handle for the stub database, and access it
 using C
 file-handling routines.

--

Comment(by olly):

 For MSVC it looks like we could just write:

 {{{
 #!cpp
 ifstream stub(msvc_posix_open(file.c_str(), O_RDONLY));
 }}}

 But GCC's libstdc++ doesn't have this non-standard form, so we can't use
 this for mingw, but there is {{{stdio_filebuf}}}, which allows you to wrap
 an fd or FILE*
 as an istream or ostream.  This would allow us to keep the current code
 with only
 minor changes on the affected platform.

 We should perhaps check if iostream imposes an overhead over the C FILE*
 routines,
 and if there is much of one have a policy to avoid istream and ostream
 instead.

 Also which having retry of the whole stub read on read failing is an
 option, another
 is to simply require that the stub update attempt retries.  It is perhaps
 better to
 have the writer blocked by heavy reader activity than have readers blocked
 by heavy writer activity as readers tend to be more performance sensitive.
 wrapping fds like this so the current code works without major changes.

-- 
Ticket URL: <http://trac.xapian.org/ticket/229#comment:6>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list