{
ReplicationSlotOnDisk cp;
int i;
+ char slotdir[MAXPGPATH + 12];
char path[MAXPGPATH + 22];
int fd;
bool restored = false;
/* no need to lock here, no concurrent access allowed yet */
/* delete temp file if it exists */
- sprintf(path, "pg_replslot/%s/state.tmp", name);
+ sprintf(slotdir, "pg_replslot/%s", name);
+ sprintf(path, "%s/state.tmp", slotdir);
if (unlink(path) < 0 && errno != ENOENT)
ereport(PANIC,
(errcode_for_file_access(),
errmsg("could not remove file \"%s\": %m", path)));
- sprintf(path, "pg_replslot/%s/state", name);
+ sprintf(path, "%s/state", slotdir);
elog(DEBUG1, "restoring replication slot from \"%s\"", path);
/* Also sync the parent directory */
START_CRIT_SECTION();
- fsync_fname(path, true);
+ fsync_fname(slotdir, true);
END_CRIT_SECTION();
/* read part of statefile that's guaranteed to be version independent */
*/
if (cp.slotdata.persistency != RS_PERSISTENT)
{
- sprintf(path, "pg_replslot/%s", name);
-
- if (!rmtree(path, true))
+ if (!rmtree(slotdir, true))
{
ereport(WARNING,
(errcode_for_file_access(),
- errmsg("could not remove directory \"%s\"", path)));
+ errmsg("could not remove directory \"%s\"", slotdir)));
}
fsync_fname("pg_replslot", true);
return;