Remove linux futext implementation
Some checks are pending
Build Win32 3proxy-lite with Watcom / ${{ matrix.target }} (windows-2022) (push) Waiting to run
Build Win32 3proxy with MSVC / ${{ matrix.target }} (windows-2022) (push) Waiting to run
Build Win64 3proxy with MSVC / ${{ matrix.target }} (windows-2022) (push) Waiting to run
Build Win-arm64 3proxy with MSVC / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run

This commit is contained in:
Vladimir Dubrovin 2026-04-28 18:06:54 +03:00
parent d125261e8c
commit b1ac46da79
16 changed files with 134 additions and 180 deletions

View File

@ -66,9 +66,9 @@ void __stdcall CommandHandler( DWORD dwCommand )
Sleep(2000); Sleep(2000);
SetStatus( SERVICE_STOPPED, 0, 0 ); SetStatus( SERVICE_STOPPED, 0, 0 );
#ifndef NOODBC #ifndef NOODBC
pthread_mutex_lock(&log_mutex); _3proxy_mutex_lock(&log_mutex);
close_sql(); close_sql();
pthread_mutex_unlock(&log_mutex); _3proxy_mutex_unlock(&log_mutex);
#endif #endif
break; break;
case SERVICE_CONTROL_PAUSE: case SERVICE_CONTROL_PAUSE:
@ -118,13 +118,6 @@ void mysigpause (int sig){
void mysigterm (int sig){ void mysigterm (int sig){
conf.paused++; conf.paused++;
usleep(999*SLEEPTIME);
usleep(999*SLEEPTIME);
#ifndef NOODBC
pthread_mutex_lock(&log_mutex);
close_sql();
pthread_mutex_unlock(&log_mutex);
#endif
conf.timetoexit = 1; conf.timetoexit = 1;
} }
@ -512,13 +505,13 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
return 1; return 1;
} }
pthread_mutex_init(&config_mutex, NULL); _3proxy_mutex_init(&config_mutex);
pthread_mutex_init(&bandlim_mutex, NULL); _3proxy_mutex_init(&bandlim_mutex);
pthread_mutex_init(&connlim_mutex, NULL); _3proxy_mutex_init(&connlim_mutex);
pthread_mutex_init(&tc_mutex, NULL); _3proxy_mutex_init(&tc_mutex);
pthread_mutex_init(&log_mutex, NULL); _3proxy_mutex_init(&log_mutex);
#ifndef NORADIUS #ifndef NORADIUS
pthread_mutex_init(&rad_mutex, NULL); _3proxy_mutex_init(&rad_mutex);
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
conf.threadinit = CreateSemaphore(NULL, 0, 1, NULL); conf.threadinit = CreateSemaphore(NULL, 0, 1, NULL);
@ -527,7 +520,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
return 1; return 1;
} }
#else #else
pthread_mutex_init(&conf.threadinit, NULL); _3proxy_mutex_init(&conf.threadinit);
#endif #endif
freeconf(&conf); freeconf(&conf);

View File

@ -20,13 +20,13 @@ int alwaysauth(struct clientparam * param){
res = doconnect(param); res = doconnect(param);
if(!res){ if(!res){
if(conf.bandlimfunc && (conf.bandlimiter||conf.bandlimiterout)){ if(conf.bandlimfunc && (conf.bandlimiter||conf.bandlimiterout)){
pthread_mutex_lock(&bandlim_mutex); _3proxy_mutex_lock(&bandlim_mutex);
initbandlims(param); initbandlims(param);
pthread_mutex_unlock(&bandlim_mutex); _3proxy_mutex_unlock(&bandlim_mutex);
} }
if(conf.trafcountfunc && conf.trafcounter) { if(conf.trafcountfunc && conf.trafcounter) {
pthread_mutex_lock(&tc_mutex); _3proxy_mutex_lock(&tc_mutex);
for(tc = conf.trafcounter; tc; tc = tc->next) { for(tc = conf.trafcounter; tc; tc = tc->next) {
if(tc->disabled) continue; if(tc->disabled) continue;
if(ACLmatches(tc->ace, param)){ if(ACLmatches(tc->ace, param)){
@ -40,7 +40,7 @@ int alwaysauth(struct clientparam * param){
if(tc->ace->action != COUNTALL) continue; if(tc->ace->action != COUNTALL) continue;
} }
if(tc->traflim64 <= tc->traf64) { if(tc->traflim64 <= tc->traf64) {
pthread_mutex_unlock(&tc_mutex); _3proxy_mutex_unlock(&tc_mutex);
return 10; return 10;
} }
param->trafcountfunc = conf.trafcountfunc; param->trafcountfunc = conf.trafcountfunc;
@ -55,14 +55,14 @@ int alwaysauth(struct clientparam * param){
continue; continue;
} }
if(tc->traflim64 <= tc->traf64) { if(tc->traflim64 <= tc->traf64) {
pthread_mutex_unlock(&tc_mutex); _3proxy_mutex_unlock(&tc_mutex);
return 10; return 10;
} }
param->trafcountfunc = conf.trafcountfunc; param->trafcountfunc = conf.trafcountfunc;
param->maxtrafout64 = tc->traflim64 - tc->traf64; param->maxtrafout64 = tc->traflim64 - tc->traf64;
} }
} }
pthread_mutex_unlock(&tc_mutex); _3proxy_mutex_unlock(&tc_mutex);
} }
} }
return res; return res;

View File

