summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d7416ec)
raw | patch | inline | side by side (parent: d7416ec)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 18 Sep 2007 04:18:20 +0000 (21:18 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 18 Sep 2007 05:02:19 +0000 (22:02 -0700) |
Earlier code took Unix time and appended a few random digits.
If you are firing off many messages within a second, you could
issue the same id to different messages, which is a no-no. If
you send out 31 messages within a single second, with random
integer taken out of rand(4200), you have about 10% chance of
producing the same message ID.
This fixes the problem by uses a prefix string which is
constant-per-invocation (time and pid), with a serial number for
each message generated by the process appended at the end.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
If you are firing off many messages within a second, you could
issue the same id to different messages, which is a no-no. If
you send out 31 messages within a single second, with random
integer taken out of rand(4200), you have about 10% chance of
producing the same message ID.
This fixes the problem by uses a prefix string which is
constant-per-invocation (time and pid), with a serial number for
each message generated by the process appended at the end.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl | patch | blob | history |
diff --git a/git-send-email.perl b/git-send-email.perl
index 195fe6f70a3a13c17b67ad8d067e8e0ff4cc9195..9547cc37a1c4fd326876e26b081bc6d6a5141ce6 100755 (executable)
--- a/git-send-email.perl
+++ b/git-send-email.perl
# We'll setup a template for the message id, using the "from" address:
+my ($message_id_stamp, $message_id_serial);
sub make_message_id
{
- my $date = time;
- my $pseudo_rand = int (rand(4200));
+ my $uniq;
+ if (!defined $message_id_stamp) {
+ $message_id_stamp = sprintf("%s-%s", time, $$);
+ $message_id_serial = 0;
+ }
+ $message_id_serial++;
+ $uniq = "$message_id_stamp-$message_id_serial";
+
my $du_part;
for ($sender, $repocommitter, $repoauthor) {
$du_part = extract_valid_address(sanitize_address($_));
use Sys::Hostname qw();
$du_part = 'user@' . Sys::Hostname::hostname();
}
- my $message_id_template = "<%s-git-send-email-$du_part>";
- $message_id = sprintf $message_id_template, "$date$pseudo_rand";
+ my $message_id_template = "<%s-git-send-email-%s>";
+ $message_id = sprintf($message_id_template, $uniq, $du_part);
#print "new message id = $message_id\n"; # Was useful for debugging
}