git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Riedy <ejr@EECS.Berkeley.EDU>
To: git@vger.kernel.org
Subject: Re: Solaris cloning woes partly diagnosed
Date: Sun, 02 Apr 2006 12:52:35 -0700	[thread overview]
Message-ID: <824.1144007555@lotus.CS.Berkeley.EDU> (raw)
In-Reply-To: <Pine.LNX.4.64.0604021159110.3050@g5.osdl.org>

And Linus Torvalds writes:
 - 
 - so it really really looks like fgets() would have problems with a SIGALRM 
 - coming in and doesn't just re-try on EINTR. Can Solaris stdio _really_ be 
 - that broken? (Yeah, yeah, it may be "conforming". It's also so incredibly 
 - programmer-unfriendly that it's not even funny)

Yes, it is that broken.  I haven't encountered the problem 
consistently in git myself, so I can't tell you if the patch 
works.  Google finds similar reports and patches for BOINC, ruby,
and a few other projects.

Solaris folks will say you should be using sigaction with
SA_RESTART.  IIRC, SA_RESTART isn't guaranteed to be there 
or work, but all the systems I deal with right now have it.
So an alternate patch for this one use is appended...  Other
uses of signal could be changed to sigaction, too.  And
progress_update "should" be sig_atomic_t.

Passes the pack-objects tests, but I can't make the problem 
happen on demand.  (I have seen it occur before, but never
during make test, and I'd not tracked it down...)

Jason
----
diff --git a/pack-objects.c b/pack-objects.c
index ccfaa5f..1faa0bb 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -877,10 +877,21 @@ static int try_delta(struct unpacked *cu
 	return 0;
 }
 
-static void progress_interval(int signum)
+static void progress_interval(int);
+
+static void setup_progress_signal(void)
+{
+	struct sigaction sa;
+	sa.sa_handler = progress_interval;
+	sigemptyset(&sa.sa_mask);
+	sa.sa_flags = SA_RESTART;
+	sigaction(SIGALRM, &sa, NULL);
+}
+
+void progress_interval(int signum)
 {
-	signal(SIGALRM, progress_interval);
 	progress_update = 1;
+	setup_progress_signal();
 }
 
 static void find_deltas(struct object_entry **list, int window, int depth)
@@ -1094,7 +1105,7 @@ int main(int argc, char **argv)
 		v.it_interval.tv_sec = 1;
 		v.it_interval.tv_usec = 0;
 		v.it_value = v.it_interval;
-		signal(SIGALRM, progress_interval);
+		setup_progress_signal();
 		setitimer(ITIMER_REAL, &v, NULL);
 		fprintf(stderr, "Generating pack...\n");
 	}

  reply	other threads:[~2006-04-02 19:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-02 10:41 Solaris cloning woes partly diagnosed Junio C Hamano
2006-04-02 18:33 ` Linus Torvalds
2006-04-02 19:10   ` Jason Riedy
2006-04-02 19:22     ` Linus Torvalds
2006-04-02 19:18   ` Linus Torvalds
2006-04-02 19:52     ` Jason Riedy [this message]
2006-04-02 20:28       ` Linus Torvalds
2006-04-02 20:31         ` [PATCH 2/2] pack-objects: be incredibly anal about stdio semantics Linus Torvalds
2006-04-02 21:09           ` Junio C Hamano
2006-04-02 21:21             ` Linus Torvalds
2006-04-02 22:12               ` Jason Riedy
2006-04-02 22:58                 ` Linus Torvalds
2006-04-02 22:29         ` [PATCH] Use sigaction and SA_RESTART in read-tree.c; add option in Makefile Jason Riedy
2006-04-03  1:02           ` Linus Torvalds
2006-04-03  4:20           ` Junio C Hamano
2006-04-03  4:40             ` Linus Torvalds
2006-04-03  3:06     ` Solaris cloning woes partly diagnosed Linus Torvalds
2006-04-04 18:21   ` H. Peter Anvin
2006-04-04  8:47 ` [RFH] Solaris cloning woes Junio C Hamano
2006-04-04 18:53   ` Jason Riedy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=824.1144007555@lotus.CS.Berkeley.EDU \
    --to=ejr@eecs.berkeley.edu \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).