"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/dbus-daemon.c" between
dbus-1.12.16.tar.gz and dbus-1.12.18.tar.gz

About: D-Bus is an inter-process communication (IPC) system, allowing multiple, concurrently-running applications to communicate with one another. D-Bus supplies both a system daemon and a per-user-login-session daemon.

dbus-daemon.c  (dbus-1.12.16):dbus-daemon.c  (dbus-1.12.18)
skipping to change at line 2043 skipping to change at line 2043
#define DESIRED_RLIMIT 65536 #define DESIRED_RLIMIT 65536
#ifdef DBUS_UNIX #ifdef DBUS_UNIX
static void static void
test_fd_limit (Fixture *f, test_fd_limit (Fixture *f,
gconstpointer context) gconstpointer context)
{ {
#ifdef HAVE_PRLIMIT #ifdef HAVE_PRLIMIT
struct rlimit lim; struct rlimit lim;
struct rlimit new_limit;
const struct passwd *pwd = NULL; const struct passwd *pwd = NULL;
#endif #endif
if (f->skip) if (f->skip)
return; return;
#ifdef HAVE_PRLIMIT #ifdef HAVE_PRLIMIT
if (getuid () != 0) if (getuid () != 0)
{ {
skipping to change at line 2070 skipping to change at line 2071
{ {
gchar *message = g_strdup_printf ("user '%s' does not exist", gchar *message = g_strdup_printf ("user '%s' does not exist",
DBUS_USER); DBUS_USER);
g_test_skip (message); g_test_skip (message);
g_free (message); g_free (message);
return; return;
} }
if (prlimit (getpid (), RLIMIT_NOFILE, NULL, &lim) < 0) if (prlimit (getpid (), RLIMIT_NOFILE, NULL, &lim) < 0)
g_error ("prlimit(): %s", g_strerror (errno)); g_error ("get prlimit (self): %s", g_strerror (errno));
g_test_message ("our RLIMIT_NOFILE: rlim_cur: %ld, rlim_max: %ld", g_test_message ("our RLIMIT_NOFILE: rlim_cur: %ld, rlim_max: %ld",
(long) lim.rlim_cur, (long) lim.rlim_max); (long) lim.rlim_cur, (long) lim.rlim_max);
if (lim.rlim_cur == RLIM_INFINITY || lim.rlim_cur >= DESIRED_RLIMIT) if (lim.rlim_cur == RLIM_INFINITY || lim.rlim_cur >= DESIRED_RLIMIT)
{ {
/* The dbus-daemon will have inherited our large rlimit */ /* The dbus-daemon will have inherited our large rlimit */
g_test_skip ("Cannot test, our own fd limit was already large"); g_test_skip ("Cannot test, our own fd limit was already large");
return; return;
} }
new_limit = lim;
new_limit.rlim_cur = DESIRED_RLIMIT;
new_limit.rlim_max = DESIRED_RLIMIT;
/* Try to increase the rlimit ourselves. If we're root in an
* unprivileged Linux container, then we won't have CAP_SYS_RESOURCE
* and this will fail with EPERM. If so, the dbus-daemon wouldn't be
* able to increase its rlimit either. */
if (prlimit (getpid (), RLIMIT_NOFILE, &new_limit, NULL) < 0)
{
gchar *message;
message = g_strdup_printf ("Cannot test, we cannot change the rlimit so "
"presumably neither can the dbus-daemon: %s",
g_strerror (errno));
g_test_skip (message);
g_free (message);
return;
}
/* Immediately put our original limit back so it won't interfere with
* subsequent tests. This should always succeed. */
if (prlimit (getpid (), RLIMIT_NOFILE, &lim, NULL) < 0)
g_error ("Cannot restore our original limits: %s", g_strerror (errno));
if (prlimit (f->daemon_pid, RLIMIT_NOFILE, NULL, &lim) < 0) if (prlimit (f->daemon_pid, RLIMIT_NOFILE, NULL, &lim) < 0)
g_error ("prlimit(): %s", g_strerror (errno)); g_error ("get prlimit (dbus-daemon): %s", g_strerror (errno));
g_test_message ("dbus-daemon's RLIMIT_NOFILE: rlim_cur: %ld, rlim_max: %ld", g_test_message ("dbus-daemon's RLIMIT_NOFILE: rlim_cur: %ld, rlim_max: %ld",
(long) lim.rlim_cur, (long) lim.rlim_max); (long) lim.rlim_cur, (long) lim.rlim_max);
if (lim.rlim_cur != RLIM_INFINITY) if (lim.rlim_cur != RLIM_INFINITY)
g_assert_cmpint (lim.rlim_cur, >=, DESIRED_RLIMIT); g_assert_cmpint (lim.rlim_cur, >=, DESIRED_RLIMIT);
#else /* !HAVE_PRLIMIT */ #else /* !HAVE_PRLIMIT */
g_test_skip ("prlimit() not supported on this platform"); g_test_skip ("prlimit() not supported on this platform");
 End of changes. 4 change blocks. 
2 lines changed or deleted 28 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)