mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
gwakeup: Clarify buffer sizing in g_wakeup_signal()
The code in g_wakeup_signal() is currently correct: it writes a 64-bit counter increment value if the FD is an eventfd, and writes an arbitrary 8-bit value if using a normal pipe. However, the reasoning behind these buffer sizes is not clear, and the mismatch between the allocated buffer size and the length passed to write() in the pipe case could be mistaken for a bug. Coverity issue: #1159490 https://bugzilla.gnome.org/show_bug.cgi?id=732002
This commit is contained in:
parent
eb6da409fa
commit
6b8ae8f21b
@ -227,19 +227,26 @@ g_wakeup_acknowledge (GWakeup *wakeup)
|
||||
void
|
||||
g_wakeup_signal (GWakeup *wakeup)
|
||||
{
|
||||
guint64 one = 1;
|
||||
int res;
|
||||
|
||||
if (wakeup->fds[1] == -1)
|
||||
{
|
||||
guint64 one = 1;
|
||||
|
||||
/* eventfd() case. It requires a 64-bit counter increment value to be
|
||||
* written. */
|
||||
do
|
||||
res = write (wakeup->fds[0], &one, sizeof one);
|
||||
while (G_UNLIKELY (res == -1 && errno == EINTR));
|
||||
}
|
||||
else
|
||||
{
|
||||
guint8 one = 1;
|
||||
|
||||
/* Non-eventfd() case. Only a single byte needs to be written, and it can
|
||||
* have an arbitrary value. */
|
||||
do
|
||||
res = write (wakeup->fds[1], &one, 1);
|
||||
res = write (wakeup->fds[1], &one, sizeof one);
|
||||
while (G_UNLIKELY (res == -1 && errno == EINTR));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user