summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Jaillet <jailletc36@apache.org>2021-09-05 07:58:57 +0200
committerChristophe Jaillet <jailletc36@apache.org>2021-09-05 07:58:57 +0200
commit0df673fcce55252b1427d8d891f1639b51d71bf1 (patch)
treefecea9040a028e1de7d14bc70458041fc6606210
parentRevert r1887244 and r1887245 which causes issues on Windows (diff)
downloadapache2-0df673fcce55252b1427d8d891f1639b51d71bf1.tar.xz
apache2-0df673fcce55252b1427d8d891f1639b51d71bf1.zip
Reduce the time window where duplicates may be generated by mod_uniqueid
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1892915 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--changes-entries/Reduce_time_window_for_duplicate_in_uniqueid.txt3
-rw-r--r--modules/metadata/mod_unique_id.c13
2 files changed, 9 insertions, 7 deletions
diff --git a/changes-entries/Reduce_time_window_for_duplicate_in_uniqueid.txt b/changes-entries/Reduce_time_window_for_duplicate_in_uniqueid.txt
new file mode 100644
index 0000000000..e8a8f9c033
--- /dev/null
+++ b/changes-entries/Reduce_time_window_for_duplicate_in_uniqueid.txt
@@ -0,0 +1,3 @@
+ *) mod_unique_id: Reduce the time window where duplicates may be generated
+ PR 65159
+ [Christophe Jaillet]
diff --git a/modules/metadata/mod_unique_id.c b/modules/metadata/mod_unique_id.c
index 4a92beaefb..a25ae3fc9b 100644
--- a/modules/metadata/mod_unique_id.c
+++ b/modules/metadata/mod_unique_id.c
@@ -186,7 +186,7 @@ static const char *gen_unique_id(const request_rec *r)
{
char *str;
/*
- * Buffer padded with two final bytes, used to copy the unique_id_red
+ * Buffer padded with two final bytes, used to copy the unique_id_rec
* structure without the internal paddings that it could have.
*/
unique_id_rec new_unique_id;
@@ -199,9 +199,13 @@ static const char *gen_unique_id(const request_rec *r)
int i,j,k;
memcpy(&new_unique_id.root, &cur_unique_id.root, ROOT_SIZE);
- new_unique_id.counter = cur_unique_id.counter;
new_unique_id.stamp = htonl((unsigned int)apr_time_sec(r->request_time));
new_unique_id.thread_index = htonl((unsigned int)r->connection->id);
+ new_unique_id.counter = cur_unique_id.counter;
+
+ /* Increment the identifier for the next call */
+ counter = ntohs(new_unique_id.counter) + 1;
+ cur_unique_id.counter = htons(counter);
/* we'll use a temporal buffer to avoid uuencoding the possible internal
* paddings of the original structure */
@@ -233,11 +237,6 @@ static const char *gen_unique_id(const request_rec *r)
}
str[k++] = '\0';
- /* and increment the identifier for the next call */
-
- counter = ntohs(new_unique_id.counter) + 1;
- cur_unique_id.counter = htons(counter);
-
return str;
}