@ -166,7 +166,7 @@ static int ntry = 0;
int nradservers = 0; int nradservers = 0;
char radiussecret[64]=""; char radiussecret[64]="";
pthread_mutex_t rad_mutex; _3proxy_mutex_t rad_mutex;
void md5_calc(unsigned char *output, unsigned char *input, void md5_calc(unsigned char *output, unsigned char *input,
unsigned int inputlen); unsigned int inputlen);
@ -327,11 +327,11 @@ int radsend(struct clientparam * param, int auth, int stop){
memset(&packet, 0, sizeof(packet)); memset(&packet, 0, sizeof(packet));
pthread_mutex_lock(&rad_mutex); _3proxy_mutex_lock(&rad_mutex);
if(auth)random_vector(packet.vector, param); if(auth)random_vector(packet.vector, param);
id = ((ntry++) & 0xff); id = ((ntry++) & 0xff);
pthread_mutex_unlock(&rad_mutex); _3proxy_mutex_unlock(&rad_mutex);
packet.code = auth?PW_AUTHENTICATION_REQUEST:PW_ACCOUNTING_REQUEST; packet.code = auth?PW_AUTHENTICATION_REQUEST:PW_ACCOUNTING_REQUEST;
packet.id=id; packet.id=id;

View File

@ -38,35 +38,6 @@ int randomizer = 1;
unsigned char **stringtable = NULL; unsigned char **stringtable = NULL;
#ifdef WITH_LINUX_FUTEX
int sys_futex(void *addr1, int op, int val1, struct timespec *timeout, void *addr2, int val3)
{
return syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3);
}
int mutex_lock(int *val)
{
int c;
if ((c = __sync_val_compare_and_swap(val, 0, 1)) != 0)
do {
if(c == 2 || __sync_val_compare_and_swap(val, 1, 2) != 0)
sys_futex(val, FUTEX_WAIT_PRIVATE, 2, NULL, NULL, 0);
} while ((c = __sync_val_compare_and_swap(val, 0, 2)) != 0);
return 0;
}
int mutex_unlock(int *val)
{
if(__sync_fetch_and_sub (val, 1) != 1){
*val = 0;
sys_futex(val, FUTEX_WAKE_PRIVATE, 1, NULL, NULL, 0);
}
return 0;
}
#endif
#ifdef WITH_UN #ifdef WITH_UN
void make_un(const unsigned char *path, struct sockaddr_un * sun){ void make_un(const unsigned char *path, struct sockaddr_un * sun){
memset(sun, 0, sizeof(*sun)); memset(sun, 0, sizeof(*sun));
@ -691,7 +662,7 @@ int scanaddr(const unsigned char *s, uint32_t * ip, uint32_t * mask) {
RESOLVFUNC resolvfunc = NULL; RESOLVFUNC resolvfunc = NULL;
#ifndef _WIN32 #ifndef _WIN32
pthread_mutex_t gethostbyname_mutex; _3proxy_mutex_t gethostbyname_mutex;
int ghbn_init = 0; int ghbn_init = 0;
#endif #endif
@ -747,10 +718,10 @@ uint32_t getip(unsigned char *name){
#ifndef NOSTDRESOLVE #ifndef NOSTDRESOLVE
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R) #if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
if(!ghbn_init){ if(!ghbn_init){
pthread_mutex_init(&gethostbyname_mutex, NULL); _3proxy_mutex_init(&gethostbyname_mutex);
ghbn_init++; ghbn_init++;
} }
pthread_mutex_lock(&gethostbyname_mutex); _3proxy_mutex_lock(&gethostbyname_mutex);
#endif #endif
hp=gethostbyname((char *)name); hp=gethostbyname((char *)name);
if (!hp && conf.demanddialprog) { if (!hp && conf.demanddialprog) {
@ -759,7 +730,7 @@ uint32_t getip(unsigned char *name){
} }
retval = hp?*(uint32_t *)hp->h_addr:0; retval = hp?*(uint32_t *)hp->h_addr:0;
#if !defined(_WIN32) && !defined(GETHOSTBYNAME_R) #if !defined(_WIN32) && !defined(GETHOSTBYNAME_R)
pthread_mutex_unlock(&gethostbyname_mutex); _3proxy_mutex_unlock(&gethostbyname_mutex);
#endif #endif
#ifdef GETHOSTBYNAME_R #ifdef GETHOSTBYNAME_R
#undef gethostbyname #undef gethostbyname

View File

@ -20,10 +20,10 @@
#define DEFAULTCONFIG conf.stringtable[25] #define DEFAULTCONFIG conf.stringtable[25]
#endif #endif
pthread_mutex_t bandlim_mutex; _3proxy_mutex_t bandlim_mutex;
pthread_mutex_t connlim_mutex; _3proxy_mutex_t connlim_mutex;
pthread_mutex_t tc_mutex; _3proxy_mutex_t tc_mutex;
pthread_mutex_t config_mutex; _3proxy_mutex_t config_mutex;
int haveerror = 0; int haveerror = 0;
int linenum = 0; int linenum = 0;
@ -164,15 +164,15 @@ int start_proxy_thread(struct child * chp){
pthread_attr_init(&pa); pthread_attr_init(&pa);
pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (32768+conf.stacksize)); pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (32768+conf.stacksize));
pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED);
pthread_mutex_lock(&conf.threadinit); _3proxy_mutex_lock(&conf.threadinit);
pthread_create(&thread, &pa, startsrv, (void *)chp); pthread_create(&thread, &pa, startsrv, (void *)chp);
pthread_attr_destroy(&pa); pthread_attr_destroy(&pa);
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
WaitForSingleObject(conf.threadinit, INFINITE); WaitForSingleObject(conf.threadinit, INFINITE);
#else #else
pthread_mutex_lock(&conf.threadinit); _3proxy_mutex_lock(&conf.threadinit);
pthread_mutex_unlock(&conf.threadinit); _3proxy_mutex_unlock(&conf.threadinit);
#endif #endif
if(haveerror) { if(haveerror) {
fprintf(stderr, "Service not started on line: %d%s\n", linenum, haveerror == 2? ": insufficient memory":""); fprintf(stderr, "Service not started on line: %d%s\n", linenum, haveerror == 2? ": insufficient memory":"");
@ -337,10 +337,10 @@ static int h_log(int argc, unsigned char ** argv){
else if(*argv[1]=='&'){ else if(*argv[1]=='&'){
conf.logfunc = logsql; conf.logfunc = logsql;
if(notchanged) return 0; if(notchanged) return 0;
pthread_mutex_lock(&log_mutex); _3proxy_mutex_lock(&log_mutex);
close_sql(); close_sql();
init_sql((char *)argv[1]+1); init_sql((char *)argv[1]+1);
pthread_mutex_unlock(&log_mutex); _3proxy_mutex_unlock(&log_mutex);
} }
#endif #endif
#ifndef NORADIUS #ifndef NORADIUS
@ -1257,7 +1257,7 @@ static int h_ace(int argc, unsigned char **argv){
sscanf((char *)argv[1], "%u", &ncl->rate); sscanf((char *)argv[1], "%u", &ncl->rate);
sscanf((char *)argv[2], "%u", &ncl->period); sscanf((char *)argv[2], "%u", &ncl->period);
} }
pthread_mutex_lock(&connlim_mutex); _3proxy_mutex_lock(&connlim_mutex);
if(!conf.connlimiter){ if(!conf.connlimiter){
conf.connlimiter = ncl; conf.connlimiter = ncl;
} }
@ -1267,7 +1267,7 @@ static int h_ace(int argc, unsigned char **argv){
for(cli = conf.connlimiter; cli->next; cli = cli->next); for(cli = conf.connlimiter; cli->next; cli = cli->next);
cli->next = ncl; cli->next = ncl;
} }
pthread_mutex_unlock(&connlim_mutex); _3proxy_mutex_unlock(&connlim_mutex);
break; break;
case BANDLIM: case BANDLIM:
@ -1289,7 +1289,7 @@ static int h_ace(int argc, unsigned char **argv){
return(4); return(4);
} }
} }
pthread_mutex_lock(&bandlim_mutex); _3proxy_mutex_lock(&bandlim_mutex);
if(!strcmp((char *)argv[0], "bandlimin") || !strcmp((char *)argv[0], "nobandlimin")){ if(!strcmp((char *)argv[0], "bandlimin") || !strcmp((char *)argv[0], "nobandlimin")){
if(!conf.bandlimiter){ if(!conf.bandlimiter){
conf.bandlimiter = nbl; conf.bandlimiter = nbl;
@ -1313,7 +1313,7 @@ static int h_ace(int argc, unsigned char **argv){
} }
} }
conf.bandlimver++; conf.bandlimver++;
pthread_mutex_unlock(&bandlim_mutex); _3proxy_mutex_unlock(&bandlim_mutex);
break; break;
case COUNTIN: case COUNTIN:
@ -1365,7 +1365,7 @@ static int h_ace(int argc, unsigned char **argv){
} }
} }
} }
pthread_mutex_lock(&tc_mutex); _3proxy_mutex_lock(&tc_mutex);
if(!conf.trafcounter){ if(!conf.trafcounter){
conf.trafcounter = tl; conf.trafcounter = tl;
} }
@ -1375,7 +1375,7 @@ static int h_ace(int argc, unsigned char **argv){
for(ntl = conf.trafcounter; ntl->next; ntl = ntl->next); for(ntl = conf.trafcounter; ntl->next; ntl = ntl->next);
ntl->next = tl; ntl->next = tl;
} }
pthread_mutex_unlock(&tc_mutex); _3proxy_mutex_unlock(&tc_mutex);
} }
return 0; return 0;
@ -1856,27 +1856,27 @@ void freeconf(struct extparam *confp){
pthread_mutex_lock(&tc_mutex); _3proxy_mutex_lock(&tc_mutex);
confp->trafcountfunc = NULL; confp->trafcountfunc = NULL;
tc = confp->trafcounter; tc = confp->trafcounter;
confp->trafcounter = NULL; confp->trafcounter = NULL;
counterd = confp->counterd; counterd = confp->counterd;
confp->counterd = -1; confp->counterd = -1;
confp->countertype = NONE; confp->countertype = NONE;
pthread_mutex_unlock(&tc_mutex); _3proxy_mutex_unlock(&tc_mutex);
pthread_mutex_lock(&bandlim_mutex); _3proxy_mutex_lock(&bandlim_mutex);
bl = confp->bandlimiter; bl = confp->bandlimiter;
blout = confp->bandlimiterout; blout = confp->bandlimiterout;
confp->bandlimiter = NULL; confp->bandlimiter = NULL;
confp->bandlimiterout = NULL; confp->bandlimiterout = NULL;
confp->bandlimfunc = NULL; confp->bandlimfunc = NULL;
confp->bandlimver++; confp->bandlimver++;
pthread_mutex_unlock(&bandlim_mutex); _3proxy_mutex_unlock(&bandlim_mutex);
pthread_mutex_lock(&connlim_mutex); _3proxy_mutex_lock(&connlim_mutex);
cl = confp->connlimiter; cl = confp->connlimiter;
confp->connlimiter = NULL; confp->connlimiter = NULL;
pthread_mutex_unlock(&connlim_mutex); _3proxy_mutex_unlock(&connlim_mutex);
destroyhashtable(&pw_table); destroyhashtable(&pw_table);
destroyhashtable(&pwnt_table); destroyhashtable(&pwnt_table);
@ -1949,7 +1949,7 @@ int reload (void){
FILE *fp; FILE *fp;
int error = -2; int error = -2;
pthread_mutex_lock(&config_mutex); _3proxy_mutex_lock(&config_mutex);
conf.paused++; conf.paused++;
freeconf(&conf); freeconf(&conf);
conf.paused++; conf.paused++;
@ -1963,6 +1963,6 @@ int reload (void){
} }
if(!writable)fclose(fp); if(!writable)fclose(fp);
} }
pthread_mutex_unlock(&config_mutex); _3proxy_mutex_unlock(&config_mutex);
return error; return error;
} }

