[12490] in Athena Bugs

home help back first fref pref prev next nref lref last post

Quota server problems

daemon@ATHENA.MIT.EDU (epeisach@MIT.EDU)
Sun Aug 28 11:10:03 1994

From: epeisach@MIT.EDU
Date: Sun, 28 Aug 1994 11:09:53 -0400
To: rel-eng@MIT.EDU, bugs@MIT.EDU
Cc: op@MIT.EDU, jis@MIT.EDU


I do not know exactly why the server is locking up - I have some
theories but I will not be able to validate them. My current theory is
that bogus clients were flooding the server with requests and it could
not cope. I think if the clients are fixed, then the problem can be
safely ignored. In theory the problem could happen again - but I could
track it down if necessary now that I understand the process better. The
other reason is because someone would have to be malicious to start
screwing around with it and other servers can be subject to such
problems as well....

Anyway the fix....

a) ncs libraries - I have some changes for how the library is compiled.
Not that the existing library was broken - it was the system provided
ucb library - but the recompiling doesn't use flock and the wrong signal
handling. (see patch for pmakefile and std.h)

b) Patches to the quota directory - do away with the use of flock and
killpg. They aren't really relevevant for the client side lpquota - but
I am supplying them for completeness.

What to do:

a) Apply the patches of course....
b) make sure path is setup as in the build environment
c) (cd lpr/quota/ncs/nck; make -f rmakefile clean; make)
	(this cleans out the old and remakes the rmakefile from
	pmakefile)
d) (cd lpr/quota; make clean)
e) (cd lpr; make Makefiles)
	Now this is important - make sure the Makefile in quota does not
contain	the -lucb in it. From what I can tell from the build process,
the Makefile was based on the old config files - possibly from rel-eng.
I am not sure how it got there in your build tree - but make sure it is
not there.
f) (cd lpr/quota; make)

Then install per usual and test. Currently the quota query port is
wedged, but "lpquota -l is working and can be the guide.

g) Pay my bill....


*** 1.1	1994/08/27 09:23:07
--- quota/ncs/nck/pmakefile	1994/08/28 14:28:45
***************
*** 165,171 ****
  
  #ifdef sun
  #ifdef sparc
! DEFS        = -Dsun -Dsparc -DBSD -DINET
  EXTRALIBS   =
  EXTRACFLAGS = -I/usr/athena/include
  #else
--- 165,172 ----
  
  #ifdef sun
  #ifdef sparc
! DEFS        = -Dsun -Dsparc -DSYS5 -DSYS5_HAS_SELECT \
! 	-DSYS5_HAS_GETTIMEOFDAY  -DINET -DSYS5_SOCKETS_TYPE6
  EXTRALIBS   =
  EXTRACFLAGS = -I/usr/athena/include
  #else
*** 1.1	1994/08/27 09:15:45
--- quota/ncs/nck/std.h	1994/08/28 14:21:24
***************
*** 380,388 ****
--- 380,390 ----
  #    define __STDDEF
  #  endif
  #  include <string.h>
+ #ifndef SOLARIS
  #  define index strchr
  #  define rindex strrchr
  #endif
+ #endif
  
  /******************************************************************************/
  
***************
*** 390,396 ****
  #include <memory.h>
  #endif
  
! #if defined(SYS5) || defined(MSDOS) || defined(vms)
  #define bcopy(src, dst, len) memcpy((dst), (src), (len))
  #define bcmp memcmp
  #define bzero(dst, len) memset((dst), 0, (len))
--- 392,400 ----
  #include <memory.h>
  #endif
  
! #ifndef SOLARIS
! /* SOLARIS strings.h defines both cases properly */
! #if defined(SYS5) || defined(MSDOS) || defined(vms))
  #define bcopy(src, dst, len) memcpy((dst), (src), (len))
  #define bcmp memcmp
  #define bzero(dst, len) memset((dst), 0, (len))
***************
*** 398,403 ****
--- 402,408 ----
  extern bcopy();
  extern bcmp();
  extern bzero();
+ #endif
  #endif
  
  /******************************************************************************/
*** 1.1	1994/08/28 10:52:12
--- quota/consist.c	1994/08/28 14:52:47
***************
*** 1,4 ****
--- 1,5 ----
  #include <stdio.h>
+ #include <strings.h>
  #include "logger.h"
  #include <sys/types.h>
  #ifdef _IBMR2
*** 1.1	1994/08/28 10:31:34
--- quota/gquota_dba.c	1994/08/28 14:48:11
***************
***************
*** 585,591 ****
--- 585,595 ----
  static int gquota_dbl_lock(mode)
      int     mode;
  {
+ #ifdef POSIX_FLOCK
+     struct flock fl;
+ #else
      int flock_mode=0;
+ #endif
      
      if (!inited)
  	(void) gquota_dbl_init();
***************
*** 596,601 ****
--- 600,613 ----
  	exit(1);
      }
      switch (mode) {
+ #ifdef POSIX_FLOCK
+     case GQUOTA_DBL_EXCLUSIVE:
+ 	fl.l_type = F_WRLCK;
+ 	break;
+     case GQUOTA_DBL_SHARED:
+ 	fl.l_type = F_RDLCK;
+ 	break;
+ #else
      case GQUOTA_DBL_EXCLUSIVE:
  	flock_mode = LOCK_EX;
  	break;
***************
*** 602,616 ****
--- 614,638 ----
      case GQUOTA_DBL_SHARED:
  	flock_mode = LOCK_SH;
  	break;
+ #endif
      default:
  	fprintf(stderr, "invalid lock mode %d\n", mode);
  	abort();
      }
