diff options
| -rw-r--r-- | ot_accesslist.c | 13 | ||||
| -rw-r--r-- | ot_accesslist.h | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/ot_accesslist.c b/ot_accesslist.c index 86fb128..17ed73e 100644 --- a/ot_accesslist.c +++ b/ot_accesslist.c | |||
| @@ -202,10 +202,14 @@ static void accesslist_readfile(void) { | |||
| 202 | #ifdef WANT_DYNAMIC_ACCESSLIST | 202 | #ifdef WANT_DYNAMIC_ACCESSLIST |
| 203 | /* If we have dynamic accesslists, reloading a new one will always void the add/delete lists. | 203 | /* If we have dynamic accesslists, reloading a new one will always void the add/delete lists. |
| 204 | Insert empty ones at the list head */ | 204 | Insert empty ones at the list head */ |
| 205 | if (g_accesslist_add && (accesslist_new = accesslist_make(g_accesslist_add, 0)) != NULL) | 205 | if (g_accesslist_add && (accesslist_new = accesslist_make(g_accesslist_add, 0)) != NULL) { |
| 206 | g_accesslist_add->base = g_now_minutes; | ||
| 206 | g_accesslist_add = accesslist_new; | 207 | g_accesslist_add = accesslist_new; |
| 207 | if (g_accesslist_delete && (accesslist_new = accesslist_make(g_accesslist_delete, 0)) != NULL) | 208 | } |
| 209 | if (g_accesslist_delete && (accesslist_new = accesslist_make(g_accesslist_delete, 0)) != NULL) { | ||
| 210 | g_accesslist_delete->base = g_now_minutes; | ||
| 208 | g_accesslist_delete = accesslist_new; | 211 | g_accesslist_delete = accesslist_new; |
| 212 | } | ||
| 209 | #endif | 213 | #endif |
| 210 | 214 | ||
| 211 | accesslist_clean(g_accesslist); | 215 | accesslist_clean(g_accesslist); |
| @@ -213,7 +217,7 @@ static void accesslist_readfile(void) { | |||
| 213 | pthread_mutex_unlock(&g_accesslist_mutex); | 217 | pthread_mutex_unlock(&g_accesslist_mutex); |
| 214 | } | 218 | } |
| 215 | 219 | ||
| 216 | int accesslist_hashisvalid(ot_hash hash) { | 220 | int accesslist_hashisvalid(const ot_hash hash) { |
| 217 | /* Get working copy of current access list */ | 221 | /* Get working copy of current access list */ |
| 218 | ot_accesslist *accesslist = g_accesslist; | 222 | ot_accesslist *accesslist = g_accesslist; |
| 219 | #ifdef WANT_DYNAMIC_ACCESSLIST | 223 | #ifdef WANT_DYNAMIC_ACCESSLIST |
| @@ -320,6 +324,7 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic | |||
| 320 | if (accesslist_new) { | 324 | if (accesslist_new) { |
| 321 | memcpy(accesslist_new->list, (*removing_from)->list, sizeof(ot_hash) * off); | 325 | memcpy(accesslist_new->list, (*removing_from)->list, sizeof(ot_hash) * off); |
| 322 | memcpy(accesslist_new->list + off, (*removing_from)->list + off + 1, (*removing_from)->size - off - 1); | 326 | memcpy(accesslist_new->list + off, (*removing_from)->list + off + 1, (*removing_from)->size - off - 1); |
| 327 | (*removing_from)->base = g_now_minutes; | ||
| 323 | *removing_from = accesslist_new; | 328 | *removing_from = accesslist_new; |
| 324 | } | 329 | } |
| 325 | } | 330 | } |
| @@ -330,6 +335,7 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic | |||
| 330 | ot_accesslist *accesslist_new = accesslist_make(NULL, 1); | 335 | ot_accesslist *accesslist_new = accesslist_make(NULL, 1); |
| 331 | if (accesslist_new) { | 336 | if (accesslist_new) { |
| 332 | memcpy(accesslist_new->list, info_hash, sizeof(ot_hash)); | 337 | memcpy(accesslist_new->list, info_hash, sizeof(ot_hash)); |
| 338 | (*adding_to)->base = g_now_minutes; | ||
| 333 | *adding_to = accesslist_new; | 339 | *adding_to = accesslist_new; |
| 334 | } | 340 | } |
| 335 | } else { | 341 | } else { |
| @@ -344,6 +350,7 @@ static void *accesslist_adddel_worker(char *fifoname, ot_accesslist *_Atomic | |||
| 344 | memcpy(accesslist_new->list, (*adding_to)->list, sizeof(ot_hash) * off); | 350 | memcpy(accesslist_new->list, (*adding_to)->list, sizeof(ot_hash) * off); |
| 345 | memcpy(accesslist_new->list + off, info_hash, sizeof(info_hash)); | 351 | memcpy(accesslist_new->list + off, info_hash, sizeof(info_hash)); |
| 346 | memcpy(accesslist_new->list + off + 1, (*adding_to)->list + off, (*adding_to)->size - off); | 352 | memcpy(accesslist_new->list + off + 1, (*adding_to)->list + off, (*adding_to)->size - off); |
| 353 | (*adding_to)->base = g_now_minutes; | ||
| 347 | *adding_to = accesslist_new; | 354 | *adding_to = accesslist_new; |
| 348 | } | 355 | } |
| 349 | } | 356 | } |
diff --git a/ot_accesslist.h b/ot_accesslist.h index b3e979d..30aaebd 100644 --- a/ot_accesslist.h +++ b/ot_accesslist.h | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #define WANT_ACCESSLIST | 16 | #define WANT_ACCESSLIST |
| 17 | void accesslist_init(void); | 17 | void accesslist_init(void); |
| 18 | void accesslist_deinit(void); | 18 | void accesslist_deinit(void); |
| 19 | int accesslist_hashisvalid(ot_hash hash); | 19 | int accesslist_hashisvalid(const ot_hash hash); |
| 20 | void accesslist_cleanup(void); | 20 | void accesslist_cleanup(void); |
| 21 | 21 | ||
| 22 | /* Scan buf for up to capacity info_hashes in hexadecimal notation, one per | 22 | /* Scan buf for up to capacity info_hashes in hexadecimal notation, one per |