View File

@ -12,7 +12,7 @@ static uint32_t hashindex(unsigned tablesize, const uint8_t* hash){
void destroyhashtable(struct hashtable *ht){ void destroyhashtable(struct hashtable *ht){
pthread_mutex_lock(&ht->hash_mutex); _3proxy_mutex_lock(&ht->hash_mutex);
if(ht->ihashtable){ if(ht->ihashtable){
myfree(ht->ihashtable); myfree(ht->ihashtable);
ht->ihashtable = NULL; ht->ihashtable = NULL;
@ -28,8 +28,8 @@ void destroyhashtable(struct hashtable *ht){
ht->poolsize = 0; ht->poolsize = 0;
ht->tablesize = 0; ht->tablesize = 0;
ht->ihashempty = 0; ht->ihashempty = 0;
pthread_mutex_unlock(&ht->hash_mutex); _3proxy_mutex_unlock(&ht->hash_mutex);
pthread_mutex_destroy(&ht->hash_mutex); _3proxy_mutex_destroy(&ht->hash_mutex);
} }
#define hvalue(ht,I) ((struct hashentry *)(ht->hashvalues + (I-1)*(sizeof(struct hashentry) + ht->recsize - 4))) #define hvalue(ht,I) ((struct hashentry *)(ht->hashvalues + (I-1)*(sizeof(struct hashentry) + ht->recsize - 4)))
@ -53,7 +53,7 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
if(tablesize < 2 || poolsize < tablesize || growlimit < poolsize) return 1; if(tablesize < 2 || poolsize < tablesize || growlimit < poolsize) return 1;
if(ht->ihashtable){ if(ht->ihashtable){
pthread_mutex_lock(&ht->hash_mutex); _3proxy_mutex_lock(&ht->hash_mutex);
if(ht->ihashtable){ if(ht->ihashtable){
myfree(ht->ihashtable); myfree(ht->ihashtable);
ht->ihashtable = NULL; ht->ihashtable = NULL;
@ -70,8 +70,8 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
ht->tablesize = 0; ht->tablesize = 0;
} }
else { else {
pthread_mutex_init(&ht->hash_mutex, NULL); _3proxy_mutex_init(&ht->hash_mutex);
pthread_mutex_lock(&ht->hash_mutex); _3proxy_mutex_lock(&ht->hash_mutex);
} }
if(!(ht->ihashtable = myalloc(tablesize * sizeof(uint32_t))) if(!(ht->ihashtable = myalloc(tablesize * sizeof(uint32_t)))
|| !(ht->hashvalues = myalloc(poolsize * (sizeof(struct hashentry) + ht->recsize - 4))) || !(ht->hashvalues = myalloc(poolsize * (sizeof(struct hashentry) + ht->recsize - 4)))
@ -81,7 +81,7 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
ht->ihashtable = NULL; ht->ihashtable = NULL;
myfree(ht->hashvalues); myfree(ht->hashvalues);
ht->hashvalues = NULL; ht->hashvalues = NULL;
pthread_mutex_unlock(&ht->hash_mutex); _3proxy_mutex_unlock(&ht->hash_mutex);
return 3; return 3;
} }
ht->poolsize = poolsize; ht->poolsize = poolsize;
@ -94,7 +94,7 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
hvalue(ht,i)->inext = i+1; hvalue(ht,i)->inext = i+1;
} }
ht->ihashempty = 1; ht->ihashempty = 1;
pthread_mutex_unlock(&ht->hash_mutex); _3proxy_mutex_unlock(&ht->hash_mutex);
return 0; return 0;
} }
@ -179,7 +179,7 @@ void hashadd(struct hashtable *ht, void* name, void* value, time_t expires){
} }
ht->index2hash_add(ht, name, hash); ht->index2hash_add(ht, name, hash);
pthread_mutex_lock(&ht->hash_mutex); _3proxy_mutex_lock(&ht->hash_mutex);
index = hashindex(ht->tablesize, hash); index = hashindex(ht->tablesize, hash);
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){ for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
@ -214,7 +214,7 @@ void hashadd(struct hashtable *ht, void* name, void* value, time_t expires){
hvalue(ht,hen)->expires = expires; hvalue(ht,hen)->expires = expires;
} }
pthread_mutex_unlock(&ht->hash_mutex); _3proxy_mutex_unlock(&ht->hash_mutex);
} }
int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){ int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
@ -227,7 +227,7 @@ int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
return 0; return 0;
} }
ht->index2hash_search(ht,name, hash); ht->index2hash_search(ht,name, hash);
pthread_mutex_lock(&ht->hash_mutex); _3proxy_mutex_lock(&ht->hash_mutex);
index = hashindex(ht->tablesize, hash); index = hashindex(ht->tablesize, hash);
for(hep = ht->ihashtable + index; (he = *hep)!=0; ){ for(hep = ht->ihashtable + index; (he = *hep)!=0; ){
if(hvalue(ht, he)->expires < conf.time) { if(hvalue(ht, he)->expires < conf.time) {
@ -239,12 +239,12 @@ int hashresolv(struct hashtable *ht, void* name, void* value, uint32_t *ttl){
else if(!memcmp(hash, hhash(ht,he), ht->hash_size)){ else if(!memcmp(hash, hhash(ht,he), ht->hash_size)){
if(ttl) *ttl = (uint32_t)(hvalue(ht,he)->expires - conf.time); if(ttl) *ttl = (uint32_t)(hvalue(ht,he)->expires - conf.time);
memcpy(value, hvalue(ht,he)->value, ht->recsize); memcpy(value, hvalue(ht,he)->value, ht->recsize);
pthread_mutex_unlock(&ht->hash_mutex); _3proxy_mutex_unlock(&ht->hash_mutex);
return 1; return 1;
} }
else hep=&(hvalue(ht,he)->inext); else hep=&(hvalue(ht,he)->inext);
} }
pthread_mutex_unlock(&ht->hash_mutex); _3proxy_mutex_unlock(&ht->hash_mutex);
return 0; return 0;
} }
@ -258,7 +258,7 @@ void hashdelete(struct hashtable *ht, void *name){
return; return;
} }
ht->index2hash_search(ht, name, hash); ht->index2hash_search(ht, name, hash);
pthread_mutex_lock(&ht->hash_mutex); _3proxy_mutex_lock(&ht->hash_mutex);
index = hashindex(ht->tablesize, hash); index = hashindex(ht->tablesize, hash);
for(hep = ht->ihashtable + index; (he = *hep) != 0; ){ for(hep = ht->ihashtable + index; (he = *hep) != 0; ){
if((hvalue(ht, he)->expires && hvalue(ht, he)->expires < conf.time) || !memcmp(hash, hhash(ht, he), ht->hash_size)) { if((hvalue(ht, he)->expires && hvalue(ht, he)->expires < conf.time) || !memcmp(hash, hhash(ht, he), ht->hash_size)) {
@ -269,7 +269,7 @@ void hashdelete(struct hashtable *ht, void *name){
} }
else hep = &(hvalue(ht, he)->inext); else hep = &(hvalue(ht, he)->inext);
} }
pthread_mutex_unlock(&ht->hash_mutex); _3proxy_mutex_unlock(&ht->hash_mutex);
} }
#define MURMUR_C1 0xcc9e2d51u #define MURMUR_C1 0xcc9e2d51u

