diff options
Diffstat (limited to 'trackerlogic.h')
| -rw-r--r-- | trackerlogic.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/trackerlogic.h b/trackerlogic.h index 721ba6e..33dccbe 100644 --- a/trackerlogic.h +++ b/trackerlogic.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <sys/time.h> | 10 | #include <sys/time.h> |
| 11 | #include <time.h> | 11 | #include <time.h> |
| 12 | #include <stdint.h> | 12 | #include <stdint.h> |
| 13 | #include <stdlib.h> | ||
| 13 | 14 | ||
| 14 | typedef uint8_t ot_hash[20]; | 15 | typedef uint8_t ot_hash[20]; |
| 15 | typedef time_t ot_time; | 16 | typedef time_t ot_time; |
| @@ -34,7 +35,7 @@ typedef struct { ot_ip6 address; int bits; } | |||
| 34 | #define OT_TORRENT_TIMEOUT_HOURS 24 | 35 | #define OT_TORRENT_TIMEOUT_HOURS 24 |
| 35 | #define OT_TORRENT_TIMEOUT (60*OT_TORRENT_TIMEOUT_HOURS) | 36 | #define OT_TORRENT_TIMEOUT (60*OT_TORRENT_TIMEOUT_HOURS) |
| 36 | 37 | ||
| 37 | #define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( random( ) % OT_CLIENT_REQUEST_VARIATION ) ) | 38 | #define OT_CLIENT_REQUEST_INTERVAL_RANDOM ( OT_CLIENT_REQUEST_INTERVAL - OT_CLIENT_REQUEST_VARIATION/2 + (int)( nrand48(ws->rand48_state) % OT_CLIENT_REQUEST_VARIATION ) ) |
| 38 | 39 | ||
| 39 | /* If WANT_MODEST_FULLSCRAPES is on, ip addresses may not | 40 | /* If WANT_MODEST_FULLSCRAPES is on, ip addresses may not |
| 40 | fullscrape more frequently than this amount in seconds */ | 41 | fullscrape more frequently than this amount in seconds */ |
| @@ -131,6 +132,10 @@ struct ot_workstruct { | |||
| 131 | ssize_t header_size; | 132 | ssize_t header_size; |
| 132 | char *reply; | 133 | char *reply; |
| 133 | ssize_t reply_size; | 134 | ssize_t reply_size; |
| 135 | |||
| 136 | /* Entropy state for rand48 function so that threads don't need to acquire mutexes for | ||
| 137 | global random() or arc4random() state, which causes heavy load on linuxes */ | ||
| 138 | uint16_t rand48_state[3]; | ||
| 134 | }; | 139 | }; |
| 135 | 140 | ||
| 136 | /* | 141 | /* |