+ 
+ #ifdef POSIX_FLOCK
+     fl.l_whence = 0;
+     fl.l_start = 0;
+     fl.l_len = 0;
+     if (fcntl(dblfd, non_blocking ? F_SETLK : F_SETLKW, &fl) == -1) 
+ 	return errno;
+ #else	 
      if (non_blocking)
  	flock_mode |= LOCK_NB;
      
      if (flock(dblfd, flock_mode) < 0) 
  	return errno;
+ #endif
      mylock++;
      return 0;
  }
***************
*** 617,628 ****
--- 639,662 ----
  
  static void gquota_dbl_unlock()
  {
+ #ifdef POSIX_FLOCK
+     struct flock fl;
+ #endif
      if (!mylock) {		/* lock already unlocked */
  	fprintf(stderr, "gquota database lock not locked when unlocking.\n");
  	(void) fflush(stderr);
  	exit(1);
      }
+ 
+ #ifdef POSIX_FLOCK
+     fl.l_type = F_UNLCK;
+     fl.l_whence = 0;
+     fl.l_start = 0;
+     fl.l_len = 0;
+     if (fcntl(dblfd, F_SETLK, &fl) == -1) {
+ #else
      if (flock(dblfd, LOCK_UN) < 0) {
+ #endif
  	fprintf(stderr, "gquota database lock error. (unlocking)\n");
  	fflush(stderr);
  	perror("flock");
*** 1.14	1993/05/10 13:42:18
--- quota/qmain.c	1994/08/28 14:50:40
***************
*** 375,381 ****
--- 375,386 ----
  	
  Exit()
  {
+ #ifdef POSIX
+     /* I think this is right - but untested */
+     (void) kill(-getpid(), SIGKILL);
+ #else
      (void) killpg(getpid(), SIGKILL);
+ #endif
      exit(0);
  }
  
*** 1.1	1994/08/28 10:31:30
--- quota/quota_dba.c	1994/08/28 14:43:39
***************
*** 609,615 ****
--- 609,619 ----
  static int quota_dbl_lock(mode)
      int     mode;
  {
+ #ifdef POSIX_FLOCK
+     struct flock fl;
+ #else
      int flock_mode=0;
+ #endif
      
      if (!inited)
  	(void) quota_dbl_init();
***************
*** 620,625 ****
--- 624,637 ----
  	exit(1);
      }
      switch (mode) {
+ #ifdef POSIX_FLOCK
+     case QUOTA_DBL_EXCLUSIVE:
+ 	fl.l_type = F_WRLCK;
+ 	break;
+     case QUOTA_DBL_SHARED:
+ 	fl.l_type = F_RDLCK;
+ 	break;
+ #else
      case QUOTA_DBL_EXCLUSIVE:
  	flock_mode = LOCK_EX;
  	break;
***************
*** 626,640 ****
--- 638,662 ----
      case QUOTA_DBL_SHARED:
  	flock_mode = LOCK_SH;
  	break;
+ #endif
      default:
  	fprintf(stderr, "invalid lock mode %d\n", mode);
  	abort();
      }
+ 
+ #ifdef POSIX_FLOCK
+     fl.l_whence = 0;
+     fl.l_start = 0;
+     fl.l_len = 0;
+     if (fcntl(dblfd, non_blocking ? F_SETLK : F_SETLKW, &fl) == -1) 
+ 	return errno;
+ #else	 
      if (non_blocking)
  	flock_mode |= LOCK_NB;
      
      if (flock(dblfd, flock_mode) < 0) 
  	return errno;
+ #endif
      mylock++;
      return 0;
  }
***************
*** 641,652 ****
--- 663,687 ----
  
  static void quota_dbl_unlock()
  {
+ #ifdef POSIX_FLOCK
+     struct flock fl;
+ #endif
+ 
      if (!mylock) {		/* lock already unlocked */
  	fprintf(stderr, "quota database lock not locked when unlocking.\n");
  	(void) fflush(stderr);
  	exit(1);
      }
+ 
+ #ifdef POSIX_FLOCK
+     fl.l_type = F_UNLCK;
+     fl.l_whence = 0;
+     fl.l_start = 0;
+     fl.l_len = 0;
+     if (fcntl(dblfd, F_SETLK, &fl) == -1) {
+ #else
      if (flock(dblfd, LOCK_UN) < 0) {
+ #endif
  	fprintf(stderr, "quota database lock error. (unlocking)\n");
  	(void) fflush(stderr);
  	perror("flock");


home help back first fref pref prev next nref lref last post