SIBackendInit returns a flag indicating whether it worked or not.  Since
there is only one caller and it dies with a FATAL error when
SIBackendInit failed, it seems better to move the elog and remove the
return value, per this patch.

-- 
Alvaro Herrera                  http://www.amazon.com/gp/registry/5ZYLFMCVHXC
"Always assume the user will do much worse than the stupidest thing
you can imagine."                                (Julien PUYDT)
Index: src/backend/storage/ipc/sinval.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/ipc/sinval.c,v
retrieving revision 1.82
diff -c -p -r1.82 sinval.c
*** src/backend/storage/ipc/sinval.c	5 Jan 2007 22:19:38 -0000	1.82
--- src/backend/storage/ipc/sinval.c	25 Jun 2007 17:33:06 -0000
*************** CreateSharedInvalidationState(void)
*** 67,83 ****
  void
  InitBackendSharedInvalidationState(void)
  {
- 	int			flag;
- 
  	LWLockAcquire(SInvalLock, LW_EXCLUSIVE);
! 	flag = SIBackendInit(shmInvalBuffer);
  	LWLockRelease(SInvalLock);
- 	if (flag < 0)				/* unexpected problem */
- 		elog(FATAL, "shared cache invalidation initialization failed");
- 	if (flag == 0)				/* expected problem: MaxBackends exceeded */
- 		ereport(FATAL,
- 				(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
- 				 errmsg("sorry, too many clients already")));
  }
  
  /*
--- 67,75 ----
  void
  InitBackendSharedInvalidationState(void)
  {
  	LWLockAcquire(SInvalLock, LW_EXCLUSIVE);
! 	SIBackendInit(shmInvalBuffer);
  	LWLockRelease(SInvalLock);
  }
  
  /*
Index: src/backend/storage/ipc/sinvaladt.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/storage/ipc/sinvaladt.c,v
retrieving revision 1.63
diff -c -p -r1.63 sinvaladt.c
*** src/backend/storage/ipc/sinvaladt.c	5 Jan 2007 22:19:38 -0000	1.63
--- src/backend/storage/ipc/sinvaladt.c	25 Jun 2007 17:33:51 -0000
*************** SIBufferInit(void)
*** 79,96 ****
  
  /*
   * SIBackendInit
!  *		Initialize a new backend to operate on the sinval buffer
!  *
!  * Returns:
!  *	   >0	A-OK
!  *		0	Failed to find a free procState slot (ie, MaxBackends exceeded)
!  *	   <0	Some other failure (not currently used)
   *
   * NB: this routine, and all following ones, must be executed with the
   * SInvalLock lock held, since there may be multiple backends trying
   * to access the buffer.
   */
! int
  SIBackendInit(SISeg *segP)
  {
  	int			index;
--- 79,92 ----
  
  /*
   * SIBackendInit
!  *		Initialize a new backend to operate on the sinval buffer.  It fails
!  *		with a FATAL error if there are no free procState slots.
   *
   * NB: this routine, and all following ones, must be executed with the
   * SInvalLock lock held, since there may be multiple backends trying
   * to access the buffer.
   */
! void
  SIBackendInit(SISeg *segP)
  {
  	int			index;
*************** SIBackendInit(SISeg *segP)
*** 117,124 ****
  		else
  		{
  			/* out of procState slots */
! 			MyBackendId = InvalidBackendId;
! 			return 0;
  		}
  	}
  
--- 113,121 ----
  		else
  		{
  			/* out of procState slots */
! 			ereport(FATAL,
! 					(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
! 					 errmsg("sorry, too many clients already")));
  		}
  	}
  
*************** SIBackendInit(SISeg *segP)
*** 137,144 ****
  
  	/* register exit routine to mark my entry inactive at exit */
  	on_shmem_exit(CleanupInvalidationState, PointerGetDatum(segP));
- 
- 	return 1;
  }
  
  /*
--- 134,139 ----
Index: src/include/storage/sinvaladt.h
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/include/storage/sinvaladt.h,v
retrieving revision 1.42
diff -c -p -r1.42 sinvaladt.h
*** src/include/storage/sinvaladt.h	5 Jan 2007 22:19:58 -0000	1.42
--- src/include/storage/sinvaladt.h	25 Jun 2007 17:32:49 -0000
*************** extern SISeg *shmInvalBuffer;	/* pointer
*** 107,113 ****
   * prototypes for functions in sinvaladt.c
   */
  extern void SIBufferInit(void);
! extern int	SIBackendInit(SISeg *segP);
  
  extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data);
  extern int SIGetDataEntry(SISeg *segP, int backendId,
--- 107,113 ----
   * prototypes for functions in sinvaladt.c
   */
  extern void SIBufferInit(void);
! extern void	SIBackendInit(SISeg *segP);
  
  extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidationMessage *data);
  extern int SIGetDataEntry(SISeg *segP, int backendId,
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to