Commit Graph

5 Commits

Author SHA1 Message Date
Panu Matilainen b13a81d02a Merge RPMDB_CLEAR into RPMDB_INIT, they're never used separately
If we need to init, we need an empty database. Having these separate
is a historical artifact from the early days of the test-suite.
2020-06-12 13:18:56 +03:00
Panu Matilainen 41cf6f9c80 Clean up and improve rpmlog error handling + reporting
Centralize the log failure printing to a helper function, handle
the common conditions there. Remember the last error and only
print a new one if the error differs to avoid unnecessary flooding.
Finally, make the actual message more concise and mark it for i18n.
Oh and add a testcase as well.

This will still try to perror() in vain even if it's stderr that's
returning the errors in the first place, but maybe that's perror()'s
problem and not ours.
2018-08-07 14:17:19 +03:00
Panu Matilainen 50c380e9e0 Disable two of the sigpipe tests, they're too unstable
Tests that fail half the time due to load on machines etc are
more trouble than its worth.
2017-08-10 20:21:26 +03:00
Panu Matilainen 9085009544 Fix regression on SIGPIPE from scriptlet killing (RhBug:1264198)
Commit 90d8cc1648 changed SIGPIPE to
be ignored during scriptlet execution - nothing wrong with that, at
that time. However since commit c5f82d3f62
we're *blocking* most signals, and contrary to what glibc manual states [*]
ignored signals are in no way special: they get queued up in the pending
set just like everything else. When unblocked, they are handled by
the signal handler active at the time of unblocking. Which means that
ignoring and then restoring handlers for scriptlets does absolutely
nothing at all in practise.

So instead, make SIGPIPE ignored for the duration of the whole
transaction on rpmsq side, and only restore the old handler
after unblocking the signals at end of transaction.

This doesn't magically make things 100% correct either, ultimately
we should probably handle signals instead of blocking during the main
transaction: we should filter out ANYTHING originating from scriptlets,
something else might make sense to queue up. Or not... Anyway, this'll
have to do for now.

[*] Quoting from https://www.gnu.org/software/libc/manual/html_node/Delivery-of-Signal.html#Delivery-of-Signal as of today:

    If the specified action for a kind of signal is to ignore it, then any
    such signal which is generated is discarded immediately. This happens
    even if the signal is also blocked at the time. A signal discarded in
    this way will never be delivered, not even if the program subsequently
    specifies a different action for that kind of signal and then unblocks it.

This clearly is NOT the case, at least in the case of Linux kernel which
explicitly notes this specific case since 2003'ish (from kernel/signal.c):

        /*
         * Blocked signals are never ignored, since the
         * signal handler may change by the time it is
         * unblocked.
         */
2017-05-10 15:20:06 +03:00
Panu Matilainen 5e51d2bf70 Add some SIGPIPE test cases
Test for SIGPIPE behavior in three different cases:
- build scriptlets ought to have SIGPIPE working as usual (RhBug:651463)
- SIGPIPE received from install scriptlet (RhBug:1264198) which currently
  fails because we end up exiting on that signal after the transaction.
  The original case involves file triggers, we simulate it by kill'ing
  for simplicitys sake.
- query involving --pipe (RhBug:444389)

Should test for RhBug:471591 too but need a simpler reproducer than
in the bug, leaving that to some rainy day.
2017-05-10 13:59:33 +03:00