ANU News Patch Patch ID: 940526_newsskim.c!bailey@genetics.upenn.edu Date: 26-May-1994 Author: Charles Bailey bailey@genetics.upenn.edu News Version: 6.1beta9 News Files: NewsSkim.C, NewsUtility.C, NewsControl.C, NewsDelete.C, NewsExtern.H Description: Adds ability to determine whether attempt to open an item file failed because the file was locked by another user, and if so to ignore it. Absent this, if the item file was locked, an error was returned in version 6.1beta9; in previous versions the command affected might fail, or, if the error was incurred during a skim pass, the item was deleted. *** newsskim.c --- newsskim_new.c ************** *** 28,30 ** **-- **/ --- 28,33 ----- + ** V6.1b9 25-May-1994 Charles Bailey bailey@genetics.upenn.edu + ** - add flk param to do_oitem calls and _ck_*_info macros so + ** file error doesn't cause entire skim pass to abort ** **-- **/ ************** *** 47,52 #if vax11c #include sordef #else #include #endif --- 50,56 ----- #if vax11c #include sordef + #include stsdef #else #include #include ************** *** 49,54 #include sordef #else #include #endif #define SOR$M_NODUPS 0x40 --- 53,59 ----- #include stsdef #else #include + #include #endif #define SOR$M_NODUPS 0x40 ************** *** 358,363 } /* * files_skim * * Delete all unreferenced ITM files in NEWS area --- 363,389 ----- } /* + * error checking macros for use during skim - force initial condition to + * severity I, so that we don't abort the skim pass. + * 26-May-1994 Charles Bailey bailey@genetics.upenn.edu + */ + + #define _ck_error_fp_info(sts,file_ptr) \ + (((file_ptr) && !ferror(file_ptr)) ? 1 : \ + (report_cio_error_routine((sts & ~STS$M_SEVERITY) | STS$K_INFO, \ + file_ptr,0,module_name_str,__LINE__),0)) + + #define _ck_error_fn_info(sts,file_name) \ + ((!errno) ? 1 : \ + (report_cio_error_routine((sts & ~STS$M_SEVERITY) | STS$K_INFO, \ + 0,file_name,module_name_str,__LINE__),0)) + + #define _ck_close_info(file_ptr) _ck_error_fp_info(NEWS$_CLOFAIL,file_ptr) + #define _ck_delete_info(file_name) _ck_error_fn_info(NEWS$_REMFAIL,file_name) + #define _ck_open_info(file_name) _ck_error_fn_info(NEWS$_OPNFAIL,file_name) + #define _ck_put_info(file_ptr) _ck_error_fp_info(NEWS$_PUTFAIL,file_ptr) + + /* * files_skim * * Delete all unreferenced ITM files in NEWS area ************** *** 445,451 } if (no_grp) { ++del_count; ! if (delete(fnam)) _ck_delete(fnam); continue; } else { --- 471,477 ----- } if (no_grp) { ++del_count; ! if (delete(fnam)) _ck_delete_info(fnam); continue; } else { ************** *** 454,460 if ((last_g == itm_key[1]) && (last_m == itm_key[0])) { if (verbose) printf("\tDelete %s - backup version?\n",fnam); ++del_count; ! if (delete(fnam)) _ck_delete(fnam); continue; } if (!sys_get_nornf(&itmrab)) { --- 480,486 ----- if ((last_g == itm_key[1]) && (last_m == itm_key[0])) { if (verbose) printf("\tDelete %s - backup version?\n",fnam); ++del_count; ! if (delete(fnam)) _ck_delete_info(fnam); continue; } if (!sys_get_nornf(&itmrab)) { ************** *** 459,465 } if (!sys_get_nornf(&itmrab)) { ++del_count; ! if (delete(fnam)) _ck_delete(fnam); } last_g = itm_key[1]; last_m = itm_key[0]; --- 485,491 ----- } if (!sys_get_nornf(&itmrab)) { ++del_count; ! if (delete(fnam)) _ck_delete_info(fnam); } last_g = itm_key[1]; last_m = itm_key[0]; ************** *** 525,531 printf("\t\t%s - DELETED\n",gnam); } chmod(gnam,0755); ! if (delete(gnam)) _ck_delete(gnam); continue; } strcpy(grp,util_undir(grp)); --- 551,557 ----- printf("\t\t%s - DELETED\n",gnam); } chmod(gnam,0755); ! if (delete(gnam)) _ck_delete_info(gnam); continue; } strcpy(grp,util_undir(grp)); ************** *** 556,562 else { grp[strlen(grp) - 1] = '\0'; sprintf(itm_fname,Access_template,util_dir(grp)); ! delete_file_versions(itm_fname); if (!delete(gnam)) { if (verbose) printf("\t\t%s Deleted - no newsgroup\n",gnam); } --- 582,589 ----- else { grp[strlen(grp) - 1] = '\0'; sprintf(itm_fname,Access_template,util_dir(grp)); ! while (!delete(itm_fname)) ; ! if (errno != ENOENT) _ck_delete_info(itm_fname); if (!delete(gnam)) { if (verbose) printf("\t\t%s Deleted - no newsgroup\n",gnam); } ************** *** 561,567 if (verbose) printf("\t\t%s Deleted - no newsgroup\n",gnam); } else { ! _ck_delete(gnam); if (verbose) printf("\t\t%s Not deleted - directory not empty or protected\n",gnam); } --- 588,594 ----- if (verbose) printf("\t\t%s Deleted - no newsgroup\n",gnam); } else { ! _ck_delete_info(gnam); if (verbose) printf("\t\t%s Not deleted - directory not empty or protected\n",gnam); } ************** *** 705,712 sprintf(itm_fname,Access_template,util_dir(newsgrp.grp_name)); sysprv(); if ((fpr = fopen(itm_fname,"r")) != 0) { ! if (fclose(fpr)) _ck_close(fpr); ! delete_file_versions(itm_fname); } nosysprv(); } --- 732,740 ----- sprintf(itm_fname,Access_template,util_dir(newsgrp.grp_name)); sysprv(); if ((fpr = fopen(itm_fname,"r")) != 0) { ! if (fclose(fpr)) _ck_close_info(fpr); ! while (!delete(itm_fname)) ; ! if (errno != ENOENT) _ck_delete_info(itm_fname); } nosysprv(); } ************** *** 772,778 time_t cur_time,t; int del_all_itms = 0, itm_count = 0, glob_exp_time, grp_exp_time = 0, itm_exp_time, s_smg_active = 0, sor_start = 0, fchk = 1, hist_date, ! mfo = mailfile_open, itm_skim_count; unsigned int itm_key[2], cur_grp = 0; unsigned short glob_exp_val, grp_exp_val = 0, itm_exp_val, arch_len, newsgroups_len; --- 800,806 ----- time_t cur_time,t; int del_all_itms = 0, itm_count = 0, glob_exp_time, grp_exp_time = 0, itm_exp_time, s_smg_active = 0, sor_start = 0, fchk = 1, hist_date, ! mfo = mailfile_open, itm_skim_count, flk; unsigned int itm_key[2], cur_grp = 0; unsigned short glob_exp_val, grp_exp_val = 0, itm_exp_val, arch_len, newsgroups_len; ************** *** 1072,1085 if (fchk) { if (!(fpr = do_oitem(&newsitm,"r",newsgrp.grp_name,0, ! (newsgrp.grp_flags & NEWS_M_RESTRICT_SET)))) { ! if (newsgrp.grp_flags & NEWS_M_NNTPSRV) { ! newsitm.itm_cachedate = 0; ! sys_update(&itmrab); ! if (served_cmd) add_check_id(newsgrp.grp_name,newsitm.itm_id, ! newsgrp.grp_num,newsgrp.grp_srvnode, ! grp_exp_time,newsgrp.grp_srvproto); ! } else { ++itm_skim_count; sys_delete(&itmrab); --- 1100,1107 ----- if (fchk) { if (!(fpr = do_oitem(&newsitm,"r",newsgrp.grp_name,0, ! (newsgrp.grp_flags & NEWS_M_RESTRICT_SET),&flk))) { ! if (flk) _ck_open_info(itm_fname); else { if (newsgrp.grp_flags & NEWS_M_NNTPSRV) { newsitm.itm_cachedate = 0; ************** *** 1081,1089 grp_exp_time,newsgrp.grp_srvproto); } else { ! ++itm_skim_count; ! sys_delete(&itmrab); ! continue; } } else { --- 1103,1120 ----- (newsgrp.grp_flags & NEWS_M_RESTRICT_SET),&flk))) { if (flk) _ck_open_info(itm_fname); else { ! if (newsgrp.grp_flags & NEWS_M_NNTPSRV) { ! newsitm.itm_cachedate = 0; ! sys_update(&itmrab); ! if (served_cmd) add_check_id(newsgrp.grp_name,newsitm.itm_id, ! newsgrp.grp_num,newsgrp.grp_srvnode, ! grp_exp_time,newsgrp.grp_srvproto); ! } ! else { ! ++itm_skim_count; ! sys_delete(&itmrab); ! continue; ! } } } else { ************** *** 1087,1093 } } else { ! if (fclose(fpr)) _ck_close(fpr); if (!newsitm.itm_cachedate) { time((time_t *) &newsitm.itm_cachedate); sys_update(&itmrab); --- 1118,1124 ----- } } else { ! if (fclose(fpr)) _ck_close_info(fpr); if (!newsitm.itm_cachedate) { time((time_t *) &newsitm.itm_cachedate); sys_update(&itmrab); ************** *** 1137,1143 } else fpo = fopen(arch_file,"w","rfm=var","rat=cr"); if (!fpo) { ! if (fclose(fpi)) _ck_close(fpi); continue; } if (fprintf(fpo,"#! rnews %d\n",inp_file.st_size) < 0) _ck_put(fpo); --- 1168,1174 ----- } else fpo = fopen(arch_file,"w","rfm=var","rat=cr"); if (!fpo) { ! if (fclose(fpi)) _ck_close_info(fpi); continue; } if (fprintf(fpo,"#! rnews %d\n",inp_file.st_size) < 0) _ck_put_info(fpo); ************** *** 1140,1146 if (fclose(fpi)) _ck_close(fpi); continue; } ! if (fprintf(fpo,"#! rnews %d\n",inp_file.st_size) < 0) _ck_put(fpo); while (fgets(xbuf,510,fpi)) { fputs(xbuf,fpo); _ck_put(fpo); } --- 1171,1177 ----- if (fclose(fpi)) _ck_close_info(fpi); continue; } ! if (fprintf(fpo,"#! rnews %d\n",inp_file.st_size) < 0) _ck_put_info(fpo); while (fgets(xbuf,510,fpi)) { fputs(xbuf,fpo); _ck_put_info(fpo); } ************** *** 1142,1148 } if (fprintf(fpo,"#! rnews %d\n",inp_file.st_size) < 0) _ck_put(fpo); while (fgets(xbuf,510,fpi)) { ! fputs(xbuf,fpo); _ck_put(fpo); } if (fclose(fpo)) _ck_close(fpo); if (fclose(fpi)) _ck_close(fpi); --- 1173,1179 ----- } if (fprintf(fpo,"#! rnews %d\n",inp_file.st_size) < 0) _ck_put_info(fpo); while (fgets(xbuf,510,fpi)) { ! fputs(xbuf,fpo); _ck_put_info(fpo); } if (fclose(fpo)) _ck_close_info(fpo); if (fclose(fpi)) _ck_close_info(fpi); ************** *** 1144,1151 while (fgets(xbuf,510,fpi)) { fputs(xbuf,fpo); _ck_put(fpo); } ! if (fclose(fpo)) _ck_close(fpo); ! if (fclose(fpi)) _ck_close(fpi); } c$cks(sor$end_sort(0)); } --- 1175,1182 ----- while (fgets(xbuf,510,fpi)) { fputs(xbuf,fpo); _ck_put_info(fpo); } ! if (fclose(fpo)) _ck_close_info(fpo); ! if (fclose(fpi)) _ck_close_info(fpi); } c$cks(sor$end_sort(0)); } ************** *** 1233,1239 struct gl_list *tmp = ns_head; unsigned int itm_key[2]; int itmcount, ! delcount = 0; FILE *fpr; while (tmp) { --- 1264,1271 ----- struct gl_list *tmp = ns_head; unsigned int itm_key[2]; int itmcount, ! delcount = 0, ! flk; FILE *fpr; while (tmp) { ************** *** 1256,1265 if (newsitm.itm_grp != newsgrp.grp_num) break; itmrab.rab$l_rop = RAB$M_WAT; itmrab.rab$b_rac = RAB$C_SEQ; ! if (!(fpr = do_oitem(&newsitm,"r",newsgrp.grp_name,0,(newsgrp.grp_flags & NEWS_M_RESTRICT_SET)))) { ! ++delcount; ! sys_delete(&itmrab); ! continue; } ++itmcount; } --- 1288,1301 ----- if (newsitm.itm_grp != newsgrp.grp_num) break; itmrab.rab$l_rop = RAB$M_WAT; itmrab.rab$b_rac = RAB$C_SEQ; ! if (!(fpr = do_oitem(&newsitm,"r",newsgrp.grp_name,0, ! (newsgrp.grp_flags & NEWS_M_RESTRICT_SET),&flk))) { ! if (flk) _ck_open_info(itm_fname); ! else { ! ++delcount; ! sys_delete(&itmrab); ! continue; ! } } ++itmcount; } *** newsutility.c --- newsutility_new.c ************** *** 101,103 **-- **/ --- 101,106 ----- + ** V6.1b9 25-May-1994 Charles Bailey bailey@genetics.upenn.edu + ** - add flk to do_openi and do_oitem to allow skim to ignore + ** contention for item files **-- **/ ************** *** 784,790 * Use SYSPRV if WRITE access required, and change the mask to (g:re,w:re). */ ! FILE *do_openi(mode,server_name,protected) char *mode,*server_name; int protected; { --- 787,793 ----- * Use SYSPRV if WRITE access required, and change the mask to (g:re,w:re). */ ! FILE *do_openi(mode,server_name,protected,flk) char *mode,*server_name; int protected, *flk; { ************** *** 786,792 FILE *do_openi(mode,server_name,protected) char *mode,*server_name; ! int protected; { FILE *tmp_fpr; int nmask = 022, omask = 0; --- 789,795 ----- FILE *do_openi(mode,server_name,protected,flk) char *mode,*server_name; ! int protected, *flk; { FILE *tmp_fpr; int nmask = 022, omask = 0; ************** *** 793,798 struct stat sb; int status; if (protected) nmask = 077; if (*mode == 'w') omask = umask(nmask); --- 796,802 ----- struct stat sb; int status; + if (flk) *flk = 0; if (protected) nmask = 077; if (*mode == 'w') omask = umask(nmask); ************** *** 805,811 else tmp_fpr = fopen(itm_fname,mode,"mbc=16", "rat=cr","rfm=var"); if (tmp_fpr && !ferror(tmp_fpr)) ; /* ok */ ! else { tmp_fpr = NULL; if (errno == ENOENT) ; /* expected error - file not found */ else if (*mode == 'r') _ck_open_r(tmp_fpr,itm_fname); --- 809,815 ----- else tmp_fpr = fopen(itm_fname,mode,"mbc=16", "rat=cr","rfm=var"); if (tmp_fpr && !ferror(tmp_fpr)) ; /* ok */ ! else if (flk && errno == EVMSERR && vaxc$errno == RMS$_FLK) { tmp_fpr = NULL; *flk =1; } ************** *** 807,812 if (tmp_fpr && !ferror(tmp_fpr)) ; /* ok */ else { tmp_fpr = NULL; if (errno == ENOENT) ; /* expected error - file not found */ else if (*mode == 'r') _ck_open_r(tmp_fpr,itm_fname); else _ck_open_w(tmp_fpr,itm_fname); --- 811,820 ----- if (tmp_fpr && !ferror(tmp_fpr)) ; /* ok */ else if (flk && errno == EVMSERR && vaxc$errno == RMS$_FLK) { tmp_fpr = NULL; + *flk =1; + } + else { + tmp_fpr = NULL; if (errno == ENOENT) ; /* expected error - file not found */ else if (*mode == 'r') _ck_open_r(tmp_fpr,itm_fname); else _ck_open_w(tmp_fpr,itm_fname); ************** *** 835,841 * Use SYSPRV if WRITE access required, and change the mask to (g:re,w:re). */ ! FILE *do_oitem(itm,mode,grp_name,server_name,protected) ITM *itm; char *mode, *grp_name, *server_name; int protected; --- 843,849 ----- * Use SYSPRV if WRITE access required, and change the mask to (g:re,w:re). */ ! FILE *do_oitem(itm,mode,grp_name,server_name,protected,flk) ITM *itm; char *mode, *grp_name, *server_name; int protected, *flk; ************** *** 838,844 FILE *do_oitem(itm,mode,grp_name,server_name,protected) ITM *itm; char *mode, *grp_name, *server_name; ! int protected; { int status; sprintf(itm_fname,Itm_template,util_dir(grp_name),itm->itm_num); --- 846,852 ----- FILE *do_oitem(itm,mode,grp_name,server_name,protected,flk) ITM *itm; char *mode, *grp_name, *server_name; ! int protected, *flk; { int status; sprintf(itm_fname,Itm_template,util_dir(grp_name),itm->itm_num); ************** *** 842,848 { int status; sprintf(itm_fname,Itm_template,util_dir(grp_name),itm->itm_num); ! return(do_openi(mode,server_name,protected)); } /* --- 850,856 ----- { int status; sprintf(itm_fname,Itm_template,util_dir(grp_name),itm->itm_num); ! return(do_openi(mode,server_name,protected,flk)); } /* ************** *** 1456,1462 else { sprintf(itm_fname,Itm_template,util_dir(ga[g]->grp_name),ga[g]->grp_ia[i].itm_num); if ((tmp = do_openi(mode,server_name, ! (ga[g]->grp_flags & NEWS_M_RESTRICT_SET))) != 0) return(tmp); if (strcmp(mode,"r") || (!(ga[g]->grp_flags & NEWS_M_NNTPSRV))) return(tmp); tmp = get_server_file(ga[g]->grp_ia[i].itm_id,ga[g]->grp_srvnode,server_name, --- 1464,1470 ----- else { sprintf(itm_fname,Itm_template,util_dir(ga[g]->grp_name),ga[g]->grp_ia[i].itm_num); if ((tmp = do_openi(mode,server_name, ! (ga[g]->grp_flags & NEWS_M_RESTRICT_SET),0)) != 0) return(tmp); if (strcmp(mode,"r") || (!(ga[g]->grp_flags & NEWS_M_NNTPSRV))) return(tmp); tmp = get_server_file(ga[g]->grp_ia[i].itm_id,ga[g]->grp_srvnode,server_name, ************** *** 1800,1806 if (!nntp_client) { sprintf(itm_fname,Itm_template,util_dir(ga[g]->grp_name),ga[g]->grp_ia[i].itm_num); if ((tmp = do_openi(mode,server_name, ! (ga[g]->grp_flags & NEWS_M_RESTRICT_SET))) != 0) return(tmp); if (strcmp(mode,"r") || (!(ga[g]->grp_flags & NEWS_M_NNTPSRV))) return(tmp); --- 1808,1814 ----- if (!nntp_client) { sprintf(itm_fname,Itm_template,util_dir(ga[g]->grp_name),ga[g]->grp_ia[i].itm_num); if ((tmp = do_openi(mode,server_name, ! (ga[g]->grp_flags & NEWS_M_RESTRICT_SET),0)) != 0) return(tmp); if (strcmp(mode,"r") || (!(ga[g]->grp_flags & NEWS_M_NNTPSRV))) return(tmp); *** newscontrol.c --- newscontrol_new.c ************** *** 55,57 ** **-- **/ --- 55,59 ----- + ** V6.1b9 25-May-1994 Charles Bailey bailey@genetics.upenn.edu + ** - add dummy flk param to do_oitem calls ** **-- **/ ************** *** 977,983 if ( sys_get_nornf(&itmrab) && !strcmp(l_id,newsitm.itm_id) && (gn = ga_locate(newsitm.itm_grp)) ! && (fpr = do_oitem(&newsitm,"r",ga[gn]->grp_name,0,(ga[gn]->grp_flags & NEWS_M_RESTRICT_SET)))) { fgetname(fpr,fname); fclose(fpr); sys_remote_send(post_path,s_str,&post_dist,fname,l_id,0); --- 979,986 ----- if ( sys_get_nornf(&itmrab) && !strcmp(l_id,newsitm.itm_id) && (gn = ga_locate(newsitm.itm_grp)) ! && (fpr = do_oitem(&newsitm,"r",ga[gn]->grp_name,0, ! (ga[gn]->grp_flags & NEWS_M_RESTRICT_SET),0))) { fgetname(fpr,fname); fclose(fpr); sys_remote_send(post_path,s_str,&post_dist,fname,l_id,0); ************** *** 997,1003 if ( sys_get_nornf(&itmrab) && !strcmp(l_id,newsitm.itm_id) && (gn = ga_locate(newsitm.itm_grp)) ! && (fpr = do_oitem(&newsitm,"r",ga[gn]->grp_name,0,(ga[gn]->grp_flags & NEWS_M_RESTRICT_SET)))) { fgetname(fpr,fname); fclose(fpr); sys_remote_send(post_path,s_str,&post_dist,itm_fname,l_id,0); --- 1000,1007 ----- if ( sys_get_nornf(&itmrab) && !strcmp(l_id,newsitm.itm_id) && (gn = ga_locate(newsitm.itm_grp)) ! && (fpr = do_oitem(&newsitm,"r",ga[gn]->grp_name,0, ! (ga[gn]->grp_flags & NEWS_M_RESTRICT_SET),0))) { fgetname(fpr,fname); fclose(fpr); sys_remote_send(post_path,s_str,&post_dist,itm_fname,l_id,0); *** newsdelete.c --- newsdelete_new.c ************** *** 33,35 **-- **/ --- 33,37 ----- + ** 6.1b9 25-May-1994 Charles Bailey bailey@genetics.upenn.edu + ** - add dummy flk param to do_oitem calls **-- **/ ************** *** 772,778 char inpline[512],*cp, *cp1; fp = do_oitem(&newsitm,"r",newsgrp.grp_name,0, ! (newsgrp.grp_flags & NEWS_M_RESTRICT_SET)); if (fp != 0) { while (fgets(inpline,512,fp)) { if (*inpline == '\n') break; --- 774,780 ----- char inpline[512],*cp, *cp1; fp = do_oitem(&newsitm,"r",newsgrp.grp_name,0, ! (newsgrp.grp_flags & NEWS_M_RESTRICT_SET),0); if (fp != 0) { while (fgets(inpline,512,fp)) { if (*inpline == '\n') break; *** newsextern.h --- newsextern_new.h ************** *** 1084,1091 EXTERN void do_new_group __ARGS((char *, int, unsigned int *)); EXTERN void create_newsgroups __ARGS((char *, unsigned int *)); EXTERN void load_newsgroups __ARGS((char *, unsigned int *)); ! EXTERN FILE *do_openi __ARGS((char *, char *, int)); ! EXTERN FILE *do_oitem __ARGS((ITM *, char *, char *, char *, int)); EXTERN unsigned int do_new_item __ARGS((unsigned int *, char *, char *, char *, char *, int, int, int, int)); EXTERN void do_new_mem_grp __ARGS((void)); EXTERN char *gendate __ARGS((unsigned int)); --- 1084,1091 ----- EXTERN void do_new_group __ARGS((char *, int, unsigned int *)); EXTERN void create_newsgroups __ARGS((char *, unsigned int *)); EXTERN void load_newsgroups __ARGS((char *, unsigned int *)); ! EXTERN FILE *do_openi __ARGS((char *, char *, int, int *)); ! EXTERN FILE *do_oitem __ARGS((ITM *, char *, char *, char *, int, int *)); EXTERN unsigned int do_new_item __ARGS((unsigned int *, char *, char *, char *, char *, int, int, int, int)); EXTERN void do_new_mem_grp __ARGS((void)); EXTERN char *gendate __ARGS((unsigned int)); *** patchlist.h;-1 --- patchlist.h ************** *** 1,1 =+=+= End =+=+= --- 1,2 ----- + 940526_newsskim.c!bailey@genetics.upenn.edu =+=+= End =+=+=