Adrian Bunk <bunk@kernel.org> writes:The old code generated rand(4200) for each message and appended it to the timestamp. I do not know where the original author got 4200 from, but I think if you send many messages within a single second it is possible to get collisions. I guess something like this patch is an improvement? It generates a single prefix from timestamp and random, and appends a number that is incremented for each message. --- diff --git a/git-send-email.perl b/git-send-email.perl index dd7560b..e250732 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -477,10 +477,18 @@ sub extract_valid_address { # 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, int(rand(4200))); + $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($_)); @@ -490,8 +498,8 @@ sub make_message_id 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 } -
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Arjan van de Ven | [Announce] Development release 0.1 of the LatencyTOP tool |
| Andrew Morton | -mm merge plans for 2.6.23 |
| Greg Kroah-Hartman | [PATCH 020/196] IDE: Convert from class_device to device for ide-tape |
git: | |
| Tantilov, Emil S | RE: [PATCH] net: sk_alloc() should not blindly overwrite memory |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 0/37] dccp: Feature negotiation - last call for comments |
