Merge branch 'fdpass' into 'master'

Fix fd limit handling in fdpass test

Closes #176

See merge request dbus/dbus!479
This commit is contained in:
Simon McVittie 2024-10-14 19:24:43 +00:00
commit c59108890a

View file

@ -674,10 +674,27 @@ test_flood (Fixture *f,
unsigned int i, j;
DBusMessage *outgoing[SOME_MESSAGES];
dbus_uint32_t serial;
#ifdef HAVE_GETRLIMIT
struct rlimit lim;
#endif
if (f->skip)
return;
#ifdef HAVE_GETRLIMIT
if (getrlimit (RLIMIT_NOFILE, &lim) == 0)
{
if (lim.rlim_cur != RLIM_INFINITY &&
/* only run if we have a fairly generous margin of error
* for stdout, stderr, duplicates, the D-Bus connection, etc. */
lim.rlim_cur < 2 * MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES)
{
g_test_skip ("not enough RLIMIT_NOFILE to run this test");
return;
}
}
#endif
test_connect (f, TRUE);
for (j = 0; j < SOME_MESSAGES; j++)
@ -910,14 +927,14 @@ main (int argc,
if (getrlimit (RLIMIT_NOFILE, &lim) < 0)
g_error ("Failed to get RLIMIT_NOFILE limit: %s", g_strerror (errno));
if (lim.rlim_cur != RLIM_INFINITY &&
/* only run if we have a fairly generous margin of error
* for stdout, stderr, duplicates, the D-Bus connection, etc. */
lim.rlim_cur < 2 * MAX_MESSAGE_UNIX_FDS * SOME_MESSAGES)
if ((lim.rlim_cur != RLIM_INFINITY) && (lim.rlim_cur < lim.rlim_max))
{
g_message ("not enough RLIMIT_NOFILE to run this test");
/* Autotools exit code for "all skipped" */
return 77;
/* Many test require large number of file descriptors,
* so max out what they can use */
lim.rlim_cur = lim.rlim_max;
if (setrlimit (RLIMIT_NOFILE, &lim) < 0)
g_error ("Failed to set RLIMIT_NOFILE limit to %ld: %s",
(long) lim.rlim_cur, g_strerror (errno));
}
}
#endif