• Fujii Masao's avatar
    Refactor WAL segment copying code. · 7abc6859
    Fujii Masao authored
    * Remove unused argument "dstfname" and related code from XLogFileCopy().
    
    * Previously XLogFileCopy() returned a pstrdup'd string so that
    InstallXLogFileSegment() used it later. Since the pstrdup'd string was never
    free'd, there could be a risk of memory leak. It was almost harmless because
    the startup process exited just after calling XLogFileCopy(), it existed.
    This commit changes XLogFileCopy() so that it directly calls
    InstallXLogFileSegment() and doesn't call pstrdup() at all. Which fixes that
    memory leak problem.
    
    * Extend InstallXLogFileSegment() so that the caller can specify the log level.
    Which allows us to emit an error when InstallXLogFileSegment() fails a disk
    file access like link() and rename(). Previously it was always logged with
    LOG level and additionally needed to be logged with ERROR when we wanted
    to treat it as an error.
    
    Michael Paquier
    7abc6859
xlog.c 358 KB