Ok. I added a comment and also fixed a small typo.
diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index 3fbe0e5..a96fb7b 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -485,35 +485,40 @@ CreateWaitEventSet(MemoryContext context, int nevents)
char *data;
Size sz = 0;
- sz += sizeof(WaitEventSet);
- sz += sizeof(WaitEvent) * nevents;
+ /*
+ * struct epoll_event contains a uint64_t which on some architectures
+ * requires 8-byte alignment and just to be safe be prepared for future
+ * additions of other such elements later in the WaitEventSet structure
+ */
+ sz += MAXALIGN(sizeof(WaitEventSet));
+ sz += MAXALIGN(sizeof(WaitEvent) * nevents);
#if defined(WAIT_USE_EPOLL)
- sz += sizeof(struct epoll_event) * nevents;
+ sz += MAXALIGN(sizeof(struct epoll_event) * nevents);
#elif defined(WAIT_USE_POLL)
- sz += sizeof(struct pollfd) * nevents;
+ sz += MAXALIGN(sizeof(struct pollfd) * nevents);
#elif defined(WAIT_USE_WIN32)
/* need space for the pgwin32_signal_event */
- sz += sizeof(HANDLE) * (nevents + 1);
+ sz += MAXALIGN(sizeof(HANDLE) * (nevents + 1));
#endif
data = (char *) MemoryContextAllocZero(context, sz);
set = (WaitEventSet *) data;
- data += sizeof(WaitEventSet);
+ data += MAXALIGN(sizeof(WaitEventSet));
set->events = (WaitEvent *) data;
- data += sizeof(WaitEvent) * nevents;
+ data += MAXALIGN(sizeof(WaitEvent) * nevents);
#if defined(WAIT_USE_EPOLL)
set->epoll_ret_events = (struct epoll_event *) data;
- data += sizeof(struct epoll_event) * nevents;
+ data += MAXALIGN(sizeof(struct epoll_event) * nevents);
#elif defined(WAIT_USE_POLL)
set->pollfds = (struct pollfd *) data;
- data += sizeof(struct pollfd) * nevents;
+ data += MAXALIGN(sizeof(struct pollfd) * nevents);
#elif defined(WAIT_USE_WIN32)
set->handles = (HANDLE) data;
- data += sizeof(HANDLE) * nevents;
+ data += MAXALIGN(sizeof(HANDLE) * nevents);
#endif
set->latch = NULL;
@@ -616,7 +621,7 @@ AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch,
if (set->latch)
elog(ERROR, "cannot wait on more than one latch");
if ((events & WL_LATCH_SET) != WL_LATCH_SET)
- elog(ERROR, "latch events only spuport being set");
+ elog(ERROR, "latch events only support being set");
}
else
{
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers