Changeset 1217
- Timestamp:
- 03/08/10 09:29:16 (2 years ago)
- Files:
-
- 1 modified
-
trunk/unxsBind/bind.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/unxsBind/bind.c
r1216 r1217 20 20 //Local data 21 21 // 22 static FILE *gLfp ;22 static FILE *gLfp=NULL; 23 23 static unsigned uReconfig=0; 24 24 static unsigned uReload=0; … … 79 79 pid_t pidThis; 80 80 const struct tm *tmTime; 81 82 if(gLfp==NULL) return; 81 83 82 84 pidThis=getpid(); … … 604 606 if(cuGID[0]) sscanf(cuGID,"%u",&uGID); 605 607 606 fprintf(stdout,"CreateSlaveFiles(%s)\n",cSlaveNS); 608 //debug only 609 //fprintf(stdout,"CreateSlaveFiles(%s)\n",cSlaveNS); 607 610 608 611 sprintf(gcQuery,"SELECT DISTINCT tZone.cZone,tView.cLabel,tView.cSlave,tView.uView,tNSSet.cMasterIPs," … … 623 626 if(mysql_num_rows(res)<1) 624 627 { 625 fprintf(stdout,"No zones found for slave NS %s\n",cSlaveNS);628 logfileLine("CreateSlaveFiles","No zones found for slave"); 626 629 return; 627 630 } … … 631 634 if(!(fp=fopen("/usr/local/idns/named.d/slave.zones","w"))) 632 635 { 633 fprintf(stderr,"Could not open slave.zones\n");636 logfileLine("CreateSlaveFiles","Could not open slave.zones"); 634 637 exit(1); 635 638 } … … 897 900 unsigned uChanged=0; 898 901 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 899 915 ConnectDb(); 900 916 … … 920 936 " cTargetServer LIKE '%% MASTER EXTERNAL'",field[3]); 921 937 mysql_query(&gMysql,gcQuery); 938 //debug only 922 939 //fprintf(stdout,"%s\n",gcQuery); 923 940 if(mysql_errno(&gMysql)) … … 937 954 exit(1); 938 955 } 939 fprintf(stdout,"Deleted MASTER EXTERNAL job, and continuing ahead\n");956 logfileLine("SlaveJobQueue","Deleted MASTER EXTERNAL job"); 940 957 } 941 958 mysql_free_result(res2); … … 945 962 " cTargetServer LIKE '%% MASTER%%'",field[3]);//3-uMasterJob 946 963 mysql_query(&gMysql,gcQuery); 964 //debug only 947 965 //fprintf(stdout,"%s\n",gcQuery); 948 966 if(mysql_errno(&gMysql)) … … 952 970 } 953 971 res2=mysql_store_result(&gMysql); 954 if(mysql_num_rows(res2) )972 if(mysql_num_rows(res2)>0) 955 973 { 956 974 mysql_free_result(res2); 957 975 //Ignore this job until 'REAL' MASTER 958 976 //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]); 960 980 continue; 961 981 } 982 //debug only 983 //fprintf(stdout,"d2 %s\n",field[2]); 962 984 mysql_free_result(res2); 963 985 … … 984 1006 strcpy(cCurrentZone,field[2]); 985 1007 } 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]); 987 1010 //Allow for combinations: Modify New, Delete New. Modify overrides a Delete. 988 1011 if(strstr(field[1],"New")) uNew++; … … 1004 1027 } 1005 1028 } 1029 mysql_free_result(res); 1006 1030 1007 1031 if(!first) … … 1013 1037 uNew,uDeleteFirst,cNameServer,cMasterIP); 1014 1038 } 1015 mysql_free_result(res);1016 1039 1017 1040 if(uChanged) … … 1199 1222 unsigned uNew,unsigned uDeleteFirst,char *cMasterNS) 1200 1223 { 1224 1225 sprintf(gcQuery,"cZone=%.99s;cMasterNS=%.99s;",cZone,cMasterNS); 1226 logfileLine("ProcessMasterJob",gcQuery); 1201 1227 //return 0 if nothing needs to be done 1202 1228 //return 1 if zone info has changed … … 1260 1286 //debug only 1261 1287 //fprintf(stdout,"Queue Policy for %s: ",cZone); 1288 sprintf(gcQuery,"cZone=%.99s;cNS=%.99s;cIP=%.32s;",cZone,cMasterNS,cMasterIP); 1289 logfileLine("ProcessSlaveJob",gcQuery); 1262 1290 if(uDelete && !uNew) 1263 1291 { 1264 1292 //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"); 1266 1295 //Replace slave.zones named.conf include file 1267 1296 //All Zones replace … … 1272 1301 { 1273 1302 //debug only 1274 fprintf(stdout,"New then Delete\n\n"); 1303 //fprintf(stdout,"New then Delete\n\n"); 1304 logfileLine("ProcessSlaveJob","New+Delete Ignored"); 1275 1305 return(0); 1276 1306 } … … 1279 1309 //debug only 1280 1310 if(uNew) 1281 fprintf(stdout,"Modify New for NS %s\n\n",cMasterNS);1311 logfileLine("ProcessSlaveJob","New+Modify"); 1282 1312 else 1283 fprintf(stdout,"Modify for NS %s\n\n",cMasterNS);1313 logfileLine("ProcessSlaveJob","Modify"); 1284 1314 CreateSlaveFiles(cMasterNS,"",cMasterIP,0); 1285 1315 if(cuControlPort[0]) … … 1296 1326 { 1297 1327 //debug only 1298 fprintf(stdout,"New for NS %s\n\n",cMasterNS);1328 logfileLine("ProcessSlaveJob","New"); 1299 1329 //Append to slave.zones named.conf include file 1300 1330 //Single zone append