View File

@ -15,7 +15,7 @@ int startconnlims (struct clientparam *param){
int ret = 0; int ret = 0;
param->connlim = 1; param->connlim = 1;
pthread_mutex_lock(&connlim_mutex); _3proxy_mutex_lock(&connlim_mutex);
for(ce = conf.connlimiter; ce; ce = ce->next) { for(ce = conf.connlimiter; ce; ce = ce->next) {
if(ACLmatches(ce->ace, param)){ if(ACLmatches(ce->ace, param)){
if(ce->ace->action == NOCONNLIM)break; if(ce->ace->action == NOCONNLIM)break;
@ -51,14 +51,14 @@ int startconnlims (struct clientparam *param){
} }
param->connlim = 0; param->connlim = 0;
} }
pthread_mutex_unlock(&connlim_mutex); _3proxy_mutex_unlock(&connlim_mutex);
return ret; return ret;
} }
void stopconnlims (struct clientparam *param){ void stopconnlims (struct clientparam *param){
struct connlim * ce; struct connlim * ce;
pthread_mutex_lock(&connlim_mutex); _3proxy_mutex_lock(&connlim_mutex);
for(ce = conf.connlimiter; ce; ce = ce->next) { for(ce = conf.connlimiter; ce; ce = ce->next) {
if(ACLmatches(ce->ace, param)){ if(ACLmatches(ce->ace, param)){
if(ce->ace->action == NOCONNLIM)break; if(ce->ace->action == NOCONNLIM)break;
@ -68,7 +68,7 @@ void stopconnlims (struct clientparam *param){
} }
} }
} }
pthread_mutex_unlock(&connlim_mutex); _3proxy_mutex_unlock(&connlim_mutex);
} }
void initbandlims (struct clientparam *param){ void initbandlims (struct clientparam *param){
@ -124,7 +124,7 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
#endif #endif
if(!nbytesin && !nbytesout) return 0; if(!nbytesin && !nbytesout) return 0;
pthread_mutex_lock(&bandlim_mutex); _3proxy_mutex_lock(&bandlim_mutex);
if(param->bandlimver != conf.bandlimver){ if(param->bandlimver != conf.bandlimver){
initbandlims(param); initbandlims(param);
param->bandlimver = conf.bandlimver; param->bandlimver = conf.bandlimver;
@ -163,7 +163,7 @@ unsigned bandlimitfunc(struct clientparam *param, unsigned nbytesin, unsigned nb
param->bandlimsout[i]->basetime = sec; param->bandlimsout[i]->basetime = sec;
param->bandlimsout[i]->nexttime = msec + nsleeptime + ((nbytesout > 512)? ((nbytesout+32)/64)*((64*8*1000000)/param->bandlimsout[i]->rate) : ((nbytesout+1)* (8*1000000))/param->bandlimsout[i]->rate); param->bandlimsout[i]->nexttime = msec + nsleeptime + ((nbytesout > 512)? ((nbytesout+32)/64)*((64*8*1000000)/param->bandlimsout[i]->rate) : ((nbytesout+1)* (8*1000000))/param->bandlimsout[i]->rate);
} }
pthread_mutex_unlock(&bandlim_mutex); _3proxy_mutex_unlock(&bandlim_mutex);
return sleeptime/1000; return sleeptime/1000;
} }
@ -171,7 +171,7 @@ void trafcountfunc(struct clientparam *param){
struct trafcount * tc; struct trafcount * tc;
int countout = 0; int countout = 0;
pthread_mutex_lock(&tc_mutex); _3proxy_mutex_lock(&tc_mutex);
for(tc = conf.trafcounter; tc; tc = tc->next) { for(tc = conf.trafcounter; tc; tc = tc->next) {
if(ACLmatches(tc->ace, param)){ if(ACLmatches(tc->ace, param)){
@ -199,6 +199,6 @@ void trafcountfunc(struct clientparam *param){
} }
} }
pthread_mutex_unlock(&tc_mutex); _3proxy_mutex_unlock(&tc_mutex);
} }

View File

@ -10,7 +10,7 @@
#include "proxy.h" #include "proxy.h"
pthread_mutex_t log_mutex; _3proxy_mutex_t log_mutex;
int havelog = 0; int havelog = 0;

View File

@ -45,7 +45,7 @@ extern "C" {
static struct pluginlink * pl; static struct pluginlink * pl;
static pthread_mutex_t file_mutex; static _3proxy_mutex_t file_mutex;
unsigned long preview = 0; unsigned long preview = 0;
@ -207,7 +207,7 @@ static void closefiles(struct fp_stream *fps){
static int searchsocket(SOCKET s, struct fp_stream **pfps){ static int searchsocket(SOCKET s, struct fp_stream **pfps){
struct fp_stream *fps = NULL; struct fp_stream *fps = NULL;
int ret = 0; int ret = 0;
pthread_mutex_lock(&file_mutex); _3proxy_mutex_lock(&file_mutex);
for(fps = fp_streams; fps; fps = fps->next){ for(fps = fp_streams; fps; fps = fps->next){
if(fps->fpd.cp->clisock == s) { if(fps->fpd.cp->clisock == s) {
ret = 1; ret = 1;
@ -222,7 +222,7 @@ static int searchsocket(SOCKET s, struct fp_stream **pfps){
break; break;
} }
} }
pthread_mutex_unlock(&file_mutex); _3proxy_mutex_unlock(&file_mutex);
*pfps = fps; *pfps = fps;
return ret; return ret;
} }
@ -235,7 +235,7 @@ static void freecallback(struct fp_stream * fps, struct fp_callback * fpc){
static void removefps(struct fp_stream * fps){ static void removefps(struct fp_stream * fps){
if(!fp_streams) return; if(!fp_streams) return;
pthread_mutex_lock(&file_mutex); _3proxy_mutex_lock(&file_mutex);
if(fp_streams == fps)fp_streams = fps->next; if(fp_streams == fps)fp_streams = fps->next;
else { else {
struct fp_stream *fps2; struct fp_stream *fps2;
@ -248,7 +248,7 @@ static void removefps(struct fp_stream * fps){
} }
} }
pthread_mutex_unlock(&file_mutex); _3proxy_mutex_unlock(&file_mutex);
if(fps->callbacks){ if(fps->callbacks){
freecallback(fps, fps->callbacks); freecallback(fps, fps->callbacks);
fps->callbacks = 0; fps->callbacks = 0;
@ -754,7 +754,7 @@ static int fp_registercallback (int what, int max_size, int preview_size, struct
fpc->max_size = max_size; fpc->max_size = max_size;
fpc->data = data; fpc->data = data;
fpc->callback = cb; fpc->callback = cb;
pthread_mutex_lock(&file_mutex); _3proxy_mutex_lock(&file_mutex);
fps = addfps(cp); fps = addfps(cp);
if(fps){ if(fps){
fpc->next = fps->callbacks; fpc->next = fps->callbacks;
@ -763,7 +763,7 @@ static int fp_registercallback (int what, int max_size, int preview_size, struct
if(preview_size > fps->preview_size) fps->preview_size = preview_size; if(preview_size > fps->preview_size) fps->preview_size = preview_size;
} }
else free(fpc); else free(fpc);
pthread_mutex_unlock(&file_mutex); _3proxy_mutex_unlock(&file_mutex);
return fps?1:0; return fps?1:0;
} }
@ -777,9 +777,9 @@ static void * fp_open(void * idata, struct srvparam * param){
static FILTER_ACTION fp_client(void *fo, struct clientparam * param, void** fc){ static FILTER_ACTION fp_client(void *fo, struct clientparam * param, void** fc){
pthread_mutex_lock(&file_mutex); _3proxy_mutex_lock(&file_mutex);
(*fc) = (void *)addfps(param); (*fc) = (void *)addfps(param);
pthread_mutex_unlock(&file_mutex); _3proxy_mutex_unlock(&file_mutex);
return CONTINUE; return CONTINUE;
} }
@ -913,7 +913,7 @@ static int file_loaded=0;
int argc, char** argv){ int argc, char** argv){
if(!file_loaded){ if(!file_loaded){
pthread_mutex_init(&file_mutex, NULL); _3proxy_mutex_init(&file_mutex);
file_loaded = 1; file_loaded = 1;
pl = pluginlink; pl = pluginlink;
memcpy(&sso, pl->so, sizeof(struct sockfuncs)); memcpy(&sso, pl->so, sizeof(struct sockfuncs));

View File

@ -21,7 +21,7 @@ extern "C" {
static struct pluginlink * pl; static struct pluginlink * pl;
static pthread_mutex_t pcre_mutex; static _3proxy_mutex_t pcre_mutex;
static struct filter pcre_first_filter = { static struct filter pcre_first_filter = {
@ -112,7 +112,7 @@ struct pcre_filter_data {
}; };
static void pcre_data_free(struct pcre_filter_data *pcrefd){ static void pcre_data_free(struct pcre_filter_data *pcrefd){
pthread_mutex_lock(&pcre_mutex); _3proxy_mutex_lock(&pcre_mutex);
pcrefd->users--; pcrefd->users--;
if(!pcrefd->users){ if(!pcrefd->users){
if(pcrefd->match_data) pcre2_match_data_free(pcrefd->match_data); if(pcrefd->match_data) pcre2_match_data_free(pcrefd->match_data);
@ -121,7 +121,7 @@ static void pcre_data_free(struct pcre_filter_data *pcrefd){
if(pcrefd->replace) pl->freefunc(pcrefd->replace); if(pcrefd->replace) pl->freefunc(pcrefd->replace);
pl->freefunc(pcrefd); pl->freefunc(pcrefd);
} }
pthread_mutex_unlock(&pcre_mutex); _3proxy_mutex_unlock(&pcre_mutex);
} }
@ -130,9 +130,9 @@ static void pcre_data_free(struct pcre_filter_data *pcrefd){
static void* pcre_filter_open(void * idata, struct srvparam * param){ static void* pcre_filter_open(void * idata, struct srvparam * param){
#define pcrefd ((struct pcre_filter_data *)idata) #define pcrefd ((struct pcre_filter_data *)idata)
if(idata){ if(idata){
pthread_mutex_lock(&pcre_mutex); _3proxy_mutex_lock(&pcre_mutex);
pcrefd->users++; pcrefd->users++;
pthread_mutex_unlock(&pcre_mutex); _3proxy_mutex_unlock(&pcre_mutex);
} }
#undef pcrefd #undef pcrefd
return idata; return idata;
@ -517,7 +517,7 @@ PLUGINAPI int PLUGINCALL pcre_plugin (struct pluginlink * pluginlink,
pcre_options = 0; pcre_options = 0;
if(!pcre_loaded){ if(!pcre_loaded){
pcre_loaded = 1; pcre_loaded = 1;
pthread_mutex_init(&pcre_mutex, NULL); _3proxy_mutex_init(&pcre_mutex);
regexp_symbols[2].next = pl->symbols.next; regexp_symbols[2].next = pl->symbols.next;
pl->symbols.next = regexp_symbols; pl->symbols.next = regexp_symbols;
pcre_commandhandlers[3].next = pl->commandhandlers->next; pcre_commandhandlers[3].next = pl->commandhandlers->next;

View File

@ -12,7 +12,7 @@ Kirill Lopuchov <lopuchov@mail.ru>
#include <security/pam_appl.h> #include <security/pam_appl.h>
pthread_mutex_t pam_mutex; _3proxy_mutex_t pam_mutex;
static int already_loaded = 0; static int already_loaded = 0;
@ -89,7 +89,7 @@ static int pamfunc(struct clientparam *param)
/*start process auth */ /*start process auth */
conv.appdata_ptr = (char *) param->password; conv.appdata_ptr = (char *) param->password;
pthread_mutex_lock(&pam_mutex); _3proxy_mutex_lock(&pam_mutex);
if (!pamh) if (!pamh)
{ {
retval = pam_start ((char *)service, (char *)param->username, &conv, &pamh); retval = pam_start ((char *)service, (char *)param->username, &conv, &pamh);
@ -113,7 +113,7 @@ static int pamfunc(struct clientparam *param)
retval = pam_end (pamh, retval); retval = pam_end (pamh, retval);
if (retval != PAM_SUCCESS) if (retval != PAM_SUCCESS)
{ pamh = NULL; } { pamh = NULL; }
pthread_mutex_unlock(&pam_mutex); _3proxy_mutex_unlock(&pam_mutex);
return rc; return rc;
@ -140,7 +140,7 @@ PLUGINAPI int PLUGINCALL start(struct pluginlink * pluginlink, int argc, unsigne
already_loaded = 1; already_loaded = 1;
pthread_mutex_init(&pam_mutex, NULL); _3proxy_mutex_init(&pam_mutex);
pamauth.authenticate = pamfunc; pamauth.authenticate = pamfunc;
pamauth.authorize = pluginlink->checkACL; pamauth.authorize = pluginlink->checkACL;
pamauth.desc = "pam"; pamauth.desc = "pam";

View File

@ -32,7 +32,7 @@ typedef struct _ssl_conn {
SSL *ssl; SSL *ssl;
} ssl_conn; } ssl_conn;
pthread_mutex_t ssl_file_mutex; _3proxy_mutex_t ssl_file_mutex;
static char errbuf[256]; static char errbuf[256];
@ -229,15 +229,15 @@ void _ssl_cert_free(SSL_CERT cert)
/* This array will store all of the mutexes available to OpenSSL. */ /* This array will store all of the mutexes available to OpenSSL. */
static pthread_mutex_t *mutex_buf= NULL; static _3proxy_mutex_t *mutex_buf= NULL;
static void locking_function(int mode, int n, const char * file, int line) static void locking_function(int mode, int n, const char * file, int line)
{ {
if (mode & CRYPTO_LOCK) if (mode & CRYPTO_LOCK)
pthread_mutex_lock(mutex_buf + n); _3proxy_mutex_lock(mutex_buf + n);
else else
pthread_mutex_unlock(mutex_buf + n); _3proxy_mutex_unlock(mutex_buf + n);
} }
static unsigned long id_function(void) static unsigned long id_function(void)
@ -253,11 +253,11 @@ int thread_setup(void)
{ {
int i; int i;
mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(pthread_mutex_t)); mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(_3proxy_mutex_t));
if (!mutex_buf) if (!mutex_buf)
return 0; return 0;
for (i = 0; i < CRYPTO_num_locks( ); i++) for (i = 0; i < CRYPTO_num_locks( ); i++)
pthread_mutex_init(mutex_buf +i, NULL); _3proxy_mutex_init(mutex_buf +i);
CRYPTO_set_id_callback(id_function); CRYPTO_set_id_callback(id_function);
CRYPTO_set_locking_callback(locking_function); CRYPTO_set_locking_callback(locking_function);
return 1; return 1;
@ -272,7 +272,7 @@ int thread_cleanup(void)
CRYPTO_set_id_callback(NULL); CRYPTO_set_id_callback(NULL);
CRYPTO_set_locking_callback(NULL); CRYPTO_set_locking_callback(NULL);
for (i = 0; i < CRYPTO_num_locks( ); i++) for (i = 0; i < CRYPTO_num_locks( ); i++)
pthread_mutex_destroy(mutex_buf +i); _3proxy_mutex_destroy(mutex_buf +i);
free(mutex_buf); free(mutex_buf);
mutex_buf = NULL; mutex_buf = NULL;
return 1; return 1;
@ -291,7 +291,7 @@ void ssl_init()
thread_setup(); thread_setup();
SSLeay_add_ssl_algorithms(); SSLeay_add_ssl_algorithms();
SSL_load_error_strings(); SSL_load_error_strings();
pthread_mutex_init(&ssl_file_mutex, NULL); _3proxy_mutex_init(&ssl_file_mutex);
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
} }
} }

View File

@ -323,12 +323,12 @@ struct datatype;
struct dictionary; struct dictionary;
struct node; struct node;
struct property; struct property;
extern pthread_mutex_t config_mutex; extern _3proxy_mutex_t config_mutex;
extern pthread_mutex_t bandlim_mutex; extern _3proxy_mutex_t bandlim_mutex;
extern pthread_mutex_t connlim_mutex; extern _3proxy_mutex_t connlim_mutex;
extern pthread_mutex_t tc_mutex; extern _3proxy_mutex_t tc_mutex;
extern pthread_mutex_t log_mutex; extern _3proxy_mutex_t log_mutex;
extern pthread_mutex_t rad_mutex; extern _3proxy_mutex_t rad_mutex;
extern struct datatype datatypes[64]; extern struct datatype datatypes[64];
extern struct commands commandhandlers[]; extern struct commands commandhandlers[];

View File

@ -119,7 +119,7 @@ int pushthreadinit(){
#ifdef _WIN32 #ifdef _WIN32
return ReleaseSemaphore(conf.threadinit, 1, NULL) ? 1 : 0; return ReleaseSemaphore(conf.threadinit, 1, NULL) ? 1 : 0;
#else #else
pthread_mutex_unlock(&conf.threadinit); _3proxy_mutex_unlock(&conf.threadinit);
return 1; return 1;
#endif #endif
} }
@ -383,7 +383,7 @@ int MODULEMAINFUNC (int argc, char** argv){
#endif #endif
#else #else
srv.needuser = 0; srv.needuser = 0;
pthread_mutex_init(&log_mutex, NULL); _3proxy_mutex_init(&log_mutex);
#endif #endif
for (i=1; i<argc; i++) { for (i=1; i<argc; i++) {
@ -937,15 +937,15 @@ int MODULEMAINFUNC (int argc, char** argv){
struct clientparam *toparam; struct clientparam *toparam;
udplen = sockrecvfrom(NULL, srv.srvsock, (struct sockaddr *)&defparam.sincr, udpbuf, UDPBUFSIZE, 0); udplen = sockrecvfrom(NULL, srv.srvsock, (struct sockaddr *)&defparam.sincr, udpbuf, UDPBUFSIZE, 0);
if(udplen <= 0) continue; if(udplen <= 0) continue;
pthread_mutex_lock(&srv.counter_mutex); _3proxy_mutex_lock(&srv.counter_mutex);
if(hashresolv(&udp_table, &defparam, &toparam, NULL)) { if(hashresolv(&udp_table, &defparam, &toparam, NULL)) {
socksendto(toparam, toparam->remsock, (struct sockaddr *)&toparam->sinsr, udpbuf, udplen, 0); socksendto(toparam, toparam->remsock, (struct sockaddr *)&toparam->sinsr, udpbuf, udplen, 0);
toparam->statscli64 += udplen; toparam->statscli64 += udplen;
toparam->nwrites++; toparam->nwrites++;
pthread_mutex_unlock(&srv.counter_mutex); _3proxy_mutex_unlock(&srv.counter_mutex);
continue; continue;
} }
pthread_mutex_unlock(&srv.counter_mutex); _3proxy_mutex_unlock(&srv.counter_mutex);
} }
#endif #endif
if(! (newparam = myalloc (sizeof(defparam)))){ if(! (newparam = myalloc (sizeof(defparam)))){
@ -996,7 +996,7 @@ int MODULEMAINFUNC (int argc, char** argv){
#endif #endif
newparam->prev = newparam->next = NULL; newparam->prev = newparam->next = NULL;
error = 0; error = 0;
pthread_mutex_lock(&srv.counter_mutex); _3proxy_mutex_lock(&srv.counter_mutex);
if(!srv.child){ if(!srv.child){
srv.child = newparam; srv.child = newparam;
} }
@ -1020,7 +1020,7 @@ int MODULEMAINFUNC (int argc, char** argv){
if(!srv.silent)dolog(&defparam, buf); if(!srv.silent)dolog(&defparam, buf);
error = 1; error = 1;
} }
pthread_mutex_unlock(&srv.counter_mutex); _3proxy_mutex_unlock(&srv.counter_mutex);
if(error) freeparam(newparam); if(error) freeparam(newparam);
#else #else
@ -1031,14 +1031,14 @@ int MODULEMAINFUNC (int argc, char** argv){
if(newparam->prev) newparam->prev->next = newparam->next; if(newparam->prev) newparam->prev->next = newparam->next;
else srv.child = newparam->next; else srv.child = newparam->next;
if(newparam->next) newparam->next->prev = newparam->prev; if(newparam->next) newparam->next->prev = newparam->prev;
pthread_mutex_unlock(&srv.counter_mutex); _3proxy_mutex_unlock(&srv.counter_mutex);
newparam->srv = NULL; newparam->srv = NULL;
freeparam(newparam); freeparam(newparam);
} }
else { else {
srv.childcount++; srv.childcount++;
newparam->threadid = (uint64_t)thread; newparam->threadid = (uint64_t)thread;
pthread_mutex_unlock(&srv.counter_mutex); _3proxy_mutex_unlock(&srv.counter_mutex);
} }
#endif #endif
@ -1048,11 +1048,11 @@ int MODULEMAINFUNC (int argc, char** argv){
#ifndef STDMAIN #ifndef STDMAIN
pthread_mutex_lock(&config_mutex); _3proxy_mutex_lock(&config_mutex);
if(srv.next)srv.next->prev = srv.prev; if(srv.next)srv.next->prev = srv.prev;
if(srv.prev)srv.prev->next = srv.next; if(srv.prev)srv.prev->next = srv.next;
else conf.services = srv.next; else conf.services = srv.next;
pthread_mutex_unlock(&config_mutex); _3proxy_mutex_unlock(&config_mutex);
#endif #endif
if(!srv.silent) srv.logfunc(&defparam, (unsigned char *)"Exiting thread"); if(!srv.silent) srv.logfunc(&defparam, (unsigned char *)"Exiting thread");
@ -1101,7 +1101,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
param->paused = srv->paused; param->paused = srv->paused;
param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET; param->remsock = param->clisock = param->ctrlsock = param->ctrlsocksrv = INVALID_SOCKET;
*SAFAMILY(&param->req) = *SAFAMILY(&param->sinsl) = *SAFAMILY(&param->sinsr) = *SAFAMILY(&param->sincr) = *SAFAMILY(&param->sincl) = AF_INET; *SAFAMILY(&param->req) = *SAFAMILY(&param->sinsl) = *SAFAMILY(&param->sinsr) = *SAFAMILY(&param->sincr) = *SAFAMILY(&param->sincl) = AF_INET;
pthread_mutex_init(&srv->counter_mutex, NULL); _3proxy_mutex_init(&srv->counter_mutex);
srv->intsa = conf.intsa; srv->intsa = conf.intsa;
srv->extsa = conf.extsa; srv->extsa = conf.extsa;
#ifndef NOIPV6 #ifndef NOIPV6
@ -1166,7 +1166,7 @@ void srvfree(struct srvparam * srv){
if(srv->acl)freeacl(srv->acl); if(srv->acl)freeacl(srv->acl);
if(srv->authfuncs)freeauth(srv->authfuncs); if(srv->authfuncs)freeauth(srv->authfuncs);
#endif #endif
pthread_mutex_destroy(&srv->counter_mutex); _3proxy_mutex_destroy(&srv->counter_mutex);
if(srv->target) myfree(srv->target); if(srv->target) myfree(srv->target);
if(srv->logtarget) myfree(srv->logtarget); if(srv->logtarget) myfree(srv->logtarget);
if(srv->logformat) myfree(srv->logformat); if(srv->logformat) myfree(srv->logformat);
@ -1183,7 +1183,7 @@ void freeparam(struct clientparam * param) {
if(param->res == 2) return; if(param->res == 2) return;
if(param->srv){ if(param->srv){
if(param->srv->so.freefunc) param->srv->so.freefunc(param->sostate); if(param->srv->so.freefunc) param->srv->so.freefunc(param->sostate);
pthread_mutex_lock(&param->srv->counter_mutex); _3proxy_mutex_lock(&param->srv->counter_mutex);
#ifndef STDMAIN #ifndef STDMAIN
if(param->srv->service == S_UDPPM) hashdelete(&udp_table, param); if(param->srv->service == S_UDPPM) hashdelete(&udp_table, param);
#endif #endif
@ -1196,7 +1196,7 @@ void freeparam(struct clientparam * param) {
param->next->prev = param->prev; param->next->prev = param->prev;
} }
(param->srv->childcount)--; (param->srv->childcount)--;
pthread_mutex_unlock(&param->srv->counter_mutex); _3proxy_mutex_unlock(&param->srv->counter_mutex);
} }
if(param->clibuf) myfree(param->clibuf); if(param->clibuf) myfree(param->clibuf);
if(param->srvbuf) myfree(param->srvbuf); if(param->srvbuf) myfree(param->srvbuf);

View File

@ -98,7 +98,7 @@ void sqlerr (char *buf){
fprintf(conf.stdlog, "%s\n", buf); fprintf(conf.stdlog, "%s\n", buf);
fflush(conf.stdlog); fflush(conf.stdlog);
} }
pthread_mutex_unlock(&log_mutex); _3proxy_mutex_unlock(&log_mutex);
} }
unsigned char statbuf[8192]; unsigned char statbuf[8192];
@ -109,7 +109,7 @@ void logsql(struct clientparam * param, const unsigned char *s) {
if(param->nolog) return; if(param->nolog) return;
pthread_mutex_lock(&log_mutex); _3proxy_mutex_lock(&log_mutex);
len = dobuf(param, statbuf, s, (unsigned char *)"\'"); len = dobuf(param, statbuf, s, (unsigned char *)"\'");
if(attempt > 5){ if(attempt > 5){
@ -146,7 +146,7 @@ void logsql(struct clientparam * param, const unsigned char *s) {
} }
attempt = 0; attempt = 0;
} }
pthread_mutex_unlock(&log_mutex); _3proxy_mutex_unlock(&log_mutex);
} }
#endif #endif

View File

@ -37,29 +37,19 @@ extern "C" {
#define SASIZETYPE socklen_t #define SASIZETYPE socklen_t
#define SOCKET int #define SOCKET int
#define INVALID_SOCKET (-1) #define INVALID_SOCKET (-1)
#ifdef WITH_LINUX_FUTEX #define _3proxy_mutex_t pthread_mutex_t
#define _GNU_SOURCE #define _3proxy_mutex_init(x) pthread_mutex_init(x,NULL)
#include <unistd.h> #define _3proxy_mutex_destroy pthread_mutex_destroy
#include <sys/syscall.h> #define _3proxy_mutex_lock pthread_mutex_lock
#include <linux/kernel.h> #define _3proxy_mutex_unlock pthread_mutex_unlock
#include <linux/futex.h>
#define pthread_mutex_t int
#define pthread_mutex_init(x, y) (*(x)=0)
#define pthread_mutex_destroy(x) (*(x)=0)
#define pthread_mutex_lock(x) mutex_lock(x)
#define pthread_mutex_unlock(x) mutex_unlock(x)
int mutex_lock(int *val);
int mutex_unlock(int *val);
#else
#endif
#else #else
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#define pthread_mutex_t CRITICAL_SECTION #define _3proxy_mutex_t CRITICAL_SECTION
#define pthread_mutex_init(x, y) InitializeCriticalSection(x) #define _3proxy_mutex_init(x) InitializeCriticalSection(x)
#define pthread_mutex_lock(x) EnterCriticalSection(x) #define _3proxy_mutex_lock(x) EnterCriticalSection(x)
#define pthread_mutex_unlock(x) LeaveCriticalSection(x) #define _3proxy_mutex_unlock(x) LeaveCriticalSection(x)
#define pthread_mutex_destroy(x) DeleteCriticalSection(x) #define _3proxy_mutex_destroy(x) DeleteCriticalSection(x)
#ifdef MSVC #ifdef MSVC
#pragma warning (disable : 4996) #pragma warning (disable : 4996)
#endif #endif
@ -511,7 +501,7 @@ struct hashtable {
uint32_t * ihashtable; uint32_t * ihashtable;
uint8_t * hashvalues; uint8_t * hashvalues;
uint8_t * hashhashvalues; uint8_t * hashhashvalues;
pthread_mutex_t hash_mutex; _3proxy_mutex_t hash_mutex;
time_t compacted; time_t compacted;
uint32_t ihashhashempty; uint32_t ihashhashempty;
uint32_t ihashempty; uint32_t ihashempty;
@ -556,7 +546,7 @@ struct srvparam {
PROXYSOCKADDRTYPE extsa6; PROXYSOCKADDRTYPE extsa6;
#endif #endif
PROXYSOCKADDRTYPE extsa; PROXYSOCKADDRTYPE extsa;
pthread_mutex_t counter_mutex; _3proxy_mutex_t counter_mutex;
struct pollfd fds; struct pollfd fds;
FILE *stdlog; FILE *stdlog;
unsigned char * target; unsigned char * target;
@ -675,7 +665,7 @@ struct extparam {
#ifdef _WIN32 #ifdef _WIN32
HANDLE threadinit; HANDLE threadinit;
#else #else
pthread_mutex_t threadinit; _3proxy_mutex_t threadinit;
#endif #endif
int *timeouts; int *timeouts;
struct ace * acl; struct ace * acl;