MCPcopy Create free account
hub / github.com/3proxy/3proxy / cyclestep

Function cyclestep

src/3proxy.c:235–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235void cyclestep(void){
236 struct tm *tm;
237 time_t minutecounter;
238 unsigned char tmpbuf[8192];
239
240 minutecounter = time(0);
241 for(;;){
242 usleep(SLEEPTIME*999);
243
244 conf.time = time(0);
245 if(conf.needreload) {
246 doschedule();
247 reload();
248 conf.needreload = 0;
249 }
250 doschedule();
251 if(conf.stdlog)fflush(conf.stdlog);
252 if(timechanged(minutecounter, conf.time, MINUTELY)) {
253 struct filemon *fm;
254 struct stat sb;
255
256 for(fm=conf.fmon; fm; fm=fm->next){
257 if(!stat(fm->path, &sb)){
258 if(fm->sb.st_mtime != sb.st_mtime || fm->sb.st_size != sb.st_size){
259 stat(fm->path, &fm->sb);
260 conf.needreload = 1;
261 }
262 }
263 }
264
265 }
266 if(timechanged(basetime, conf.time, DAILY)) {
267 tm = localtime(&conf.time);
268 wday = (1 << tm->tm_wday);
269 tm->tm_hour = tm->tm_min = tm->tm_sec = 0;
270 basetime = mktime(tm);
271 }
272 if(conf.logname) {
273 if(timechanged(conf.logtime, conf.time, conf.logtype)) {
274 FILE *fp;
275 fp = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.time), "a");
276 if (fp) {
277 pthread_mutex_lock(&log_mutex);
278 fclose(conf.stdlog);
279 conf.stdlog = fp;
280 pthread_mutex_unlock(&log_mutex);
281 }
282 fseek(stdout, 0L, SEEK_END);
283 usleep(SLEEPTIME);
284 conf.logtime = conf.time;
285 if(conf.logtype != NONE && conf.rotate) {
286 int t;
287 t = 1;
288 switch(conf.logtype){
289 case ANNUALLY:
290 t = t * 12;
291 case MONTHLY:
292 t = t * 4;

Callers 2

ServiceMainFunction · 0.85
WinMainFunction · 0.85

Calls 6

doscheduleFunction · 0.85
reloadFunction · 0.85
timechangedFunction · 0.85
dolognameFunction · 0.85
dumpcountersFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected