From:	SMTP%"saul@hnrc.tufts.edu" 15-JUN-1994 10:14:21.99
To:	EVERHART
CC:	
Subj:	RMS Performance Patch

Message-Id: <9406142356.AA10080@uu7.psi.com>
Date:         Tue, 14 Jun 1994 10:20:27 -0500
Reply-To: "Saul Tannenbaum (Saul Tannenbaum)" <saul@hnrc.tufts.edu>
Sender: ANU-NEWS Discussion <ANU-NEWS@VM1.NoDak.EDU>
From: "Saul Tannenbaum (Saul Tannenbaum)" <saul@hnrc.tufts.edu>
Organization: USDA HNRC at Tufts University
Subject:      RMS Performance Patch
To: Multiple recipients of list ANU-NEWS <ANU-NEWS@VM1.NoDak.EDU>

Below, in VMS_SHARE format, you'll find a set of patches that address
some of the RMS performance issues in News.

The goal of these patches are two-fold:

1) To increase the performance of out-of-the-box News by using reasonable
defaults for RMS parameters, turning on RMS performance features such as
read-ahead and write-behind, and to take other actions, such as pre-extending
files where their length can be estimated, that speed processing.

2) To provide hooks to tune RMS performance on the indexed files that are
a News bottleneck.

The end result of this patch should be to speed ADD and SKIM times.

This patch supersedes the so-called "Fast Skim" patch that is distributed
with News and addresses concerns about the safety and reliability of that
patch.

The changes include:

        NEWSADD:
                Open the input batch file with multibuffer and read-ahead
                For creating articles, estimate the article size, pre-extend
                        the file, and write it with multiblocking,
                        multibuffering and write behind
        NEWSRTL
                Modify file_copy to allocate a dynamically sized buffer
                        up to 63 blocks (file_copy is used for propagating
                        crossposted articles)
        NNTP_SERVER
        NEWSFILES
                Changed controlling logical names to the NEWS_ format
                Established run time control over buffercount, cathedral
                        windows, deferred write, and global buffercount
                        of the items and group files via logical names
                Modified RMS support routines to use read ahead and write
                        behind
                Open the newsrc file with read ahead
        NEWSDELETE
                Changed controlling logical names to the NEWS_ format
                Established run time control over buffercount, cathedral
                        windows, deferred write, and global buffercount
                        of the history file


The following logical names are used to control RMS indexed file performance:

  NEWS_GROUPFILE_BUFFERCOUNT
  NEWS_ITEMFILE_BUFFERCOUNT
  NEWS_HISTORYFILE_BUFFERCOUNT
        Sets the number of buffers used for each file

  NEWS_GROUPFILE_GLOBAL_BUFFERCOUNT
  NEWS_ITEMFILE_GLOBAL_BUFFERCOUNT
        Set the number of global buffers used for these files. The code
        ensures that the number of global buffers used is never less
        anything defined with SET FILE. Note that in a shared filed
        environment, the first stream to connect to a file establishes
        its global buffer count.

  NEWS_GROUPFILE_RTV
  NEWS_HISTORYFILE_RTV
  NEWS_ITEMFILE_RTV
        If defined to _any_ value, turns on "cathedral windows", causes
        an entire file to be mapped into its window control block, which
        avoids window turns. Useful if these files are highly fragmented.

  NEWS_GROUPFILE_DFW
  NEWS_HISTORYFILE_DFW
  NEWS_ITEMFILE_DFW
        *** Note: Use with caution. ***
        If defined to _any_ value, turns on "deferred write." By default,
        RMS uses a very conservative buffering strategy, writing any changed
        buffer to disk immediately. Deferred write changes that behavior and
        defers the writing of a buffer until that buffer is needed for other
        blocks. Use this option ONLY if you are prepared to rebuild your
        group, item, and/or history files. If you don't know what this means,
        don't do it. The performance gains are not worth the pain of learning
        how to rebuild these files.

Be sure you understand the implication of these changes on your system.
Shared files with lots of buffers require many locks. Be sure process
quotas are set appropriately.

I'd appreciate comments and feedback. With the new /STAT option on ADD FILE,
we now have the opportunity to actually measure performance, and not just
guess at it.

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_UNPACK_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 8.3
$!   On 14-JUN-1994 09:51:59.89   By user SAUL_SY
$!
$! The VMS_SHARE software that created this archive
$!    was written by  Andy Harper, Kings College London UK
$!    -- December 1992
$!
$! Credit is due to these people for their original ideas:
$!    James Gray, Michael Bednarek
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. RMS_OPTIMIZE.PATCH;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_UNPACK_TEMP","SYS$SCRATCH:."+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if .not. f$trnlnm("SHARE_UNPACK_LOG") then $ w = "!"
$ if f$getsyi("CPU") .gt. 127 then $ goto start
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto start
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$unpack: subroutine ! P1=filename, P2=checksum, P3=attributes
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'"
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn' File skipped"
$ delete 'f'*
$ exit
$dirok:
$ x=f$search(P1)
$ if x .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped"
$ delete 'f'*
$ exit
$file_absent:
$ w "-I-UNPACK, Unpacking file ", P1
$ n=P1
$ if P3 .nes. "" then $ n=f
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='n'
PROCEDURE GetHex(s,p)LOCAL x1,x2;x1:=INDEX(t,SUBSTR(s,p,1))-1;x2:=INDEX(t,
SUBSTR(s,p+1,1))-1;RETURN 16*x1+x2;ENDPROCEDURE;
PROCEDURE SkipPartsep LOOP EXITIF MARK(NONE)=END_OF(b);EXITIF INDEX(ERASE_LINE,
"-+-+-+-+-+-+-+-+")=1;ENDLOOP;ENDPROCEDURE;PROCEDURE ProcessLine LOCAL c,s,l,b,
n,p;c := ERASE_CHARACTER(1);s := ERASE_LINE;IF c = "X" THEN SPLIT_LINE; ENDIF;
MOVE_HORIZONTAL(-1);l := LENGTH(s);p := 1;LOOP EXITIF p > l;c := SUBSTR(s,p,1);
p := p+1;CASE c FROM ' ' TO '`' ['&']: b:=GetHex(s,p); n:=GetHex(s,p+2); p:=
p+4; COPY_TEXT(ASCII(n)*b);['`']: COPY_TEXT(ASCII(GetHex(s,p))); p:=p+2;[' ']
: p:=p+1;[INRANGE,OUTRANGE]: COPY_TEXT(c);ENDCASE;ENDLOOP;ENDPROCEDURE;
PROCEDURE Decode POSITION(BEGINNING_OF(b));LOOP EXITIF MARK(NONE)=END_OF(b);
IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+-")=1 THEN SkipPartSep;ELSE ProcessLine;
MOVE_HORIZONTAL(1);ENDIF;ENDLOOP;ENDPROCEDURE;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);t:="0123456789ABCDEF";f:=GET_INFO(
COMMAND_LINE,"file_name");b:=CREATE_BUFFER(f,f);Decode;WRITE_FILE(b,GET_INFO(
COMMAND_LINE,"output_file"));QUIT;
$ if p3 .eqs. "" then $ goto dl
$ open/write fdl &f
$ write fdl "RECORD"
$ write fdl P3
$ close fdl
$ w "-I-CONVRFM, Converting record format to ", P3
$ convert/fdl=&f &f-1 &P1
$dl: delete 'f'*
$ checksum 'P1'
$ if checksum$checksum .nes. P2 then $ -
  e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ exit
