New bookkeeper hash broke NfSen. Fixed. ported back to release 1.6.17

This commit is contained in:
Peter Haag 2018-05-06 11:10:51 +02:00
parent ec91b397c3
commit 11f9159138
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,6 @@
2018-05-06
- New bookkeeper hash broke NfSen. Fixed. ported back to release 1.6.17
2018-04-20
- Release 1.6.17

View File

@ -43,6 +43,7 @@
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
@ -83,15 +84,21 @@ static inline bookkeeper_list_t *Get_bookkeeper_list_entry(bookkeeper_t *bookkee
static uint32_t hash(char *str, int flag) {
uint32_t h;
unsigned char *p;
char cleanPath[MAXPATHLEN];
if ( realpath(str, cleanPath) == NULL ) {
return 0;
}
h = 0;
for (p = (unsigned char*)str; *p != '\0'; p++)
for (p = (unsigned char*)cleanPath; *p != '\0'; p++)
h = MULTIPLIER * h + *p;
if ( flag ) {
h = MULTIPLIER * h + 'R';
}
return h; // or, h % ARRAY_SIZE;
} // End of hash
// locks the semaphore, for exclusive access to the bookkeeping record