[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lost files in router directory



If you run multiple routers, there is a danger of leaving files
orphaned in the router directory.  If it finds a file already renamed
to "file(N)", the file is ignored.  This is probably wrong -- the file
should only be ignored if N != our own router id.

Here is a patch, which also changes the format of the names to "file-N":

*** 1.2	1992/08/06 16:54:27
--- functions.c	1992/09/28 21:29:38
***************
*** 523,544 ****
  	extern void free_gensym();
  
  	if (router_id) {
  		len = strlen(filename);
! 		if (filename[len - 1] == ')' && strchr(filename, '(') != NULL)
! 			return;	/* an already locked message file */
! 		if (blen == 0) {
! 			blen = 100;
! 			buf = (char *)malloc(blen);
  		}
! 		while (len + 12 > blen) {
! 			blen = 2 * blen;
! 			buf = (char *)realloc(buf, blen);
  		}
- 		sprintf(buf, "%s(%d)", filename, router_id);
- 		if (erename(filename, buf) < 0)
- 			return;	/* something is wrong, erename() complains */
- 		filename = buf;
- 		/* message file is now "file(#)" and belongs to this process */
  	}
  
  	gensym = 1;
--- 523,555 ----
  	extern void free_gensym();
  
  	if (router_id) {
+ 		char *p;
+ 
  		len = strlen(filename);
! 		if ((p=strchr(filename, '-')) != NULL) { /* message file is "file-#" */
! 			if (router_id != atoi(p+1)) {
! 				/*
! 				 * an already locked message file,
! 				 * belonging to another process
! 				 */
! 				return;
! 			}
  		}
! 		else {
! 			if (blen == 0) {
! 				blen = 100;
! 				buf = (char *)malloc(blen);
! 			}
! 			while (len + 12 > blen) {
! 				blen = 2 * blen;
! 				buf = (char *)realloc(buf, blen);
! 			}
! 			sprintf(buf, "%s-%d", filename, router_id);
! 			if (erename(filename, buf) < 0)
! 				return;	/* something is wrong, erename() complains */
! 			filename = buf;
! 			/* message file is now "file-#" and belongs to this process */
  		}
  	}
  
  	gensym = 1;