chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
manager: refuse reloading/reexecing when /run is overly full
[elogind.git]
/
src
/
libelogind
/
sd-bus
/
bus-bloom.c
diff --git
a/src/libelogind/sd-bus/bus-bloom.c
b/src/libelogind/sd-bus/bus-bloom.c
index 3556774074c38ad9d3492d8f9cde0652bcc55891..112769fcb6d964299e94606f5a1cdb34f37b199f 100644
(file)
--- a/
src/libelogind/sd-bus/bus-bloom.c
+++ b/
src/libelogind/sd-bus/bus-bloom.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-19,9
+17,9
@@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "util.h"
-#include "siphash24.h"
#include "bus-bloom.h"
#include "bus-bloom.h"
+#include "siphash24.h"
+#include "util.h"
static inline void set_bit(uint64_t filter[], unsigned long b) {
filter[b >> 6] |= 1ULL << (b & 63);
static inline void set_bit(uint64_t filter[], unsigned long b) {
filter[b >> 6] |= 1ULL << (b & 63);
@@
-45,7
+43,7
@@
static void bloom_add_data(
const void *data, /* Data to hash */
size_t n) { /* Size of data to hash in bytes */
const void *data, /* Data to hash */
size_t n) { /* Size of data to hash in bytes */
- uint
8_t h[8]
;
+ uint
64_t h
;
uint64_t m;
unsigned w, i, c = 0;
unsigned hash_index;
uint64_t m;
unsigned w, i, c = 0;
unsigned hash_index;
@@
-72,11
+70,11
@@
static void bloom_add_data(
for (d = 0; d < w; d++) {
if (c <= 0) {
for (d = 0; d < w; d++) {
if (c <= 0) {
-
siphash24(h,
data, n, hash_keys[hash_index++].bytes);
+
h = siphash24(
data, n, hash_keys[hash_index++].bytes);
c += 8;
}
c += 8;
}
- p = (p << 8ULL) | (uint64_t)
h
[8 - c];
+ p = (p << 8ULL) | (uint64_t)
((uint8_t *)&h)
[8 - c];
c--;
}
c--;
}
@@
-116,11
+114,19
@@
void bloom_add_prefixes(uint64_t filter[], size_t size, unsigned k, const char *
p = stpcpy(stpcpy(c, a), ":");
strcpy(p, b);
p = stpcpy(stpcpy(c, a), ":");
strcpy(p, b);
+ bloom_add_data(filter, size, k, c, n);
+
for (;;) {
char *e;
e = strrchr(p, sep);
for (;;) {
char *e;
e = strrchr(p, sep);
- if (!e || e == p)
+ if (!e)
+ break;
+
+ *(e + 1) = 0;
+ bloom_add_data(filter, size, k, c, e - c + 1);
+
+ if (e == p)
break;
*e = 0;
break;
*e = 0;