Compare commits

...

3 Commits

Author SHA1 Message Date
Vladimir Dubrovin
451b3d180c Allow hashtables to grow index
Some checks failed
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
2026-04-24 21:08:57 +03:00
Vladimir Dubrovin
f63a83f554 Fix blake2 for watcom 2026-04-24 18:13:30 +03:00
Vladimir Dubrovin
6b61cfde4c Fix for older Windows (7 and below) / VC 2026-04-24 17:04:03 +03:00
6 changed files with 36 additions and 12 deletions

View File

@ -823,7 +823,7 @@ int doauth(struct clientparam * param){
(res = (*authfuncs->authorize)(param)))
return res;
if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){
struct authcache ac={};
struct authcache ac={.username=""};
if(param->username) strncpy((char *)ac.username, (char *)param->username, 64);
if(*SAFAMILY(&param->sincr) == AF_INET

View File

@ -153,6 +153,7 @@ int start_proxy_thread(struct child * chp){
pthread_t thread;
#ifdef _WIN32
HANDLE h;
DWORD num;
#endif
char r[1];
@ -171,7 +172,7 @@ int start_proxy_thread(struct child * chp){
pthread_attr_destroy(&pa);
#endif
#ifdef _WIN32
ReadFile(conf.threadinit[0], r, 1, NULL, NULL);
ReadFile(conf.threadinit[0], r, 1, &num, NULL);
#else
while(read(conf.threadinit[0], r, 1) !=1) if(errno != EINTR) {
fprintf(stderr, "pipe failed\n");

View File

@ -8,8 +8,8 @@ struct hashentry {
char value[4];
};
static uint32_t hashindex(struct hashtable *ht, const uint8_t* hash){
return (*(unsigned *)hash ) % (ht->tablesize);
static uint32_t hashindex(unsigned tablesize, const uint8_t* hash){
return (*(unsigned *)hash) % tablesize;
}
@ -135,6 +135,27 @@ static void hashgrow(struct hashtable *ht){
hvalue(ht,newsize)->inext = ht->ihashempty;
ht->ihashempty = ht->poolsize + 1;
ht->poolsize = newsize;
if (ht->poolsize / ht->tablesize > 10) {
unsigned newtablesize = ht->poolsize / 3;
uint32_t *newitable = myalloc(newtablesize * sizeof(uint32_t));
if (newitable) {
unsigned j;
memset(newitable, 0, newtablesize * sizeof(uint32_t));
for (j = 0; j < ht->tablesize; j++) {
uint32_t he = ht->ihashtable[j];
while (he) {
uint32_t next = hvalue(ht, he)->inext;
unsigned idx = hashindex(newtablesize, hhash(ht, he));
hvalue(ht, he)->inext = newitable[idx];
newitable[idx] = he;
he = next;
}
}
myfree(ht->ihashtable);
ht->ihashtable = newitable;
ht->tablesize = newtablesize;
}
}
}
@ -153,7 +174,7 @@ void hashadd(struct hashtable *ht, const void* name, const void* value, time_t e
ht->index2hash(ht, name, hash);
pthread_mutex_lock(&hash_mutex);
index = hashindex(ht, hash);
index = hashindex(ht->tablesize, hash);
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
if(hvalue(ht,he)->expires < conf.time || !memcmp(hash, hhash(ht,he), ht->hash_size)) {
@ -201,7 +222,7 @@ int hashresolv(struct hashtable *ht, const void* name, void* value, uint32_t *tt
}
ht->index2hash(ht,name, hash);
pthread_mutex_lock(&hash_mutex);
index = hashindex(ht, hash);
index = hashindex(ht->tablesize, hash);
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
if(hvalue(ht, he)->expires < conf.time) {
(*hep) = hvalue(ht,he)->inext;

View File

@ -18,7 +18,9 @@
#include <stddef.h>
#include <stdint.h>
#if defined(_MSC_VER)
#if defined(WATCOM)
#define BLAKE2_PACKED(x) _Packed x
#elif defined(_MSC_VER)
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
#else
#define BLAKE2_PACKED(x) x __attribute__((packed))

View File

@ -279,7 +279,7 @@ SSL_CONN ssl_handshake_to_server(SOCKET s, char * hostname, SSL_CONFIG *config,
#endif
do {
struct pollfd fds[1] = {{}};
struct pollfd fds[1] = {{INVALID_SOCKET}};
int sslerr;
err = SSL_connect(conn->ssl);
@ -350,7 +350,7 @@ SSL_CONN ssl_handshake_to_client(SOCKET s, SSL_CONFIG *config, X509 *server_cert
SSL_set_fd(conn->ssl, s);
do {
struct pollfd fds[1] = {{}};
struct pollfd fds[1] = {{INVALID_SOCKET}};
int sslerr;
err = SSL_accept(conn->ssl);

View File

@ -116,11 +116,11 @@ void * threadfunc (void *p) {
#undef param
int pushthreadinit(){
return
#ifdef _WIN32
WriteFile(conf.threadinit[1], "1", 1, NULL, NULL);
DWORD n;
return WriteFile(conf.threadinit[1], "1", 1, &n, NULL);
#else
write(conf.threadinit[1], "1", 1);
return write(conf.threadinit[1], "1", 1);
#endif
}