mirror of
				https://github.com/3proxy/3proxy.git
				synced 2025-11-04 07:42:39 +08:00 
			
		
		
		
	remove debug output
This commit is contained in:
		
							parent
							
								
									fa52a1ae92
								
							
						
					
					
						commit
						f219544d6a
					
				@ -229,7 +229,7 @@ void cyclestep(void){
 | 
				
			|||||||
 for(;;){
 | 
					 for(;;){
 | 
				
			||||||
	usleep(SLEEPTIME*999);
 | 
						usleep(SLEEPTIME*999);
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
//	flushlogs();
 | 
						flushlogs();
 | 
				
			||||||
	conf.time = time(0);
 | 
						conf.time = time(0);
 | 
				
			||||||
	if(conf.needreload) {
 | 
						if(conf.needreload) {
 | 
				
			||||||
		doschedule();
 | 
							doschedule();
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										71
									
								
								src/log.c
									
									
									
									
									
								
							
							
						
						
									
										71
									
								
								src/log.c
									
									
									
									
									
								
							@ -140,15 +140,11 @@ void delayregisterlog(struct LOGGER *log){
 | 
				
			|||||||
	struct LOGFUNC *funcs;
 | 
						struct LOGFUNC *funcs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("delayregisterlog %s\n", log->selector);
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	if(log->logfunc) return;
 | 
						if(log->logfunc) return;
 | 
				
			||||||
	for(funcs = logfuncs; funcs; funcs=funcs->next){
 | 
						for(funcs = logfuncs; funcs; funcs=funcs->next){
 | 
				
			||||||
		if(!strncmp(log->selector, funcs->prefix, strlen(funcs->prefix))){
 | 
							if(!strncmp(log->selector, funcs->prefix, strlen(funcs->prefix))){
 | 
				
			||||||
			if(funcs->init && funcs->init(log)) break;
 | 
								if(funcs->init && funcs->init(log)) break;
 | 
				
			||||||
			log->logfunc = funcs;
 | 
								log->logfunc = funcs;
 | 
				
			||||||
printf("new log initialised\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -158,16 +154,12 @@ fflush(stdout);
 | 
				
			|||||||
struct LOGGER * registerlog(const char * logstring, int logtype){
 | 
					struct LOGGER * registerlog(const char * logstring, int logtype){
 | 
				
			||||||
	struct LOGGER *log;
 | 
						struct LOGGER *log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("registerlog %s\n", logstring);
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	if(!logstring || !strcmp(logstring, "NUL") || !strcmp(logstring, "/dev/null")) return NULL;
 | 
						if(!logstring || !strcmp(logstring, "NUL") || !strcmp(logstring, "/dev/null")) return NULL;
 | 
				
			||||||
	pthread_mutex_lock(&log_mutex);
 | 
						pthread_mutex_lock(&log_mutex);
 | 
				
			||||||
	for(log = loggers; log; log=log->next){
 | 
						for(log = loggers; log; log=log->next){
 | 
				
			||||||
		if(!strcmp(logstring, log->selector)){
 | 
							if(!strcmp(logstring, log->selector)){
 | 
				
			||||||
			if(logtype >= 0) log->rotate = logtype;
 | 
								if(logtype >= 0) log->rotate = logtype;
 | 
				
			||||||
			log->registered++;
 | 
								log->registered++;
 | 
				
			||||||
printf("log registered\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
			pthread_mutex_unlock(&log_mutex);
 | 
								pthread_mutex_unlock(&log_mutex);
 | 
				
			||||||
			return log;
 | 
								return log;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -192,8 +184,6 @@ fflush(stdout);
 | 
				
			|||||||
		evt->event = REGISTER;
 | 
							evt->event = REGISTER;
 | 
				
			||||||
		evt->log = log;
 | 
							evt->log = log;
 | 
				
			||||||
		logpush(evt);
 | 
							logpush(evt);
 | 
				
			||||||
printf("new log registered\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
		return log;
 | 
							return log;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pthread_mutex_unlock(&log_mutex);
 | 
						pthread_mutex_unlock(&log_mutex);
 | 
				
			||||||
@ -217,13 +207,9 @@ static void delayunregisterlog (struct LOGGER * log){
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			myfree(log->selector);
 | 
								myfree(log->selector);
 | 
				
			||||||
			myfree(log);
 | 
								myfree(log);
 | 
				
			||||||
printf("log closed\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else pthread_mutex_unlock(&log_mutex);
 | 
							else pthread_mutex_unlock(&log_mutex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("log unregistered\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -243,11 +229,6 @@ DWORD WINAPI logthreadfunc(LPVOID p) {
 | 
				
			|||||||
void * logthreadfunc (void *p) {
 | 
					void * logthreadfunc (void *p) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("enter logthreadfunc\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for(;;){
 | 
						for(;;){
 | 
				
			||||||
		struct logevent *evt;
 | 
							struct logevent *evt;
 | 
				
			||||||
#ifdef _WIN32
 | 
					#ifdef _WIN32
 | 
				
			||||||
@ -255,8 +236,6 @@ fflush(stdout);
 | 
				
			|||||||
#else
 | 
					#else
 | 
				
			||||||
		sem_wait(&log_sem);
 | 
							sem_wait(&log_sem);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
printf("got semaphore\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		while(loghead){
 | 
							while(loghead){
 | 
				
			||||||
			pthread_mutex_lock(&log_mutex);
 | 
								pthread_mutex_lock(&log_mutex);
 | 
				
			||||||
@ -266,28 +245,18 @@ fflush(stdout);
 | 
				
			|||||||
			pthread_mutex_unlock(&log_mutex);
 | 
								pthread_mutex_unlock(&log_mutex);
 | 
				
			||||||
			switch(evt->event){
 | 
								switch(evt->event){
 | 
				
			||||||
				case REGISTER:
 | 
									case REGISTER:
 | 
				
			||||||
printf("got register\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
					delayregisterlog(evt->log);
 | 
										delayregisterlog(evt->log);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				case UNREGISTER:
 | 
									case UNREGISTER:
 | 
				
			||||||
printf("got unregister\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
					delayunregisterlog(evt->log);
 | 
										delayunregisterlog(evt->log);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				case FLUSH:
 | 
									case FLUSH:
 | 
				
			||||||
printf("got flush\n");
 | 
										delayflushlogs();
 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
//					delayflushlogs();
 | 
					 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				case LOG:
 | 
									case LOG:
 | 
				
			||||||
printf("got log\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
					delaydolog(evt);
 | 
										delaydolog(evt);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				case FREEPARAM:
 | 
									case FREEPARAM:
 | 
				
			||||||
printf("got freeparam\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
					delayfreeparam(evt->param);
 | 
										delayfreeparam(evt->param);
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -301,16 +270,12 @@ fflush(stdout);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("finish logthreadfunc\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void logpush(struct logevent *evt){
 | 
					void logpush(struct logevent *evt){
 | 
				
			||||||
printf("logpush\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	pthread_mutex_lock(&log_mutex);
 | 
						pthread_mutex_lock(&log_mutex);
 | 
				
			||||||
	if(logtail) logtail->next = evt;
 | 
						if(logtail) logtail->next = evt;
 | 
				
			||||||
	logtail = evt;
 | 
						logtail = evt;
 | 
				
			||||||
@ -318,8 +283,6 @@ fflush(stdout);
 | 
				
			|||||||
	if(!loghead)loghead = evt;
 | 
						if(!loghead)loghead = evt;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	pthread_mutex_unlock(&log_mutex);
 | 
						pthread_mutex_unlock(&log_mutex);
 | 
				
			||||||
printf("sending post\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
#ifdef _WIN32
 | 
					#ifdef _WIN32
 | 
				
			||||||
	ReleaseSemaphore(log_sem, 1, NULL);
 | 
						ReleaseSemaphore(log_sem, 1, NULL);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
@ -330,8 +293,6 @@ fflush(stdout);
 | 
				
			|||||||
void initlog(void){
 | 
					void initlog(void){
 | 
				
			||||||
	pthread_t thread;
 | 
						pthread_t thread;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("initlog\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	srvinit(&logsrv, &logparam);
 | 
						srvinit(&logsrv, &logparam);
 | 
				
			||||||
	pthread_mutex_init(&log_mutex, NULL);
 | 
						pthread_mutex_init(&log_mutex, NULL);
 | 
				
			||||||
	errld.fp = stdout;
 | 
						errld.fp = stdout;
 | 
				
			||||||
@ -367,19 +328,13 @@ fflush(stdout);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void delaydolog(struct logevent *evt){
 | 
					static void delaydolog(struct logevent *evt){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("delaylog\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	if(!evt->log->logfunc || !evt->log->logfunc->log) return;
 | 
						if(!evt->log->logfunc || !evt->log->logfunc->log) return;
 | 
				
			||||||
	if(evt->inbuf){
 | 
						if(evt->inbuf){
 | 
				
			||||||
printf("havebuffer\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
		evt->log->logfunc->log(evt->buf, evt->inbuf, evt->log);
 | 
							evt->log->logfunc->log(evt->buf, evt->inbuf, evt->log);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else if(evt->param && evt->log->logfunc->dobuf){
 | 
						else if(evt->param && evt->log->logfunc->dobuf){
 | 
				
			||||||
		char buf[LOGBUFSIZE];
 | 
							char buf[LOGBUFSIZE];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("haveparam\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
		evt->log->logfunc->log(buf, evt->log->logfunc->dobuf(evt->param, buf, LOGBUFSIZE, evt->logstring), evt->log);
 | 
							evt->log->logfunc->log(buf, evt->log->logfunc->dobuf(evt->param, buf, LOGBUFSIZE, evt->logstring), evt->log);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -387,8 +342,6 @@ fflush(stdout);
 | 
				
			|||||||
void dolog(struct clientparam * param, const unsigned char *s){
 | 
					void dolog(struct clientparam * param, const unsigned char *s){
 | 
				
			||||||
	static int init = 0;
 | 
						static int init = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("dolog\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	if(!param || !param->srv){
 | 
						if(!param || !param->srv){
 | 
				
			||||||
		stdlog(s, strlen(s), &errlogger);
 | 
							stdlog(s, strlen(s), &errlogger);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
@ -400,8 +353,6 @@ fflush(stdout);
 | 
				
			|||||||
		if(!param->srv->log->logfunc) {
 | 
							if(!param->srv->log->logfunc) {
 | 
				
			||||||
			int slen =0, hlen=0, ulen=0;
 | 
								int slen =0, hlen=0, ulen=0;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
printf("no log functions, sending param\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
			slen = s?strlen(s)+1 : 0;
 | 
								slen = s?strlen(s)+1 : 0;
 | 
				
			||||||
			hlen = param->hostname? strlen(param->hostname)+1 : 0;
 | 
								hlen = param->hostname? strlen(param->hostname)+1 : 0;
 | 
				
			||||||
			ulen = param->username? strlen(param->username)+1 : 0;
 | 
								ulen = param->username? strlen(param->username)+1 : 0;
 | 
				
			||||||
@ -423,14 +374,10 @@ fflush(stdout);
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			evt->event = LOG;
 | 
								evt->event = LOG;
 | 
				
			||||||
			evt->log = param->srv->log;
 | 
								evt->log = param->srv->log;
 | 
				
			||||||
printf("pushing event\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
			logpush(evt);
 | 
								logpush(evt);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else if (param->srv->log->logfunc->log){
 | 
							else if (param->srv->log->logfunc->log){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("have log functions\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
			if(!(evt = malloc(param->srv->log->logfunc->dobuf?EVENTSIZE:sizeof(struct logevent)))) return;
 | 
								if(!(evt = malloc(param->srv->log->logfunc->dobuf?EVENTSIZE:sizeof(struct logevent)))) return;
 | 
				
			||||||
			evt->inbuf = 0;
 | 
								evt->inbuf = 0;
 | 
				
			||||||
			evt->param = NULL;
 | 
								evt->param = NULL;
 | 
				
			||||||
@ -441,15 +388,9 @@ fflush(stdout);
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			evt->event = LOG;
 | 
								evt->event = LOG;
 | 
				
			||||||
			evt->log = param->srv->log;
 | 
								evt->log = param->srv->log;
 | 
				
			||||||
printf("pushing event\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
			logpush(evt);
 | 
								logpush(evt);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
printf("nolog\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if(param->trafcountfunc)(*param->trafcountfunc)(param);
 | 
						if(param->trafcountfunc)(*param->trafcountfunc)(param);
 | 
				
			||||||
	clearstat(param);
 | 
						clearstat(param);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -862,8 +803,6 @@ static int stdloginit(struct LOGGER *logger){
 | 
				
			|||||||
	char tmpbuf[1024];
 | 
						char tmpbuf[1024];
 | 
				
			||||||
	struct stdlogdata *lp;
 | 
						struct stdlogdata *lp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("stdloginit %s\n", logger->selector);
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	lp = myalloc(sizeof(struct stdlogdata));
 | 
						lp = myalloc(sizeof(struct stdlogdata));
 | 
				
			||||||
	if(!lp) return 1;
 | 
						if(!lp) return 1;
 | 
				
			||||||
	logger->data = lp;
 | 
						logger->data = lp;
 | 
				
			||||||
@ -878,29 +817,21 @@ fflush(stdout);
 | 
				
			|||||||
	else {
 | 
						else {
 | 
				
			||||||
		lp->fp = fopen((char *)dologname (tmpbuf, sizeof(tmpbuf) - 1, logger->selector, NULL, logger->rotate, time(NULL)), "a");
 | 
							lp->fp = fopen((char *)dologname (tmpbuf, sizeof(tmpbuf) - 1, logger->selector, NULL, logger->rotate, time(NULL)), "a");
 | 
				
			||||||
		if(!lp->fp){
 | 
							if(!lp->fp){
 | 
				
			||||||
printf("file not created: %s\n", tmpbuf);
 | 
					 | 
				
			||||||
			myfree(lp);
 | 
								myfree(lp);
 | 
				
			||||||
			return(2);
 | 
								return(2);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
printf("file created: %s\n", tmpbuf);
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int stddobuf(struct clientparam * param, unsigned char * buf, int bufsize, const unsigned char *s){
 | 
					static int stddobuf(struct clientparam * param, unsigned char * buf, int bufsize, const unsigned char *s){
 | 
				
			||||||
printf("stddobuf\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	return dobuf(param, buf, bufsize, s, NULL);
 | 
						return dobuf(param, buf, bufsize, s, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void stdlog(const char * buf, int len, struct LOGGER *logger) {
 | 
					static void stdlog(const char * buf, int len, struct LOGGER *logger) {
 | 
				
			||||||
	FILE *log = ((struct stdlogdata *)logger->data)->fp;
 | 
						FILE *log = ((struct stdlogdata *)logger->data)->fp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
printf("stdlog\n");
 | 
					 | 
				
			||||||
fflush(stdout);
 | 
					 | 
				
			||||||
	fprintf(log, "%s\n", buf);
 | 
						fprintf(log, "%s\n", buf);
 | 
				
			||||||
fflush(log);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void stdlogrotate(struct LOGGER *logger){
 | 
					static void stdlogrotate(struct LOGGER *logger){
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user