$ endsubroutine
$start:
$!
$ create 'f'
X***`20newsadd.c;2
X---`20newsadd.c;
X&0E2A
X***`201074,1080
X&0220`7D
X&0220`0C
X&0220/*
X!&0220*&0220out_body
X&0320*
X&0320*&0220Write`20the`20body`20of`20an`20article`20out`20to`20a`20file
X&0320*/
X---`201074,1080`20-----
X&0220`7D
X&0220`0C
X&0220/*
X!&0220*&0220length_header
X&0320*
X&0320*&0220Calculates`20approximate`20length`20of`20all`20header`20lines`20of
V`20an`20article.
X&0320*`09Modeled`20in`20out_header`20above`20ST`206/6/94
X&0E2A
X***`201076,1081
X&0220/*
X&0320*&0220out_body
X&0320*
X&0320*&0220Write`20the`20body`20of`20an`20article`20out`20to`20a`20file
X&0320*/
X&0220
X---`201076,1103`20-----
X&0220/*
X&0320*&0220length_header
X&0320*
X+&0220*&0220Calculates`20approximate`20length`20of`20all`20header`20lines`20of
V`20an`20article.
X+&0220*`09Modeled`20in`20out_header`20above`20ST`206/6/94
X+&0220*/
X+`20
X+`20int`20length_header()
X+`20`7B
X+&0320int`20i;
X+&0320int`20total_length`20=`2060;`20/*`20estimated`20size`20of`20a`20"relay"
V`20header`20*/
X+`20
X+&0320for`20(i`20=`200;`20i`20<`20OHEADERS;`20++i)`20`7B
X+&0720total_length`20=`20total_length`20+`20HDR_TEXT_L(i);
X+&0720`7D
X+&0320/*`20append`20all`20the`20remaining`20header`20lines,`20unrecognized`20b
Vy`20ANU-NEWS`20*/
X+&0320for`20(i`20=`200;`20i`20<`20itm_unk_l;`20++i)`20`7B
X+&0520total_length`20=`20total_length`20+`20UNK_HDR_TEXT_L(i);
X+&0520`7D
X+&0520return(total_length);
X+`20`7D
X+`20`0C
X+`20/*
X+&0220*&0220out_body
X+&0220*
X&0320*&0220Write`20the`20body`20of`20an`20article`20out`20to`20a`20file
X&0320*/
X&0220
X&0E2A
X***`201097,1103
X&0220`7D
X&0220`0C
X&0220/*
X!&0220*&0220create_article
X&0320*
X&0320*&0220Create`20an`20article`20file`20from`20the`20headers`20and`20body
V`20stored`20in`20memory
X&0320*
X---`201119,1125`20-----
X&0220`7D
X&0220`0C
X&0220/*
X!&0220*&0220length_body
X&0320*
X&0320*&0220Estimate`20the`20length`20of`20the`20body`20of`20an`20article`20and
V`20return`20it
X&0320*&0220ST`206/5/94
X&0E2A
X***`201099,1104
X&0220/*
X&0320*&0220create_article
X&0320*
X&0320*&0220Create`20an`20article`20file`20from`20the`20headers`20and`20body
V`20stored`20in`20memory
X&0320*
X&0320*&0220return`20NULL`20on`20error,`20otherwise`20return`20ptr`20to`20filen
Vame
X---`201121,1147`20-----
X&0220/*
X&0320*&0220length_body
X&0320*
X+&0220*&0220Estimate`20the`20length`20of`20the`20body`20of`20an`20article`20an
Vd`20return`20it
X+&0220*&0220ST`206/5/94
X+&0220*/
X+`20
X+`20int`20length_body()
X+`20`7B
X+&0320if`20(!fpt)
X+&0520`7B
X+&0520return(artbuf_l);
X+&0520`7D
X+&0320else`20`7B
X+&0320stat_t`20statb;
X+&0520fstat`20(fileno`20(fpt),`20`26statb);
X+&0520return(statb.st_size);
X+&0520`7D
X+&0320return(0);
X+`20`7D
X+`20`0C
X+`20/*
X+&0220*&0220create_article
X+&0220*
X&0320*&0220Create`20an`20article`20file`20from`20the`20headers`20and`20body
V`20stored`20in`20memory
X&0320*
X&0320*&0220return`20NULL`20on`20error,`20otherwise`20return`20ptr`20to`20filen
Vame
X&0E2A
X***`201111,1116
X&0320*&0220in`20memory).&0220The`20second`20parameter`20is`20xref,`20which`20i
Vs`20a`20pointer`20to`20the
X&0320*&0220xref`20header`20string`20if`20needed.&0220This`20is`20the`20one`20h
Veader`20line`20that`20is`20not
X&0320*&0220output`20by`20out_header.
X&0320*/
X&0220
X&0220char`20*create_article(fn,xref)
X---`201154,1163`20-----
X&0320*&0220in`20memory).&0220The`20second`20parameter`20is`20xref,`20which`20i
Vs`20a`20pointer`20to`20the
X&0320*&0220xref`20header`20string`20if`20needed.&0220This`20is`20the`20one`20h
Veader`20line`20that`20is`20not
X&0320*&0220output`20by`20out_header.
X+&0220*
X+&0220*&0320modified`20by`20saul@hnrc.tufts.edu`20to`20estimated`20article`20s
Vize`20and
X+&0220*`09pre-extend`20the`20article`20file`20and`20open`20it`20with`20multibl
Vocking,
X+&0220*`09multibuffering,`20and`20write`20behind.
X&0320*/
X&0220
X&0220char`20*create_article(fn,xref)
X&0E2A
X***`201118,1124
X&0420char`20*xref;&0309/*`20xref`20header`20line`20for`20article`20or`20NULL
V`20*/
X&0220`7B
X&0420FILE`20*fpw;
X!`20
X&0420if`20(!fn)`20fn`20=`20scratchfilename;
X&0420sysprv();
X&0420if`20(!(fpw`20=`20fopen(fn,"w","mbc=20")))`20`7B
X---`201165,1176`20-----
X&0420char`20*xref;&0309/*`20xref`20header`20line`20for`20article`20or`20NULL
V`20*/
X&0220`7B
X&0420FILE`20*fpw;
X!&0320int`20estimated_length`20=`200;
X!`20&0409/*`20calculated`20the`20estimated`20length`20of`20the
X!`20&0409&0320article`20and`20prextend`20the`20file`20*/
X!&0320char`20alloc_size`5B32`5D;
X!&0320estimated_length`20=`20length_header()`20+`20length_body();
X!&0320sprintf`20(alloc_size,`20"alq=%d",`20((estimated_length+511)/512));
X&0420if`20(!fn)`20fn`20=`20scratchfilename;
X&0420sysprv();
X&0420if`20(!(fpw`20=`20fopen`20(fn,"w",alloc_size,`20"mbc=16","mbf=2","rop=wbh
V",
X&0E2A
X***`201121,1127
X&0220
X&0420if`20(!fn)`20fn`20=`20scratchfilename;
X&0420sysprv();
X!&0320if`20(!(fpw`20=`20fopen(fn,"w","mbc=20")))`20`7B
X&0620nosysprv();
X&0620del_after`20=`200;
X&0620if`20(!try_to_quietly_handle_errors)`20_ck_open_w(fpw,fn);
X---`201173,1180`20-----
X&0420sprintf`20(alloc_size,`20"alq=%d",`20((estimated_length+511)/512));
X&0420if`20(!fn)`20fn`20=`20scratchfilename;
X&0420sysprv();
X!&0320if`20(!(fpw`20=`20fopen`20(fn,"w",alloc_size,`20"mbc=16","mbf=2","rop=wb
Vh",
X!`20&0309&0420"deq=16","fop=cbt,tef")))`20`7B
X&0620nosysprv();
X&0620del_after`20=`200;
X&0620if`20(!try_to_quietly_handle_errors)`20_ck_open_w(fpw,fn);
X&0E2A
X***`201441,1447
X&0220#if`20ADDFILE_STATISTICS_ENABLE
X&0620stat_artbuf_too_small++;
X&0220#endif
X!&0520if`20(!(fpt`20=`20fopen(bigitem_scratchfilename,"w+",`20"mbc=32")))`20
V`7B
X&0820temp_file_error`20=`201;`20del_after`20=`200;
X&0820if`20(!try_to_quietly_handle_errors)`20_ck_open_w(fpt,bigitem_scratchfile
Vname);
X&0820print_log("ERROR`20(Cannot`20open`20scratch`20file`20%s)",`20bigitem_scra
Vtchfilename,`200);
X---`201494,1501`20-----
X&0220#if`20ADDFILE_STATISTICS_ENABLE
X&0620stat_artbuf_too_small++;
X&0220#endif
X!&0520if`20(!(fpt`20=`20fopen(bigitem_scratchfilename,"w+",`20"mbc=32",
X!`20&0609&0420"mbf=2","rop=wbh")))`20`7B
X&0820temp_file_error`20=`201;`20del_after`20=`200;
X&0820if`20(!try_to_quietly_handle_errors)`20_ck_open_w(fpt,bigitem_scratchfile
Vname);
X&0820print_log("ERROR`20(Cannot`20open`20scratch`20file`20%s)",`20bigitem_scra
Vtchfilename,`200);
X&0E2A
X***`201712,1718
X&0320/*`20printf("`5CtError:`20Add`20-`20`5Cn");`20*/
X&0620return(0);
X&0620`7D
X!&0320if`20(!(fpr`20=`20fopen(fnam,"r","mbc=120")))`20`7B
X&0620if`20(!try_to_quietly_handle_errors)`20_ck_open_r(fpr,fnam);
X&0620print_log("ERROR`20(Cannot`20read`20%s)",`20fnam,`200);
X&0320/*`20printf("`5CtError:`20Add`20-`20Cannot`20read`20%s`5Cn",fnam);`20*/
X---`201766,1772`20-----
X&0320/*`20printf("`5CtError:`20Add`20-`20`5Cn");`20*/
X&0620return(0);
X&0620`7D
X!&0320if`20(!(fpr`20=`20fopen(fnam,"r","mbc=64","mbf=2","rop=rah")))`20`7B
X&0620if`20(!try_to_quietly_handle_errors)`20_ck_open_r(fpr,fnam);
X&0620print_log("ERROR`20(Cannot`20read`20%s)",`20fnam,`200);
X&0320/*`20printf("`5CtError:`20Add`20-`20Cannot`20read`20%s`5Cn",fnam);`20*/
X***`20newsdelete.c;2
X---`20newsdelete.c;
X&0E2A
X***`2032,37
X&0220**&0620itself`20as`20SMG`20failures`20during`20DELETE`20ITEM`20in`20'nosc
Vreen'`20mode)
X&0220**&03206.1b9&022025-May-1994&0220Charles`20Bailey&0220bailey@genetics.upe
Vnn.edu
X&0220**&0420-`20add`20dummy`20flk`20param`20to`20do_oitem`20calls
X&0220**--
X&0220**/
X&0220`0C
X---`2032,39`20-----
X&0220**&0620itself`20as`20SMG`20failures`20during`20DELETE`20ITEM`20in`20'nosc
Vreen'`20mode)
X&0220**&03206.1b9&022025-May-1994&0220Charles`20Bailey&0220bailey@genetics.upe
Vnn.edu
X&0220**&0420-`20add`20dummy`20flk`20param`20to`20do_oitem`20calls
X+`20**&03206.1b9&03206-Jun-1994`20Sault`20Tannenbaum`20saul@hnrc.tufts.edu
X+`20**&0420-`20add`20rms`20tuning`20hooks
X&0220**--
X&0220**/
X&0220`0C
X&0E2A
X***`20158,163
X&0220open_hist_file()
X&0220`7B
X&0420FILE`20*fpw;
X&0220
X&0420if`20(nntp_client)`20return(0);
X&0420if`20(hist_off)`20return(0);
X---`20160,169`20-----
X&0220open_hist_file()
X&0220`7B
X&0420FILE`20*fpw;
X+`20/*`20ST`203/2/93`20-`20RMS`20Performance`20Options`20for`20History`20file
V`20access`20*/
X+&0320int`20buff_count=0;
X+&0320char`20*buff_count_ptr;
X+&0320int`20hist_performance`20=`20FALSE;
X&0220
X&0220
X&0420if`20(nntp_client)`20return(0);
X&0E2A
X***`20159,164
X&0220`7B
X&0420FILE`20*fpw;
X&0220
X&0420if`20(nntp_client)`20return(0);
X&0420if`20(hist_off)`20return(0);
X&0420sysprv();
X---`20165,171`20-----
X&0420char`20*buff_count_ptr;
X&0420int`20hist_performance`20=`20FALSE;
X&0220
X+`20
X&0420if`20(nntp_client)`20return(0);
X&0420if`20(hist_off)`20return(0);
X&0420sysprv();
X&0E2A
X***`20178,183
X&0420histfab.fab$b_fns`20=`20strlen(histfab.fab$l_fna);
X&0420histfab.fab$b_shr`20=`20FAB$M_SHRDEL`20`7C`20FAB$M_SHRGET`20`7C`20FAB$M_S
VHRPUT`20`7C`20FAB$M_SHRUPD;
X&0220
X&0420if`20(!sys_open_nofnf(`26histfab))`20`7B
X&0620histfab.fab$b_bks`20=`204;
X&0620histfab.fab$l_fop`20=`20FAB$M_CIF;
X---`20185,202`20-----
X&0420histfab.fab$b_fns`20=`20strlen(histfab.fab$l_fna);
X&0420histfab.fab$b_shr`20=`20FAB$M_SHRDEL`20`7C`20FAB$M_SHRGET`20`7C`20FAB$M_S
VHRPUT`20`7C`20FAB$M_SHRUPD;
X&0220
X+`20/*`20ST`203/2/93`20RMS`20Performance`20Patches`20*/
X+&0320buff_count_ptr`20=`20news_getenv("NEWS_HISTORYFILE_BUFFERCOUNT",0);
X+&0320if`20(buff_count_ptr`20!=`20NULL)
X+`20`09`7B
X+`20`09`20sscanf(buff_count_ptr,"%d",`26buff_count);
X+`20`09`20hist_performance`20=`20TRUE;
X+`20`09`7D
X+`20
X+&0320if`20(news_getenv("NEWS_HISTORYFILE_DFW",0)`20!=`200)
X+`20&0209`20histfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write`20*/
V
X+&0320if`20(news_getenv("NEWS_HISTORYFILE_RTV",0)`20!=`200)
X+`20&0209`20histfab.fab$b_rtv`20=`20255;`09/*`20map`20the`20entire`20file`20*/
V
X&0420if`20(!sys_open_nofnf(`26histfab))`20`7B
X&0620histfab.fab$b_bks`20=`204;
X&0620histfab.fab$l_fop`20=`20FAB$M_CIF;
X&0E2A
X***`20216,221
X&0420histrab.rab$l_rbf`20=`20(char`20*)`20`26newshist;
X&0420histrab.rab$w_rsz`20=`20sizeof`20newshist;
X&0220
X&0420if`20(!sys_connect(`26histrab))`20`7B
X&0620sys_close(`26histfab);
X&0620nosysprv();
X---`20235,247`20-----
X&0420histrab.rab$l_rbf`20=`20(char`20*)`20`26newshist;
X&0420histrab.rab$w_rsz`20=`20sizeof`20newshist;
X&0220
X+`20/*`20ST`203/2/93`20RMS`20Performance`20Patches`20*/
X+&0520if`20(hist_performance)`20
X+`20`09histrab.rab$b_mbf`20=`20(buff_count`20<=`20127)`20?`20buff_count`20:
V`20127;
X+`20
X+&0520if`20(news_getenv("NEWS_HISTORYFILE_FASTDELETE",0)`20!=`200)
X+`20`09histrab.rab$l_rop`20`7C=`20RAB$M_FDL;
X+`20`09
X&0420if`20(!sys_connect(`26histrab))`20`7B
X&0620sys_close(`26histfab);
X&0620nosysprv();
X***`20newsfiles.c;2
X---`20newsfiles.c;5
X&0E2A
X***`2049,54
X&0220**`09V6.1b8&022012-Apr-1994&0220mark.martinec@ijs.si
X&0220**`09&0320-`20rms_open()`20and`20rms_create`20receive`20an`20extra`20argu
Vment
X&0220**`09&0520to`20disable`20some`20(more`20common)`20cases`20of`20signalling
V`20errors
X&0220**--
X&0220*/
X&0220`0C
X---`2049,59`20-----
X&0220**`09V6.1b8&022012-Apr-1994&0220mark.martinec@ijs.si
X&0220**`09&0320-`20rms_open()`20and`20rms_create`20receive`20an`20extra`20argu
Vment
X&0220**`09&0520to`20disable`20some`20(more`20common)`20cases`20of`20signalling
V`20errors
X+`20**`09V6.1b9&02206-jun-1994`20saul@hnrc.tufts.edu
X+`20**`09&0320-`20modifications`20to`20some`20of`20my`20rms`20performance`20pa
Vtches:
X+`20**&0209separate`20out`20potentially`20dangerous`20deferred`20write
X+`20**&0209add`20latent`20support`20for`20"fast`20delete"`20on`20item`20file
X+`20**&0209change`20logical`20names`20to`20conform`20to`20NEWS_`20standard
X&0220**--
X&0220*/
X&0220`0C
X&0E2A
X***`20234,239
X&0220void`20openfiles(nntp_sts)
X&0420int`20nntp_sts;
X&0220`7B
X&0420char`20*in_line`20=`200,`20*gotenv,`20*cp,`20tmp`5B256`5D;
X&0220
X&0420if`20(newsrc)`20fseek(newsrc,0,0);
X---`20239,245`20-----
X&0220void`20openfiles(nntp_sts)
X&0420int`20nntp_sts;
X&0220`7B
X+`20#define`20REG_OPEN_OPT`20"mbc=32","mbf=2","rop=rah"
X&0420char`20*in_line`20=`200,`20*gotenv,`20*cp,`20tmp`5B256`5D;
X&0220
X&0420if`20(newsrc)`20fseek(newsrc,0,0);
X&0E2A
X***`20237,243
X&0420char`20*in_line`20=`200,`20*gotenv,`20*cp,`20tmp`5B256`5D;
X&0220
X&0420if`20(newsrc)`20fseek(newsrc,0,0);
X!&0320else`20newsrc`20=`20fopen(news_register,"r","mbc=40");
X&0220
X&0420if`20(&0320newsrc
X&0820&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X---`20243,249`20-----
X&0420char`20*in_line`20=`200,`20*gotenv,`20*cp,`20tmp`5B256`5D;
X&0220
X&0420if`20(newsrc)`20fseek(newsrc,0,0);
X!&0320else`20newsrc`20=`20fopen(news_register,"r",REG_OPEN_OPT);
X&0220
X&0420if`20(&0320newsrc
X&0820&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X&0E2A
X***`20249,255
X&0820nntp_client`20=`200;
X&0820fclose(newsrc);`20newsrc`20=`200;
X&0820strcpy(news_register,"SYS$LOGIN:NEWSRC");
X!&0720if`20(&0320(newsrc`20=`20fopen(news_register,"r","mbc=40"))`20!=`200
X&0220`09&0220&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X&0220`09&0220&0226`20*in_line`20==`20'`7E')`20`7B
X&0A20fclose(newsrc);`20newsrc`20=`200;
X---`20255,261`20-----
X&0820nntp_client`20=`200;
X&0820fclose(newsrc);`20newsrc`20=`200;
X&0820strcpy(news_register,"SYS$LOGIN:NEWSRC");
X!&0720if`20(&0320(newsrc`20=`20fopen(news_register,"r",REG_OPEN_OPT))`20!=`200
V
X&0220`09&0220&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X&0220`09&0220&0226`20*in_line`20==`20'`7E')`20`7B
X&0A20fclose(newsrc);`20newsrc`20=`200;
X&0E2A
X***`20267,273
X&0220`09&0220sprintf(news_register,"SYS$LOGIN:NEWSRC#%s",nntp_node);
X&0220`09&0220while`20((cp`20=`20strchr(news_register,'.'))`20!=`200)`20*cp`20=
V`20'-';
X&0220`09&0220if`20((cp`20=`20strchr(news_register,'#'))`20!=`200)`20*cp`20=
V`20'.';
X!&0B20if`20(&0320(newsrc`20=`20fopen(news_register,"r","mbc=40"))`20!=`200
X&0220`09&0620&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X&0220`09&0620&0226`20*in_line`20==`20'`7E'`20&0226`20(cp`20=`20strchr(in_line+
V1,'`7E'))`20!=`200)`20`7B
X&0E20*cp--`20=`20'`5C0';
X---`20273,279`20-----
X&0220`09&0220sprintf(news_register,"SYS$LOGIN:NEWSRC#%s",nntp_node);
X&0220`09&0220while`20((cp`20=`20strchr(news_register,'.'))`20!=`200)`20*cp`20=
V`20'-';
X&0220`09&0220if`20((cp`20=`20strchr(news_register,'#'))`20!=`200)`20*cp`20=
V`20'.';
X!&0B20if`20(&0320(newsrc`20=`20fopen(news_register,"r",REG_OPEN_OPT))`20!=`200
V
X&0220`09&0620&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X&0220`09&0620&0226`20*in_line`20==`20'`7E'`20&0226`20(cp`20=`20strchr(in_line+
V1,'`7E'))`20!=`200)`20`7B
X&0E20*cp--`20=`20'`5C0';
X&0E2A
X***`20297,303
X&0620sprintf(news_register,"SYS$LOGIN:NEWSRC#%s",nntp_node);
X&0620while`20((cp`20=`20strchr(news_register,'.'))`20!=`200)`20*cp`20=`20'-';
X&0620if`20((cp`20=`20strchr(news_register,'#'))`20!=`200)`20*cp`20=`20'.';
X!&0520if`20(&0320(nntp_sts`20<`203)`20&0226`20(newsrc`20=`20fopen(news_registe
Vr,"r","mbc=40"))`20!=`200
X&0220`09&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X&0220`09&0226`20*in_line`20==`20'`7E'`20&0226`20(cp`20=`20strchr(in_line+1,'
V`7E'))`20!=`200)`20`7B
X&0820*cp--`20=`20'`5C0';
X---`20303,310`20-----
X&0620sprintf(news_register,"SYS$LOGIN:NEWSRC#%s",nntp_node);
X&0620while`20((cp`20=`20strchr(news_register,'.'))`20!=`200)`20*cp`20=`20'-';
X&0620if`20((cp`20=`20strchr(news_register,'#'))`20!=`200)`20*cp`20=`20'.';
X!&0520if`20(&0320(nntp_sts`20<`203)`20&0226`20(newsrc`20=`20fopen(news_registe
Vr,"r",REG_OPEN_OPT))`20
X!`20&0909&0420!=`200
X&0220`09&0226`20(in_line`20=`20fgetl(newsrc))`20!=`200
X&0220`09&0226`20*in_line`20==`20'`7E'`20&0226`20(cp`20=`20strchr(in_line+1,'
V`7E'))`20!=`200)`20`7B
X&0820*cp--`20=`20'`5C0';
X&0E2A
X***`20379,385
X&0220`09int`20buff_count=0;
X&0220`09char`20*buff_count_ptr;
X&0220`09int`20item_performance`20=`20FALSE;
X!`20`09buff_count_ptr`20=`20news_getenv("ANU_NEWS_ITEMFILE_BUFFERCOUNT",0);
X&0220`09if`20(buff_count_ptr`20!=`20NULL)
X&0220`09`7B
X&0220`09&0420sscanf(buff_count_ptr,"%d",`26buff_count);
X---`20386,392`20-----
X&0220`09int`20buff_count=0;
X&0220`09char`20*buff_count_ptr;
X&0220`09int`20item_performance`20=`20FALSE;
X!`20`09buff_count_ptr`20=`20news_getenv("NEWS_ITEMFILE_BUFFERCOUNT",0);
X&0220`09if`20(buff_count_ptr`20!=`20NULL)
X&0220`09`7B
X&0220`09&0420sscanf(buff_count_ptr,"%d",`26buff_count);
X&0E2A
X***`20395,405
X&0620itmfab.fab$b_fns`20=`20strlen(itmfab.fab$l_fna);
X&0620itmfab.fab$l_fop`20=`20FAB$M_CIF;
X&0220
X!`20`09/*`20ST`202/2/93`20if`20the`20buffer`20count`20logical`20was`20defined,
V`20turn`20on`20
X!`20`09&0420a`20number`20of`20RMS`20performance`20features`20*/
X!&0520if`20(item_performance)`20
X!&0520`7B
X!`20`09itmfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write`20*/
X&0220`09itmfab.fab$b_rtv`20=`20255;`09&0720/*`20map`20the`20entire`20file`20*/
V
X&0620`7D`09
X&0620itmfab.fab$w_mrs`20=`20sizeof`20newsitm;
X---`20402,410`20-----
X&0620itmfab.fab$b_fns`20=`20strlen(itmfab.fab$l_fna);
X&0620itmfab.fab$l_fop`20=`20FAB$M_CIF;
X&0220
X!&0520if`20(news_getenv("NEWS_ITEMFILE_DFW",0)`20!=`200)
X!`20`09&0420`09itmfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write
V`20*/
X!&0520if`20(news_getenv("NEWS_ITEMFILE_RTV",0)`20!=`200)
X&0220`09itmfab.fab$b_rtv`20=`20255;`09&0720/*`20map`20the`20entire`20file`20*/
V
X&0220
X&0620itmfab.fab$w_mrs`20=`20sizeof`20newsitm;
X&0E2A
X***`20401,407
X&0620`7B
X&0220`09itmfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write`20*/
X&0220`09itmfab.fab$b_rtv`20=`20255;`09&0720/*`20map`20the`20entire`20file`20*/
V
X!&0520`7D`09
X&0620itmfab.fab$w_mrs`20=`20sizeof`20newsitm;
X&0620itmfab.fab$b_org`20=`20FAB$C_IDX;
X&0620itmfab.fab$b_rat`20=`20FAB$M_CR;
X---`20406,412`20-----
X&0220`09&0420`09itmfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write
V`20*/
X&0620if`20(news_getenv("NEWS_ITEMFILE_RTV",0)`20!=`200)
X&0220`09itmfab.fab$b_rtv`20=`20255;`09&0720/*`20map`20the`20entire`20file`20*/
V
X!`20
X&0620itmfab.fab$w_mrs`20=`20sizeof`20newsitm;
X&0620itmfab.fab$b_org`20=`20FAB$C_IDX;
X&0620itmfab.fab$b_rat`20=`20FAB$M_CR;
X&0E2A
X***`20443,448
X&0620if`20(item_performance)`20
X&0220`09itmrab.rab$b_mbf`20=`20(buff_count`20<=`20127)`20?`20buff_count`20:
V`20127;
X&0220
X&0620sysprv();
X&0620if`20(!sys_open_nofnf(`26itmfab))`20`7B
X&0220#ifndef`20V58_UPGRADE_MANUAL
X---`20448,456`20-----
X&0620if`20(item_performance)`20
X&0220`09itmrab.rab$b_mbf`20=`20(buff_count`20<=`20127)`20?`20buff_count`20:
V`20127;
X&0220
X+&0520if`20(news_getenv("NEWS_ITEMFILE_FASTDELETE",0)`20!=`200)
X+`20`09itmrab.rab$l_rop`20`7C=`20RAB$M_FDL;
X+`20
X&0620sysprv();
X&0620if`20(!sys_open_nofnf(`26itmfab))`20`7B
X&0220#ifndef`20V58_UPGRADE_MANUAL
X&0E2A
X***`20471,476
X&0820first_time();
X&0820printf("`5CtNEWS`20-`20create`20new`20ITEM`20file`5Cn");
X&0820`7D
X&0620sys_connect(`26itmrab);
X&0620`7B`20int`20old_itmrop`20=`20itmrab.rab$l_rop;
X&0820itmrab.rab$l_rop`20`7C=`20RAB$M_RRL`20`7C`20RAB$M_NLK;
X---`20479,499`20-----
X&0820first_time();
X&0820printf("`5CtNEWS`20-`20create`20new`20ITEM`20file`5Cn");
X&0820`7D
X+`20/*`206/7/94`20-`20saul@hnrc.tufts.edu`20add`20global`20buffer`20handling
V`20*/
X+&0720`7B
X+`20`09int`20buff_count=0;
X+`20`09char`20*buff_count_ptr;
X+`20`09buff_count_ptr`20=`20news_getenv("NEWS_ITEMFILE_GLOBAL_BUFFERCOUNT",0);
V
X+`20`09if`20(buff_count_ptr`20!=`20NULL)
X+`20`09`7B
X+`20`09&0420sscanf(buff_count_ptr,"%d",`26buff_count);
X+`20
X+`20/*`20the`20file's`20global`20buffer`20count`20gets`20loaded`20on`20open
V`20by`20RMS,`20use`20the
X+&0520maximum`20of`20the`20stored`20value`20and`20the`20logical`20defined`20va
Vlue`20*/
X+`20
X+`20`09&0420if`20(itmfab.fab$w_gbc`20<`20buff_count)`20itmfab.fab$w_gbc`20=
V`20buff_count;
X+`20`09`7D
X+&0520`7D
X&0620sys_connect(`26itmrab);
X&0620`7B`20int`20old_itmrop`20=`20itmrab.rab$l_rop;
X&0820itmrab.rab$l_rop`20`7C=`20RAB$M_RRL`20`7C`20RAB$M_NLK;
X&0E2A
X***`20499,505
X&0220`09int`20buff_count=0;
X&0220`09char`20*buff_count_ptr;
X&0220`09int`20group_performance`20=`20FALSE;
X!`20`09buff_count_ptr`20=`20news_getenv("ANU_NEWS_GROUPFILE_BUFFERCOUNT",0);
X&0220`09if`20(buff_count_ptr`20!=`20NULL)
X&0220`09`7B
X&0220`09&0420sscanf(buff_count_ptr,"%d",`26buff_count);
X---`20522,528`20-----
X&0220`09int`20buff_count=0;
X&0220`09char`20*buff_count_ptr;
X&0220`09int`20group_performance`20=`20FALSE;
X!`20`09buff_count_ptr`20=`20news_getenv("NEWS_GROUPFILE_BUFFERCOUNT",0);
X&0220`09if`20(buff_count_ptr`20!=`20NULL)
X&0220`09`7B
X&0220`09&0420sscanf(buff_count_ptr,"%d",`26buff_count);
X&0E2A
X***`20513,525
X&0620grpfab.fab$b_fns`20=`20strlen(grpfab.fab$l_fna);
X&0620grpfab.fab$l_fop`20=`20FAB$M_CIF;
X&0220
X!`20`09/*`20ST&02203/2/93`20if`20the`20buffer`20count`20logical`20was`20define
Vd,`20turn`20on`20
X!`20`09&0420a`20number`20of`20RMS`20performance`20features`20*/
X!&0520if`20(group_performance)`20
X!&0520`7B
X!`20`09grpfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write`20*/
X!`20`09grpfab.fab$b_rtv`20=`20255;`09&0720/*`20map`20the`20entire`20file`20*/
X!&0520`7D`09
X&0620grpfab.fab$w_mrs`20=`20NEWS_GRPFIL_RSZ;
X&0620grpfab.fab$b_org`20=`20FAB$C_IDX;
X&0620grpfab.fab$b_rat`20=`20FAB$M_CR;
X---`20536,550`20-----
X&0620grpfab.fab$b_fns`20=`20strlen(grpfab.fab$l_fna);
X&0620grpfab.fab$l_fop`20=`20FAB$M_CIF;
X&0220
X!`20
X!`20/*`206/6/94`20saul@hnrc.tufts.edu`20-`20optionally`20turn`20on`20other`20p
Verformance
X!`20&0409enhancements`20*/
X!`20
X!&0520if`20(news_getenv("NEWS_GROUPFILE_DFW",0)`20!=`200)
X!`20`09&0420`09grpfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write
V`20*/
X!&0520if`20(news_getenv("NEWS_GROUPFILE_RTV",0)`20!=`200)
X!`20&0209grpfab.fab$b_rtv`20=`20255;`09&0720/*`20map`20the`20entire`20file`20*
V/
X!`20
X&0620grpfab.fab$w_mrs`20=`20NEWS_GRPFIL_RSZ;
X&0620grpfab.fab$b_org`20=`20FAB$C_IDX;
X&0620grpfab.fab$b_rat`20=`20FAB$M_CR;
X&0E2A
X***`20558,563
X&0220`09grprab.rab$b_mbf`20=`20(buff_count`20<=`20127)`20?`20buff_count`20:
V`20127;
X&0220`7D
X&0220
X&0620sysprv();
X&0620if`20(no_priv())`20sys_open(`26grpfab);
X&0620else`20sys_create(`26grpfab);
X---`20583,591`20-----
X&0220`09grprab.rab$b_mbf`20=`20(buff_count`20<=`20127)`20?`20buff_count`20:
V`20127;
X&0220`7D
X&0220
X+&0520if`20(news_getenv("NEWS_GROUPFILE_FASTDELETE",0)`20!=`200)
X+`20`09grprab.rab$l_rop`20`7C=`20RAB$M_FDL;
X+`20
X&0620sysprv();
X&0620if`20(no_priv())`20sys_open(`26grpfab);
X&0620else`20sys_create(`26grpfab);
X&0E2A
X***`20561,566
X&0620sysprv();
X&0620if`20(no_priv())`20sys_open(`26grpfab);
X&0620else`20sys_create(`26grpfab);
X&0620if`20(status`20!=`20RMS$_CREATED)
X&0820sys_connect(`26grprab);
X&0620else`20`7B
X---`20589,610`20-----
X&0620sysprv();
X&0620if`20(no_priv())`20sys_open(`26grpfab);
X&0620else`20sys_create(`26grpfab);
X+`20
X+`20/*`206/7/94`20-`20saul@hnrc.tufts.edu`20add`20global`20buffer`20handling
V`20*/
X+&0720`7B
X+`20`09int`20buff_count=0;
X+`20`09char`20*buff_count_ptr;
X+`20`09buff_count_ptr`20=`20news_getenv("NEWS_GROUPFILE_GLOBAL_BUFFERCOUNT",0)
V;
X+`20`09if`20(buff_count_ptr`20!=`20NULL)
X+`20`09`7B
X+`20`09&0420sscanf(buff_count_ptr,"%d",`26buff_count);
X+`20
X+`20/*`20the`20file's`20global`20buffer`20count`20gets`20loaded`20on`20open
V`20by`20RMS,`20use`20the
X+&0520maximum`20of`20the`20stored`20value`20and`20the`20logical`20defined`20va
Vlue`20*/
X+`20
X+`20`09&0420if`20(grpfab.fab$w_gbc`20<`20buff_count)`20grpfab.fab$w_gbc`20=
V`20buff_count;
X+`20`09`7D
X+&0520`7D
X&0620if`20(status`20!=`20RMS$_CREATED)
X&0820sys_connect(`26grprab);
X&0620else`20`7B
X***`20newsrtl.c;2
X---`20newsrtl.c;8
X&0E2A
X***`2064,70
X&0220**`09V6.1b8`09`2011-May-1994`09mark.martinec@ijs.si
X&0220**`09&0220-`20added`20macro`20news_assert_nonfatal`20and`20use`20it`20in
V`20news_free_raw()
X&0220**`09V6.1b9&04206-Jun-1994`09saul@hnrc.tufts.edu
X!`20**`09&0220-`20in`20file_copy,`20increase`20size`20of`20buffer`20to`2063
V`20blocks`20and`20pge`20align`20it
X&0220**--
X&0220**/
X&0220`0C
X---`2064,70`20-----
X&0220**`09V6.1b8`09`2011-May-1994`09mark.martinec@ijs.si
X&0220**`09&0220-`20added`20macro`20news_assert_nonfatal`20and`20use`20it`20in
V`20news_free_raw()
X&0220**`09V6.1b9&04206-Jun-1994`09saul@hnrc.tufts.edu
X!`20**`09&0220-`20in`20file_copy,`20dynamically`20allocate`20a`20buffer`20of
V`20up`20to`2063`20blocks
X&0220**--
X&0220**/
X&0220`0C
X&0E2A
X***`20905,912
X&0920*to;
X&0420int`20bypass_signalling_errors;&0220/*`20bypass`20signalling`20of`20some
X&2620of`20the`20more`20common`20errors`20*/
X!&0520/*`206/6/94`20-`20saul@hnrc.tufts.edu`20-`20Increase`20buffersize`20to
V`2063`20blocks,
X!`20&0209page`20align`20the`20buffer`20*/
X&0220`7B
X&0420struct`20FAB`20infab,
X&0F20outfab;
X---`20905,913`20-----
X&0920*to;
X&0420int`20bypass_signalling_errors;&0220/*`20bypass`20signalling`20of`20some
X&2620of`20the`20more`20common`20errors`20*/
X!&0520/*`206/6/94`20-`20saul@hnrc.tufts.edu`20-`20Dynamically`20allocate`20the
V`20buffer
X!`20&0209up`20to`2063`20blocks`20*/
X!`20`09&0420
X&0220`7B
X&0420struct`20FAB`20infab,
X&0F20outfab;
X&0E2A
X***`20921,928
X&0420struct`20XABPRO`20inxabpro,
X&1220outxabpro;
X&0420int`20status,`20ret_stat;
X-&0320char`20_align`20(PAGE)`20rec_buff`5B63*512`5D;
X-&0320short`20rec_size`20=`20sizeof(rec_buff);
X&0220
X&0420ret_stat`20=`20SS$_NORMAL;
X&0220
X---`20922,927`20-----
X&0420struct`20XABPRO`20inxabpro,
X&1220outxabpro;
X&0420int`20status,`20ret_stat;
X&0220
X&0420ret_stat`20=`20SS$_NORMAL;
X&0220
X&0E2A
X***`20946,953
X&0420inrab`20=`20cc$rms_rab;
X&0420inrab.rab$l_fab`20=`20`26infab;
X&0420inrab.rab$l_bkt`20=`200;
X-&0320inrab.rab$l_ubf`20=`20rec_buff;
X-&0320inrab.rab$w_usz`20=`20rec_size;
X&0220
X&0420if`20(!`20((status=sys$open(`26infab))`20`26`201))`20`7B
X&0620ret_stat`20=`20status;
X---`20945,950`20-----
X&0420inrab`20=`20cc$rms_rab;
X&0420inrab.rab$l_fab`20=`20`26infab;
X&0420inrab.rab$l_bkt`20=`200;
X&0220
X&0420if`20(!`20((status=sys$open(`26infab))`20`26`201))`20`7B
X&0620ret_stat`20=`20status;
X&0E2A
X***`20965,971
X&0820outfab.fab$l_fna`20=`20to;
X&0820outfab.fab$b_fns`20=`20strlen(to);
X&0820outfab.fab$l_fop`20=`20FAB$M_CBT;
X-&0720outfab.fab$w_mrs`20=`20rec_size;
X&0820outfab.fab$b_fac`20=`20FAB$M_BIO`20`7C`20FAB$M_PUT;
X&0820outfab.fab$b_rat`20=`20FAB$M_CR;
X&0820outfab.fab$l_xab`20=`20(char`20*)`20`26outxabdat;
X---`20962,967`20-----
X&0820outfab.fab$l_fna`20=`20to;
X&0820outfab.fab$b_fns`20=`20strlen(to);
X&0820outfab.fab$l_fop`20=`20FAB$M_CBT;
X&0820outfab.fab$b_fac`20=`20FAB$M_BIO`20`7C`20FAB$M_PUT;
X&0820outfab.fab$b_rat`20=`20FAB$M_CR;
X&0820outfab.fab$l_xab`20=`20(char`20*)`20`26outxabdat;
X&0E2A
X***`20984,990
X&0820outrab`20=`20cc$rms_rab;
X&0820outrab.rab$l_fab`20=`20`26outfab;
X&0820outrab.rab$l_bkt`20=`200;
X-&0720outrab.rab$l_rbf`20=`20rec_buff;
X&0220
X&0820outfab.fab$l_alq`20=`20infab.fab$l_alq;
X&0820outfab.fab$w_deq`20=`20infab.fab$w_deq;
X---`20980,985`20-----
X&0820outrab`20=`20cc$rms_rab;
X&0820outrab.rab$l_fab`20=`20`26outfab;
X&0820outrab.rab$l_bkt`20=`200;
X&0220
X&0820outfab.fab$l_alq`20=`20infab.fab$l_alq;
X&0820outfab.fab$w_deq`20=`20infab.fab$w_deq;
X&0E2A
X***`201019,1027
X&0E20report_rms_error_routine(NEWS$_CONFAIL,status,`26outrab,module_name_str,_
V_LINE__);
X&0C20`7D
X&0A20else`20`7B
X!`20`09&0220x`20=lib$get_vm_page`20(
X!&0E20`09`20`7B@number_of_pages.r@`7D,`20
X!&0E20`09`20`7B@base_address.r@`7D)
X&0C20while`20(sys_read_noeof(`26inrab))`20`7B
X&0E20outrab.rab$w_rsz`20=`20inrab.rab$w_rsz;
X&0E20if`20(!`20((status=sys$write(`26outrab))`20`26`201))`20`7B
X---`201014,1038`20-----
X&0E20report_rms_error_routine(NEWS$_CONFAIL,status,`26outrab,module_name_str,_
V_LINE__);
X&0C20`7D
X&0A20else`20`7B
X!`20`09&0220/*`20buffer`20space`20allocation`206/6/94`20saul@hnrc.tufts.edu
V`20*/
X!`20`09&0220char`20*`20buf_ptr;
X!`20`09&0220int`20buf_size,buf_page;
X!`20`09&0220char`20fall_back_buffer`5B4*512`5D;
X!`20
X!`20`09&0220/*`20set`20buffer`20size`20to`20minimum(last_block_of_input_file,
V`2063)`20*/
X!&0B20buf_page`20=`20(inxabfhc.xab$l_ebk`20<=`2063)`20?`20inxabfhc.xab$l_ebk
V`20:`2063;
X!`20
X!`20`09&0220status`20=`20lib$get_vm_page`20(`26buf_page,`20`26buf_ptr);
X!`20`09&0220buf_size`20=`20buf_page`20*`20512;
X!`20/*`20if,`20for`20any`20reason`20we`20can't`20get`20memory,`20use`20a`20bui
Vltin`20fall`20back`20buffer`20*/
X!`20`09&0220if`20(!(status`20`26`201))`20`7B
X!`20&0209&0420buf_size`20=`20sizeof(fall_back_buffer);
X!`20&0209&0420buf_ptr&0220=`20`26fall_back_buffer;
X!`20&0209&0420`7D
X!`20`09&0420inrab.rab$l_ubf`20=`20buf_ptr;
X!`20`09&0420outrab.rab$l_rbf`20=`20buf_ptr;
X!`20`09&0420inrab.rab$w_usz`20=`20buf_size;
X!`20
X&0C20while`20(sys_read_noeof(`26inrab))`20`7B
X&0E20outrab.rab$w_rsz`20=`20inrab.rab$w_rsz;
X&0E20if`20(!`20((status=sys$write(`26outrab))`20`26`201))`20`7B
X&0E2A
X***`201033,1038
X&0E20`7D
X&0C20if`20(status`20==`20RMS$_EOF)`20status`20=`20SS$_NORMAL;
X&0C20ret_stat`20=`20status;
X&0C20`7D
X&0A20sys_close(`26outfab);
X&0A20`7D
X---`201044,1054`20-----
X&0E20`7D
X&0C20if`20(status`20==`20RMS$_EOF)`20status`20=`20SS$_NORMAL;
X&0C20ret_stat`20=`20status;
X+`20`09if`20(buf_ptr`20!=`20`26fall_back_buffer)`20`7B
X+`20`09&0420lib$free_vm_page`20(
X+`20&0209`26buf_page,
X+&0D20`09`26buf_ptr);
X+`20`09&0420`7D
X&0C20`7D
X&0A20sys_close(`26outfab);
X&0A20`7D
X***`20nntp_server.c;2
X---`20nntp_server.c;4
X&0E2A
X***`20219,224
X&0220**`09V6.1b9`0924-May-1994&0220Charles`20Bailey&0220bailey@genetics.upenn.
Vedu
X&0220**`09&0220-`20added`20further`20file`20optimizations`20based`20on`20patch
V`20noted`20in
X&0220**`09&0420previous`20comment`20(930723_nntp_server.c!saul@hnrc.tufts.edu)
V.
X&0220**
X&0220**--
X&0220**/
X---`20219,225`20-----
X&0220**`09V6.1b9`0924-May-1994&0220Charles`20Bailey&0220bailey@genetics.upenn.
Vedu
X&0220**`09&0220-`20added`20further`20file`20optimizations`20based`20on`20patch
V`20noted`20in
X&0220**`09&0420previous`20comment`20(930723_nntp_server.c!saul@hnrc.tufts.edu)
V.
X+`20**`09V6.1b9&02208-jun-1994&0320RMS`20optimizations`20to`20item,`20group
V`20and`20history`20file
X&0220**
X&0220**--
X&0220**/
X&0E2A
X***`201880,1885
X&0420grprab.rab$l_ubf`20=`20grprab.rab$l_rbf`20=`20`26newsgrp;
X&0420grprab.rab$w_usz`20=`20grprab.rab$w_rsz`20=`20sizeof`20newsgrp;
X&0220
X&0420if`20(!sys_open(`26itmfab))`20return(0);
X&0420itm_file_open`20=`201;
X&0420if`20(!sys_connect(`26itmrab))`20`7B
X---`201881,1899`20-----
X&0420grprab.rab$l_ubf`20=`20grprab.rab$l_rbf`20=`20`26newsgrp;
X&0420grprab.rab$w_usz`20=`20grprab.rab$w_rsz`20=`20sizeof`20newsgrp;
X&0220
X+&0220/*`20ST`206/8/94&0220RMS`20Performance`20Patch`20*/
X+`20`7B
X+&0820int`20buff_count=0;
X+&0820char`20*buff_count_ptr;
X+&0820buff_count_ptr`20=`20news_getenv("NEWS_ITEMFILE_BUFFERCOUNT",0);
X+&0820if`20(buff_count_ptr`20!=`20NULL)&0220sscanf(buff_count_ptr,"%d",`26buff
V_count);
X+&0620if`20(news_getenv("NEWS_ITEMFILE_DFW",0)`20!=`200)
X+&1020itmfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write`20*/
X+&0620if`20(news_getenv("NEWS_ITEMFILE_RTV",0)`20!=`200)
X+&0820itmfab.fab$b_rtv`20=`20255;&0820/*`20map`20the`20entire`20file`20*/
X+&0620if`20(buff_count`20>`200)`20
X+&0820itmrab.rab$b_mbf`20=`20(buff_count`20<=`20127)`20?`20buff_count`20:`2012
V7;
X+`20`7D
X&0420if`20(!sys_open(`26itmfab))`20return(0);
X&0420itm_file_open`20=`201;
X&0220
X&0E2A
X***`201882,1887
X&0220
X&0420if`20(!sys_open(`26itmfab))`20return(0);
X&0420itm_file_open`20=`201;
X&0420if`20(!sys_connect(`26itmrab))`20`7B
X&0620sys_close(`26itmfab);`20itm_file_open`20=`200;
X&0620return(0);
X---`201896,1918`20-----
X&0220`7D
X&0420if`20(!sys_open(`26itmfab))`20return(0);
X&0420itm_file_open`20=`201;
X+`20
X+&0220/*`206/7/94`20-`20saul@hnrc.tufts.edu`20add`20global`20buffer`20handling
V`20*/
X+&0820`7B
X+&0820int`20buff_count=0;
X+&0820char`20*buff_count_ptr;
X+&0820buff_count_ptr`20=`20news_getenv("NEWS_ITEMFILE_GLOBAL_BUFFERCOUNT",0);
X+&0820if`20(buff_count_ptr`20!=`20NULL)
X+&0820`7B
X+&0C20sscanf(buff_count_ptr,"%d",`26buff_count);
X+`20
X+&0220/*`20the`20file's`20global`20buffer`20count`20gets`20loaded`20on`20open
V`20by`20RMS,`20use`20the
X+&0620maximum`20of`20the`20stored`20value`20and`20the`20logical`20defined`20va
Vlue`20*/
X+`20
X+&0C20if`20(itmfab.fab$w_gbc`20<`20buff_count)`20itmfab.fab$w_gbc`20=`20buff_c
Vount;
X+&0820`7D
X+&0620`7D
X+`20
X&0420if`20(!sys_connect(`26itmrab))`20`7B
X&0620sys_close(`26itmfab);`20itm_file_open`20=`200;
X&0620return(0);
X&0E2A
X***`201886,1891
X&0620sys_close(`26itmfab);`20itm_file_open`20=`200;
X&0620return(0);
X&0620`7D
X&0420if`20(!sys_open(`26grpfab))`20return(0);
X&0420grp_file_open`20=`201;
X&0420if`20(!sys_connect(`26grprab))`20`7B
X---`201917,1936`20-----
X&0620sys_close(`26itmfab);`20itm_file_open`20=`200;
X&0620return(0);
X&0620`7D
X+`20/*`206/8/94`20saul@hnrc.tufts.edu`20-`20RMS`20Performance`20patch`20*/
X+`20`7B
X+&0720int`20buff_count=0;
X+&0720char`20*buff_count_ptr;
X+&0720buff_count_ptr`20=`20news_getenv("NEWS_GROUPFILE_BUFFERCOUNT",0);
X+&0720if`20(buff_count_ptr`20!=`20NULL)&0220sscanf(buff_count_ptr,"%d",`26buff
V_count);
X+`20
X+&0520if`20(news_getenv("NEWS_GROUPFILE_DFW",0)`20!=`200)
X+&0F20grpfab.fab$l_fop`20`7C=`20FAB$M_DFW;`20/*`20deferred`20write`20*/
X+&0520if`20(news_getenv("NEWS_GROUPFILE_RTV",0)`20!=`200)
X+&0F20grpfab.fab$b_rtv`20=`20255;&0820/*`20map`20the`20entire`20file`20*/
X+&0520if`20(buff_count`20>`200)
X+&0720grprab.rab$b_mbf`20=`20(buff_count`20<=`20127)`20?`20buff_count`20:`2012
V7;
X+`20`7D
X&0420if`20(!sys_open(`26grpfab))`20return(0);
X&0420grp_file_open`20=`201;
X&0220
X&0E2A
X***`201888,1893
X&0620`7D
X&0420if`20(!sys_open(`26grpfab))`20return(0);
X&0420grp_file_open`20=`201;
X&0420if`20(!sys_connect(`26grprab))`20`7B
X&0620sys_close(`26grpfab);`20grp_file_open`20=`200;
X&0620return(0);
X---`201933,1954`20-----
X&0220`7D
X&0420if`20(!sys_open(`26grpfab))`20return(0);
X&0420grp_file_open`20=`201;
X+`20
X+`20/*`206/8/94`20-`20saul@hnrc.tufts.edu`20RMS`20Performance`20patch`20*/
X+&0720`7B
X+&0720int`20buff_count=0;
X+&0720char`20*buff_count_ptr;
X+&0720buff_count_ptr`20=`20news_getenv("NEWS_GROUPFILE_GLOBAL_BUFFERCOUNT",0);
V
X+&0720if`20(buff_count_ptr`20!=`20NULL)
X+&0720`7B
X+&0B20sscanf(buff_count_ptr,"%d",`26buff_count);
X+`20
X+`20/*`20the`20file's`20global`20buffer`20count`20gets`20loaded`20on`20open
V`20by`20RMS,`20use`20the
X+&0520maximum`20of`20the`20stored`20value`20and`20the`20logical`20defined`20va
Vlue`20*/
X+`20
X+&0B20if`20(grpfab.fab$w_gbc`20<`20buff_count)`20grpfab.fab$w_gbc`20=`20buff_c
Vount;
X+&0720`7D
X+&0420`7D
X&0420if`20(!sys_connect(`26grprab))`20`7B
X&0620sys_close(`26grpfab);`20grp_file_open`20=`200;
X&0620return(0);
$ call unpack RMS_OPTIMIZE.PATCH;1 -
 2083362573 "FORMAT STREAM_LF;CARRIAGE_CONTROL CARRIAGE_RETURN"
$ v=f$verify(v)
$ exit

--
Saul Tannenbaum, Manager, Scientific Computing     Internet: saul@hnrc.tufts.edu
USDA Human Nutrition Research Center on Aging at Tufts University
