teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.12.0-tslock-nowait.patch

Panu Matilainen 96d481
commit 6ce2d43e2533505aa252159bfa8cc799965655bb
Panu Matilainen 96d481
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 96d481
Date:   Wed Oct 1 09:59:21 2014 +0300
Panu Matilainen 96d481
Panu Matilainen 96d481
    Dont wait for transaction lock within scriptlets (RhBug:1135596)
Panu Matilainen 96d481
    
Panu Matilainen 96d481
    - Packages doing stupid things like rpm -U/-i/-e from their scriptlets
Panu Matilainen 96d481
      can and will get hung waiting on the transaction lock, which can
Panu Matilainen 96d481
      prompt users to kill the entire transaction, possibly with severe
Panu Matilainen 96d481
      consequences. Starting with rpm >= 4.12 we also take the transaction
Panu Matilainen 96d481
      lock for importing public keys, which seems to have caught one of
Panu Matilainen 96d481
      the bigger fishes in the pond (Google Chrome packages).
Panu Matilainen 96d481
    - Only wait when stdin is a tty, this affects more than scriptlets but
Panu Matilainen 96d481
      most likely we dont want to wait for locks in those situations either.
Panu Matilainen 96d481
Panu Matilainen 96d481
diff --git a/lib/rpmlock.c b/lib/rpmlock.c
Panu Matilainen 96d481
index 7696cbe..9c07654 100644
Panu Matilainen 96d481
--- a/lib/rpmlock.c
Panu Matilainen 96d481
+++ b/lib/rpmlock.c
Panu Matilainen 96d481
@@ -124,10 +124,11 @@ rpmlock rpmlockNew(const char *lock_path, const char *descr)
Panu Matilainen 96d481
 int rpmlockAcquire(rpmlock lock)
Panu Matilainen 96d481
 {
Panu Matilainen 96d481
     int locked = 0; /* assume failure */
Panu Matilainen 96d481
+    int maywait = isatty(STDIN_FILENO); /* dont wait within scriptlets */
Panu Matilainen 96d481
 
Panu Matilainen 96d481
     if (lock) {
Panu Matilainen 96d481
 	locked = rpmlock_acquire(lock, RPMLOCK_WRITE);
Panu Matilainen 96d481
-	if (!locked && (lock->openmode & RPMLOCK_WRITE)) {
Panu Matilainen 96d481
+	if (!locked && (lock->openmode & RPMLOCK_WRITE) && maywait) {
Panu Matilainen 96d481
 	    rpmlog(RPMLOG_WARNING, _("waiting for %s lock on %s\n"),
Panu Matilainen 96d481
 		    lock->descr, lock->path);
Panu Matilainen 96d481
 	    locked = rpmlock_acquire(lock, (RPMLOCK_WRITE|RPMLOCK_WAIT));