crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs

lockreporter.c (1026B)


      1 /*************************************************************************
      2  * This file is part of Crosroads 1.23, a load balancer and fail over
      3  * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL.
      4  * Visit http://crossroads.e-tunity.com for information.
      5  *************************************************************************/
      6 #include "crossroads.h"
      7 
      8 void lock_reporter() {
      9     static int warning_issued = 0;
     10     struct sembuf buf[] = {
     11 	{
     12 	    0,		/* semaphore number */
     13 	    0,		/* wait for zero */
     14 	    0,		/* no special flags */
     15 	}, 
     16 	{
     17 	    0,		/* semaphore number */
     18 	    1, 		/* add 1 to the value */
     19 	    0		/* no special flags */
     20 	}
     21     };
     22     
     23     /* msg ("Locking reporter memory"); */
     24     if ( (!warning_issued++) && (semop (semid, buf, 2) < 0) ) {
     25 	warning ("Failed to lock reporter memory (stage %s): %s",
     26 		 stage_to_string (program_stage), strerror(errno));
     27 	if (program_stage != stage_serving)
     28 	    exit (1);
     29 	else
     30 	    warning (".. but continuing serving this TCP connection");
     31     }
     32 }