summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-04-04 13:12:38 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-04-04 13:22:45 +0300
commit7d1e0e8d7a96ac2be5c3ce0e68a5c4eb65fccff2 (patch)
tree0d3e3ed78dc2e99304161c7676fcf8138d1ebc68 /src/backend/access/transam/xlog.c
parent6c1cfbacb9f92454a91d2898da84772fc6eeddd7 (diff)
Avoid allocations in critical sections.
If a palloc in a critical section fails, it becomes a PANIC.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index e245aa6ef8a..2f715903245 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2449,6 +2449,7 @@ XLogFileInit(uint32 log, uint32 seg,
{
char path[MAXPGPATH];
char tmppath[MAXPGPATH];
+ char zbuffer_raw[BLCKSZ + MAXIMUM_ALIGNOF];
char *zbuffer;
uint32 installed_log;
uint32 installed_seg;
@@ -2506,11 +2507,11 @@ XLogFileInit(uint32 log, uint32 seg,
* fdatasync(2) or O_DSYNC will be sufficient to sync future writes to the
* log file.
*
- * Note: palloc zbuffer, instead of just using a local char array, to
- * ensure it is reasonably well-aligned; this may save a few cycles
- * transferring data to the kernel.
+ * Note: ensure the buffer is reasonably well-aligned; this may save a few
+ * cycles transferring data to the kernel.
*/
- zbuffer = (char *) palloc0(XLOG_BLCKSZ);
+ zbuffer = (char *) MAXALIGN(zbuffer_raw);
+ memset(zbuffer, 0, BLCKSZ);
for (nbytes = 0; nbytes < XLogSegSize; nbytes += XLOG_BLCKSZ)
{
errno = 0;
@@ -2530,7 +2531,6 @@ XLogFileInit(uint32 log, uint32 seg,
errmsg("could not write to file \"%s\": %m", tmppath)));
}
}
- pfree(zbuffer);
if (pg_fsync(fd) != 0)
ereport(ERROR,