mirror of
				https://github.com/3proxy/3proxy.git
				synced 2025-10-31 05:45:51 +08:00 
			
		
		
		
	fix some warnings, add log flushing for standalone services
This commit is contained in:
		
							parent
							
								
									a0da9c97e8
								
							
						
					
					
						commit
						245222f59c
					
				| @ -202,7 +202,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){ | |||||||
| 
 | 
 | ||||||
| 	cheader.updated = conf.time; | 	cheader.updated = conf.time; | ||||||
| 	lseek(counterd, 0, SEEK_SET); | 	lseek(counterd, 0, SEEK_SET); | ||||||
| 	write(counterd, &cheader, sizeof(struct counter_header));			 | 	(void)write(counterd, &cheader, sizeof(struct counter_header));			 | ||||||
| 	for(tl=tlin; tl; tl = tl->next){ | 	for(tl=tlin; tl; tl = tl->next){ | ||||||
| 		if(tl->number){ | 		if(tl->number){ | ||||||
| 			lseek(counterd,  | 			lseek(counterd,  | ||||||
| @ -211,7 +211,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){ | |||||||
| 			crecord.traf64 = tl->traf64; | 			crecord.traf64 = tl->traf64; | ||||||
| 			crecord.cleared = tl->cleared; | 			crecord.cleared = tl->cleared; | ||||||
| 			crecord.updated = tl->updated; | 			crecord.updated = tl->updated; | ||||||
| 			write(counterd, &crecord, sizeof(struct counter_record)); | 			(void)write(counterd, &crecord, sizeof(struct counter_record)); | ||||||
| 		} | 		} | ||||||
| 		if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){ | 		if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){ | ||||||
| 			tl->cleared = conf.time; | 			tl->cleared = conf.time; | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								src/conf.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/conf.c
									
									
									
									
									
								
							| @ -1161,7 +1161,7 @@ static int h_ace(int argc, char **argv){ | |||||||
| 					sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record), | 					sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record), | ||||||
| 					SEEK_SET); | 					SEEK_SET); | ||||||
| 				memset(&crecord, 0, sizeof(struct counter_record)); | 				memset(&crecord, 0, sizeof(struct counter_record)); | ||||||
| 				read(conf.counterd, &crecord, sizeof(struct counter_record)); | 				(void)read(conf.counterd, &crecord, sizeof(struct counter_record)); | ||||||
| 				tl->traf64 = crecord.traf64; | 				tl->traf64 = crecord.traf64; | ||||||
| 				tl->cleared = crecord.cleared; | 				tl->cleared = crecord.cleared; | ||||||
| 				tl->updated = crecord.updated; | 				tl->updated = crecord.updated; | ||||||
| @ -1379,15 +1379,18 @@ static int h_chroot(int argc, char **argv){ | |||||||
| 		} | 		} | ||||||
| 		chrootp = mystrdup((char *)argv[1]); | 		chrootp = mystrdup((char *)argv[1]); | ||||||
| 	} | 	} | ||||||
| 	if (gid && setregid(gid,gid)) { | 	if(gid && setregid(gid,gid)) { | ||||||
| 		fprintf(stderr, "Unable to set gid %d", (int)gid); | 		fprintf(stderr, "Unable to set gid %d", (int)gid); | ||||||
| 		return(4); | 		return(4); | ||||||
| 	} | 	} | ||||||
| 	if (uid && setreuid(uid,uid)) { | 	if(uid && setreuid(uid,uid)) { | ||||||
| 		fprintf(stderr, "Unable to set uid %d", (int)uid); | 		fprintf(stderr, "Unable to set uid %d", (int)uid); | ||||||
| 		return(5); | 		return(5); | ||||||
| 	} | 	} | ||||||
| 	chdir("/"); | 	if(chdir("/")){ | ||||||
|  | 		fprintf(stderr, "Unable to chdir to /"); | ||||||
|  | 		return(5); | ||||||
|  | 	} | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  | |||||||
| @ -836,9 +836,13 @@ 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; | ||||||
| 
 | 
 | ||||||
| 	fprintf(log, "%s\n", buf); | 	fprintf(log, "%s\n", buf); | ||||||
|  | #ifdef WITHMAIN | ||||||
|  | 	fflush(log); | ||||||
|  | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void stdlogrotate(struct LOGGER *logger){ | static void stdlogrotate(struct LOGGER *logger){ | ||||||
|  | #ifndef WITHMAIN | ||||||
|  char tmpbuf[1024]; |  char tmpbuf[1024]; | ||||||
|  struct stdlogdata *lp = (struct stdlogdata *)logger->data; |  struct stdlogdata *lp = (struct stdlogdata *)logger->data; | ||||||
|  if(lp->fp) lp->fp = freopen((char *)dologname (tmpbuf, sizeof(tmpbuf) -1, logger->selector, NULL, logger->rotate, conf.time), "a", lp->fp); |  if(lp->fp) lp->fp = freopen((char *)dologname (tmpbuf, sizeof(tmpbuf) -1, logger->selector, NULL, logger->rotate, conf.time), "a", lp->fp); | ||||||
| @ -886,9 +890,10 @@ static void stdlogrotate(struct LOGGER *logger){ | |||||||
| 			else | 			else | ||||||
| 				strcat((char *)tmpbuf, (char *)conf.archiver[i]); | 				strcat((char *)tmpbuf, (char *)conf.archiver[i]); | ||||||
| 		} | 		} | ||||||
| 		system((char *)tmpbuf+1); | 		(void)system((char *)tmpbuf+1); | ||||||
| 	} | 	} | ||||||
|  } |  } | ||||||
|  | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void stdlogflush(struct LOGGER *logger){ | static void stdlogflush(struct LOGGER *logger){ | ||||||
| @ -913,8 +918,10 @@ static void logsyslog(const char * buf, int len, struct LOGGER *logger) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void syslogrotate(struct LOGGER *logger){ | static void syslogrotate(struct LOGGER *logger){ | ||||||
|  | #ifndef WITHMAIN | ||||||
| 	closelog(); | 	closelog(); | ||||||
| 	openlog(logger->selector+1, LOG_PID, LOG_DAEMON); | 	openlog(logger->selector+1, LOG_PID, LOG_DAEMON); | ||||||
|  | #endif | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void syslogclose(struct LOGGER *logger){ | static void syslogclose(struct LOGGER *logger){ | ||||||
|  | |||||||
| @ -557,7 +557,7 @@ void * adminchild(struct clientparam* param) { | |||||||
| 			if(writable && !error){ | 			if(writable && !error){ | ||||||
| 				fflush(writable); | 				fflush(writable); | ||||||
| #ifndef _WINCE | #ifndef _WINCE | ||||||
| 				ftruncate(fileno(writable), ftell(writable)); | 				(void)ftruncate(fileno(writable), ftell(writable)); | ||||||
| #endif | #endif | ||||||
| 			} | 			} | ||||||
| 			printstr(&pp, error?    "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file": | 			printstr(&pp, error?    "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file": | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 z3APA3A
						z3APA3A