Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 78d1091

Browse files
committed
Free walmethods before exiting
Not strictly necessary since we quite after, but could become important in the future if we do restarts etc. Michael Paquier with nitpicking from me
1 parent 8c46f0c commit 78d1091

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

src/bin/pg_basebackup/pg_basebackup.c

+7
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ LogStreamerMain(logstreamer_param *param)
495495
}
496496

497497
PQfinish(param->bgconn);
498+
499+
if (format == 'p')
500+
FreeWalDirectoryMethod();
501+
else
502+
FreeWalTarMethod();
503+
pg_free(stream.walmethod);
504+
498505
return 0;
499506
}
500507

src/bin/pg_basebackup/pg_receivexlog.c

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ StreamLog(void)
352352
}
353353

354354
PQfinish(conn);
355+
356+
FreeWalDirectoryMethod();
357+
pg_free(stream.walmethod);
358+
355359
conn = NULL;
356360
}
357361

src/bin/pg_basebackup/walmethods.c

+18
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,13 @@ CreateWalDirectoryMethod(const char *basedir, bool sync)
299299
return method;
300300
}
301301

302+
void
303+
FreeWalDirectoryMethod(void)
304+
{
305+
pg_free(dir_data->basedir);
306+
pg_free(dir_data);
307+
}
308+
302309

303310
/*-------------------------------------------------------------------------
304311
* WalTarMethod - write wal to a tar file containing pg_xlog contents
@@ -894,3 +901,14 @@ CreateWalTarMethod(const char *tarbase, int compression, bool sync)
894901

895902
return method;
896903
}
904+
905+
void
906+
FreeWalTarMethod(void)
907+
{
908+
pg_free(tar_data->tarfilename);
909+
#ifdef HAVE_LIBZ
910+
if (tar_data->compression)
911+
pg_free(tar_data->zlibOut);
912+
#endif
913+
pg_free(tar_data);
914+
}

src/bin/pg_basebackup/walmethods.h

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ struct WalWriteMethod
4343
*/
4444
WalWriteMethod *CreateWalDirectoryMethod(const char *basedir, bool sync);
4545
WalWriteMethod *CreateWalTarMethod(const char *tarbase, int compression, bool sync);
46+
47+
/* Cleanup routines for previously-created methods */
48+
void FreeWalDirectoryMethod(void);
49+
void FreeWalTarMethod(void);

0 commit comments

Comments
 (0)