diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-04-04 13:12:38 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2014-04-04 13:32:40 +0300 |
commit | 895243d69ba1972157d8d2644efbf87d557abec3 (patch) | |
tree | b348f19bede0cbe2fd12c3f0a9ed08848f0e9586 /src/backend/access/transam/xlog.c | |
parent | 447e23737cc82489258f9b2564fac68cf834188f (diff) | |
download | postgresql-895243d69ba1972157d8d2644efbf87d557abec3.tar.gz postgresql-895243d69ba1972157d8d2644efbf87d557abec3.zip |
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.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 42ec2fe71de..6b9209d882a 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -2348,6 +2348,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; @@ -2405,11 +2406,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; @@ -2429,7 +2430,6 @@ XLogFileInit(uint32 log, uint32 seg, errmsg("could not write to file \"%s\": %m", tmppath))); } } - pfree(zbuffer); if (pg_fsync(fd) != 0) ereport(ERROR, |