Jan Wieck wieck at lists.slony.info
Thu Sep 27 11:02:54 PDT 2007
Update of /home/cvsd/slony1/slony1-engine/src/slony_logshipper
In directory main.slony.info:/tmp/cvs-serv16953

Modified Files:
	ipcutil.c slony_logshipper.h 
Log Message:
Let the logshipper wait on -t and -T until the running daemon has
destroyed the semaphore set.

Jan


Index: ipcutil.c
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slony_logshipper/ipcutil.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ipcutil.c	9 Sep 2007 02:37:05 -0000	1.2
--- ipcutil.c	27 Sep 2007 18:02:52 -0000	1.3
***************
*** 86,90 ****
  		 * Create or attach to the semaphore set
  		 */
! 		semid = semget(semkey, 2, 0700 | IPC_CREAT);
  		if (semid < 0)
  		{
--- 86,90 ----
  		 * Create or attach to the semaphore set
  		 */
! 		semid = semget(semkey, 3, 0700 | IPC_CREAT);
  		if (semid < 0)
  		{
***************
*** 487,491 ****
  ipc_send_term(char *archive_dir, bool immediate)
  {
! 	return ipc_send_code(archive_dir, (immediate) ? 3 : 2);
  }
  
--- 487,497 ----
  ipc_send_term(char *archive_dir, bool immediate)
  {
! 	int		rc;
! 
! 	rc = ipc_send_code(archive_dir, (immediate) ? 3 : 2);
! 	if (rc != 0)
! 		return rc;
! 
! 	return ipc_wait_for_destroy();
  }
  
***************
*** 603,606 ****
--- 609,635 ----
  
  /*
+  * ipc_wait_for_destroy()
+  *
+  *	Wait until the semaphore set is destroyed.
+  */
+ int
+ ipc_wait_for_destroy(void)
+ {
+ 	struct sembuf	sops[1] = {{2, -1, 0}};
+ 
+ 	if (semop(semid, sops, 1) < 0)
+ 	{
+ 		if (errno != EIDRM && errno != EINVAL)
+ 		{
+ 			fprintf(stderr, "semop() failed in ipc_wait_for_destroy(): %s\n",
+ 					strerror(errno));
+ 			return -1;
+ 		}
+ 	}
+ 	return 0;
+ }
+ 
+ 
+ /*
   * ipc_cleanup() -
   *

Index: slony_logshipper.h
===================================================================
RCS file: /home/cvsd/slony1/slony1-engine/src/slony_logshipper/slony_logshipper.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** slony_logshipper.h	17 Sep 2007 22:07:47 -0000	1.3
--- slony_logshipper.h	27 Sep 2007 18:02:52 -0000	1.4
***************
*** 220,223 ****
--- 220,224 ----
  int			ipc_lock(void);
  int			ipc_unlock(void);
+ int			ipc_wait_for_destroy(void);
  int			ipc_cleanup(char *archive_dir);
  void		ipc_set_shutdown_smart(void);



More information about the Slony1-commit mailing list