8000 We don't need to use a ranom value for our ECHO liveness challenge. · phpredis/phpredis@c139de3 · GitHub
[go: up one dir, main page]

Skip to content

Commit c139de3

Browse files
We don't need to use a ranom value for our ECHO liveness challenge.
A microsecond resolution timestamp combined with a monotonically incremented counter should be sufficient. This also fixes PHP 8.4 compilation as PHP 8.4 doesn't seem to have `php_rand()`.
1 parent dab6a62 commit c139de3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2886,11 +2886,13 @@ redis_sock_create(char *host, int host_len, int port,
28862886
}
28872887

28882888
static int redis_uniqid(char *buf, size_t buflen) {
2889+
static unsigned long counter = 0;
28892890
struct timeval tv;
2891+
28902892
gettimeofday(&tv, NULL);
28912893

28922894
return snprintf(buf, buflen, "phpredis:%08lx%05lx:%08lx",
2893-
(long)tv.tv_sec, (long)tv.tv_usec, (long)php_rand());
2895+
(long)tv.tv_sec, (long)tv.tv_usec, counter++);
28942896
}
28952897

28962898
static int redis_stream_liveness_check(php_stream *stream) {

0 commit comments

Comments
 (0)
0