ado@elsie.UUCP (06/16/84)
Recently there were challenges in getting news to a computer in our area. There was a big backlog of stuff to be sent, and names for uucp temporary files started to get recycled on the machine from which we get our news feed. Chaos! The version of uucp in question generated temporary file names with sequence numbers that had four decimal digits. By changing the sequence numbers to have four hexadecimal digits, the number of different sequence numbers was increased from 10000 to 65536, thus increasing the amount of backlog that could exist before chaos ensued. Source for sequence number handling is in "gename.c". Since some versions of printf have yet to be taught about hex, the portable way to enhance "gename.c" involves more than just substituting 4x for 4d throughout. Here's the result of "diff -c": *** /usr/local/src/cmd/uucp/oldgename.c Fri Jun 15 21:35:29 1984 --- /usr/local/src/cmd/uucp/gename.c Fri Jun 15 21:03:03 1984 *************** *** 36,41 { FILE *fp; int n; for (n = 0; n < SLOCKTRIES; n++) { if (!ulockf( SEQLOCK, SLOCKTIME)) break; --- 36,49 ----- { FILE *fp; int n; + #ifndef OLDVERSION + register char * format; + int testval; + + format = "%04x"; + if (sscanf("c", format, &testval) != 1 || testval != 12) + format = "%04d"; + #endif for (n = 0; n < SLOCKTRIES; n++) { if (!ulockf( SEQLOCK, SLOCKTIME)) break; *************** *** 46,51 if ((fp = fopen(SEQFILE, "r")) != NULL) { /* read sequence number file */ fscanf(fp, "%4d", &n); fp = freopen(SEQFILE, "w", fp); ASSERT(fp != NULL, "CAN NOT OPEN %s", SEQFILE); --- 54,60 ----- if ((fp = fopen(SEQFILE, "r")) != NULL) { /* read sequence number file */ + #ifdef OLDVERSION fscanf(fp, "%4d", &n); #else fscanf(fp, format, &n); *************** *** 47,52 if ((fp = fopen(SEQFILE, "r")) != NULL) { /* read sequence number file */ fscanf(fp, "%4d", &n); fp = freopen(SEQFILE, "w", fp); ASSERT(fp != NULL, "CAN NOT OPEN %s", SEQFILE); chmod(SEQFILE, 0666); --- 56,64 ----- /* read sequence number file */ #ifdef OLDVERSION fscanf(fp, "%4d", &n); + #else + fscanf(fp, format, &n); + #endif fp = freopen(SEQFILE, "w", fp); ASSERT(fp != NULL, "CAN NOT OPEN %s", SEQFILE); chmod(SEQFILE, 0666); *************** *** 60,65 n = 0; } fprintf(fp, "%s", sprintf(snum, "%04d", ++n)); fclose(fp); rmlock(SEQLOCK); --- 72,78 ----- n = 0; } + #ifdef OLDVERSION fprintf(fp, "%s", sprintf(snum, "%04d", ++n)); #else fprintf(fp, "%s", sprintf(snum, format, ++n)); *************** *** 61,66 } fprintf(fp, "%s", sprintf(snum, "%04d", ++n)); fclose(fp); rmlock(SEQLOCK); return(0); --- 74,82 ----- #ifdef OLDVERSION fprintf(fp, "%s", sprintf(snum, "%04d", ++n)); + #else + fprintf(fp, "%s", sprintf(snum, format, ++n)); + #endif fclose(fp); rmlock(SEQLOCK); return(0); -- ...decvax!allegra!umcp-cs!elsie!ado (301) 496-5688