Changeset 1217

Show
Ignore:
Timestamp:
03/08/10 09:29:16 (2 years ago)
Author:
Gary
Message:

unxsBind working on master and slave jobqueue processing changes for logfileLine().

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/unxsBind/bind.c

    r1216 r1217  
    2020//Local data 
    2121// 
    22 static FILE *gLfp; 
     22static FILE *gLfp=NULL; 
    2323static unsigned uReconfig=0; 
    2424static unsigned uReload=0; 
     
    7979        pid_t pidThis; 
    8080        const struct tm *tmTime; 
     81 
     82        if(gLfp==NULL) return; 
    8183 
    8284        pidThis=getpid(); 
     
    604606        if(cuGID[0]) sscanf(cuGID,"%u",&uGID); 
    605607 
    606         fprintf(stdout,"CreateSlaveFiles(%s)\n",cSlaveNS); 
     608        //debug only 
     609        //fprintf(stdout,"CreateSlaveFiles(%s)\n",cSlaveNS); 
    607610 
    608611        sprintf(gcQuery,"SELECT DISTINCT tZone.cZone,tView.cLabel,tView.cSlave,tView.uView,tNSSet.cMasterIPs," 
     
    623626        if(mysql_num_rows(res)<1)  
    624627        { 
    625                 fprintf(stdout,"No zones found for slave NS %s\n",cSlaveNS); 
     628                logfileLine("CreateSlaveFiles","No zones found for slave"); 
    626629                return; 
    627630        } 
     
    631634                if(!(fp=fopen("/usr/local/idns/named.d/slave.zones","w"))) 
    632635                { 
    633                         fprintf(stderr,"Could not open slave.zones\n"); 
     636                        logfileLine("CreateSlaveFiles","Could not open slave.zones"); 
    634637                        exit(1); 
    635638                } 
     
    897900        unsigned uChanged=0; 
    898901 
     902#ifdef cLOGFILE 
     903        if((gLfp=fopen(cLOGFILE,"a"))==NULL) 
     904        { 
     905                fprintf(stderr,"Could not open logfile: %s\n",cLOGFILE); 
     906                exit(300); 
     907        } 
     908#else 
     909        gLfp=stdout; 
     910#endif 
     911         
     912        ConnectDb(); 
     913 
     914 
    899915        ConnectDb(); 
    900916         
     
    920936                                        " cTargetServer LIKE '%% MASTER EXTERNAL'",field[3]); 
    921937                        mysql_query(&gMysql,gcQuery); 
     938                        //debug only 
    922939                        //fprintf(stdout,"%s\n",gcQuery); 
    923940                        if(mysql_errno(&gMysql))  
     
    937954                                        exit(1); 
    938955                                } 
    939                                 fprintf(stdout,"Deleted MASTER EXTERNAL job, and continuing ahead\n"); 
     956                                logfileLine("SlaveJobQueue","Deleted MASTER EXTERNAL job"); 
    940957                        } 
    941958                        mysql_free_result(res2); 
     
    945962                                        " cTargetServer LIKE '%% MASTER%%'",field[3]);//3-uMasterJob 
    946963                        mysql_query(&gMysql,gcQuery); 
     964                        //debug only 
    947965                        //fprintf(stdout,"%s\n",gcQuery); 
    948966                        if(mysql_errno(&gMysql))  
     
    952970                        } 
    953971                        res2=mysql_store_result(&gMysql); 
    954                         if(mysql_num_rows(res2))  
     972                        if(mysql_num_rows(res2)>0)  
    955973                        { 
    956974                                mysql_free_result(res2); 
    957975                                //Ignore this job until 'REAL' MASTER 
    958976                                //handles it. 
    959                                 fprintf(stdout,"Skipping job not yet handled by MASTER\n"); 
     977                                logfileLine("SlaveJobQueue","Skipping job not yet handled by MASTER"); 
     978                                //debug only 
     979                                //fprintf(stdout,"d1 %s\n",field[2]); 
    960980                                continue; 
    961981                        } 
     982                        //debug only 
     983                        //fprintf(stdout,"d2 %s\n",field[2]); 
    962984                        mysql_free_result(res2); 
    963985                         
     
    9841006                                strcpy(cCurrentZone,field[2]); 
    9851007                        } 
    986                         fprintf(stdout,"%s\t%s\t%s\n",field[0],field[2],field[1]); 
     1008                        //debug only 
     1009                        //fprintf(stdout,"%s\t%s\t%s\n",field[0],field[2],field[1]); 
    9871010                        //Allow for combinations: Modify New, Delete New. Modify overrides a Delete. 
    9881011                        if(strstr(field[1],"New")) uNew++; 
     
    10041027                } 
    10051028        } 
     1029        mysql_free_result(res); 
    10061030 
    10071031        if(!first) 
     
    10131037                                uNew,uDeleteFirst,cNameServer,cMasterIP); 
    10141038        } 
    1015         mysql_free_result(res); 
    10161039         
    10171040        if(uChanged) 
     
    11991222                        unsigned uNew,unsigned uDeleteFirst,char *cMasterNS) 
    12001223{ 
     1224 
     1225        sprintf(gcQuery,"cZone=%.99s;cMasterNS=%.99s;",cZone,cMasterNS); 
     1226        logfileLine("ProcessMasterJob",gcQuery); 
    12011227        //return 0 if nothing needs to be done 
    12021228        //return 1 if zone info has changed 
     
    12601286        //debug only 
    12611287        //fprintf(stdout,"Queue Policy for %s: ",cZone); 
     1288        sprintf(gcQuery,"cZone=%.99s;cNS=%.99s;cIP=%.32s;",cZone,cMasterNS,cMasterIP); 
     1289        logfileLine("ProcessSlaveJob",gcQuery); 
    12621290        if(uDelete && !uNew) 
    12631291        { 
    12641292                //debug only 
    1265                 fprintf(stdout,"Delete for NS %s\n\n",cMasterNS); 
     1293                //fprintf(stdout,"Delete for NS %s\n\n",cMasterNS); 
     1294                logfileLine("ProcessSlaveJob","Delete"); 
    12661295                //Replace slave.zones named.conf include file 
    12671296                //All Zones replace 
     
    12721301        { 
    12731302                //debug only 
    1274                 fprintf(stdout,"New then Delete\n\n"); 
     1303                //fprintf(stdout,"New then Delete\n\n"); 
     1304                logfileLine("ProcessSlaveJob","New+Delete Ignored"); 
    12751305                return(0); 
    12761306        } 
     
    12791309                //debug only 
    12801310                if(uNew) 
    1281                         fprintf(stdout,"Modify New for NS %s\n\n",cMasterNS); 
     1311                        logfileLine("ProcessSlaveJob","New+Modify"); 
    12821312                else 
    1283                         fprintf(stdout,"Modify for NS %s\n\n",cMasterNS); 
     1313                        logfileLine("ProcessSlaveJob","Modify"); 
    12841314                CreateSlaveFiles(cMasterNS,"",cMasterIP,0); 
    12851315                if(cuControlPort[0]) 
     
    12961326        { 
    12971327                //debug only 
    1298                 fprintf(stdout,"New for NS %s\n\n",cMasterNS); 
     1328                logfileLine("ProcessSlaveJob","New"); 
    12991329                //Append to slave.zones named.conf include file 
    13001330                //Single zone append