Subversion Repositories wimsdev

Rev

Rev 8195 | Rev 8849 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8195 Rev 8342
Line 174... Line 174...
174
    snprintf(pidstr,sizeof(pidstr),"%u",mypid);
174
    snprintf(pidstr,sizeof(pidstr),"%u",mypid);
175
    getnow(); printf("wimslogd %s started at %s.\n",pidstr,nowstr);
175
    getnow(); printf("wimslogd %s started at %s.\n",pidstr,nowstr);
176
    startdate=nowday;
176
    startdate=nowday;
177
    fflush(NULL);
177
    fflush(NULL);
178
    starttime=nowtime; startmin=lastmin=thismin;
178
    starttime=nowtime; startmin=lastmin=thismin;
179
    accessfile(qbuf,"r","log/cquota/lim.host");
179
    wlogdaccessfile(qbuf,"r","log/cquota/lim.host");
180
    accessfile(buf,"r","log/myip"); mystrncpy(ipbuf,find_word_start(buf),sizeof(ipbuf));
180
    wlogdaccessfile(buf,"r","log/myip"); mystrncpy(ipbuf,find_word_start(buf),sizeof(ipbuf));
181
    accessfile(buf,"r","tmp/log/wimslogd.relax"); /* if yes then it is a cluster child */
181
    wlogdaccessfile(buf,"r","tmp/log/wimslogd.relax"); /* if yes then it is a cluster child */
182
    if(strstr(buf,"yes")!=NULL) {       /* register my real IP */
182
    if(strstr(buf,"yes")!=NULL) {       /* register my real IP */
183
        accessfile(nodeipbuf,"r","/etc/myip");
183
        wlogdaccessfile(nodeipbuf,"r","/etc/myip");
184
        accessfile(nodeipbuf,"w","tmp/log/myip");
184
        wlogdaccessfile(nodeipbuf,"w","tmp/log/myip");
185
    }
185
    }
186
    do {
186
    do {
187
        fd_set rset;
187
        fd_set rset;
188
        struct timeval tv;
188
        struct timeval tv;
189
        int t, selectcnt;
189
        int t, selectcnt;
190
 
190
 
191
        if(getpid()!=mypid) return 0;   /* leaked child */
191
        if(getpid()!=mypid) return 0;   /* leaked child */
192
        if(stat(debugfile,&st)==0 && st.st_size<MAX_DEBUGLENGTH) debugging=1;
192
        if(stat(debugfile,&st)==0 && st.st_size<MAX_DEBUGLENGTH) debugging=1;
193
        else debugging=0;
193
        else debugging=0;
194
        accessfile(loadavg,"r","/proc/loadavg");
194
        wlogdaccessfile(loadavg,"r","/proc/loadavg");
195
        for(selectcnt=0; selectcnt<100; selectcnt++) {
195
        for(selectcnt=0; selectcnt<100; selectcnt++) {
196
            tv.tv_sec=0; tv.tv_usec=50000; /* a pause every 50 ms. */
196
            tv.tv_sec=0; tv.tv_usec=50000; /* a pause every 50 ms. */
197
            FD_ZERO(&rset); FD_SET(commsock,&rset);
197
            FD_ZERO(&rset); FD_SET(commsock,&rset);
198
            t=select(commsock+1,&rset,NULL,NULL,&tv);
198
            t=select(commsock+1,&rset,NULL,NULL,&tv);
199
            if(t==0) {forkman(0); continue;}
199
            if(t==0) {forkman(0); continue;}
Line 206... Line 206...
206
        getnow();
206
        getnow();
207
        if(thismin==lastmin) continue;
207
        if(thismin==lastmin) continue;
208
        mincnt++; /* if(mincnt>MAX_MIN) return 0; Refreshment. */
208
        mincnt++; /* if(mincnt>MAX_MIN) return 0; Refreshment. */
209
        if(nowday!=startdate) return 0; /* Daily refreshment. */
209
        if(nowday!=startdate) return 0; /* Daily refreshment. */
210
        lastmin=thismin;
210
        lastmin=thismin;
211
        accessfile(buf,"r",pidfile); strip_trailing_spaces(buf);
211
        wlogdaccessfile(buf,"r",pidfile); strip_trailing_spaces(buf);
212
        if(strcmp(buf,pidstr)!=0) {     /* wrong pid: abandon. */
212
        if(strcmp(buf,pidstr)!=0) {     /* wrong pid: abandon. */
213
            wait_children();
213
            wait_children();
214
            return 0;
214
            return 0;
215
        }
215
        }
216
 
216
 
217
        if(getpid()!=mypid) return 0;   /* leaked child */
217
        if(getpid()!=mypid) return 0;   /* leaked child */
218
        accessfile(qbuf,"r","log/cquota/lim.host");
218
        wlogdaccessfile(qbuf,"r","log/cquota/lim.host");
219
        accessfile(buf,"r","log/myip"); mystrncpy(ipbuf,find_word_start(buf),sizeof(ipbuf));
219
        wlogdaccessfile(buf,"r","log/myip"); mystrncpy(ipbuf,find_word_start(buf),sizeof(ipbuf));
220
        cleancache();
220
        cleancache();
221
        if((thismin%127)==6) homedir(); /* update home directory setup */
221
        if((thismin%127)==6) homedir(); /* update home directory setup */
222
        accessfile(buf,"r","tmp/log/wimslogd.relax"); /* if yes then no housekeeping */
222
        wlogdaccessfile(buf,"r","tmp/log/wimslogd.relax"); /* if yes then no housekeeping */
223
        if(strstr(buf,"yes")==NULL) {
223
        if(strstr(buf,"yes")==NULL) {
224
            dispatch_log();
224
            dispatch_log();
225
            if((thismin%2)==1) local();
225
            if((thismin%2)==1) local();
226
            /* if((thismin%9)==0) */ cleaning(1);       /* clean up session directories */
226
            /* if((thismin%9)==0) */ cleaning(1);       /* clean up session directories */
227
            if((thismin%5)==0 && nowmin>15) housekeep();        /* daily housekeeping */
227
            if((thismin%5)==0 && nowmin>15) housekeep();        /* daily housekeeping */