Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 153907 Details for
Bug 238498
need fallback service
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch, pass 2
piranha-238498-2.patch (text/plain), 28.73 KB, created by
Lon Hohberger
on 2007-05-02 00:12:12 UTC
(
hide
)
Description:
patch, pass 2
Filename:
MIME Type:
Creator:
Lon Hohberger
Created:
2007-05-02 00:12:12 UTC
Size:
28.73 KB
patch
obsolete
>? .piranha.spec.swp >? RPM >? piranha-0.8.0-link.patch >? piranha-0.8.6-patched-238498.tar.gz >? piranha.spec >Index: Makefile >=================================================================== >RCS file: /cvs/devel/piranha/Makefile,v >retrieving revision 1.167 >diff -u -p -r1.167 Makefile >--- Makefile 15 Nov 2006 20:10:35 -0000 1.167 >+++ Makefile 2 May 2007 00:10:11 -0000 >@@ -129,11 +129,11 @@ endif > pkglists: > > >-lvsd: lvsd.o lvsconfig.o util.o >+lvsd: lvsd.o lvsconfig.o util.o ipvs_exec.o > > fos: fos.o lvsconfig.o util.o > >-nanny: nanny.o util.o >+nanny: nanny.o util.o ipvs_exec.o > > send_arp: send_arp.c > $(CC) $(CFLAGS) -o send_arp send_arp.c >Index: globals.h >=================================================================== >RCS file: /cvs/devel/piranha/globals.h,v >retrieving revision 1.11 >diff -u -p -r1.11 globals.h >--- globals.h 18 Jan 2002 20:21:06 -0000 1.11 >+++ globals.h 2 May 2007 00:10:11 -0000 >@@ -5,6 +5,10 @@ > #define PULSE "pulse 1.56" > #define NANNY "nanny 1.46" > >+#define NANNY_STATUS_SIZE 8 >+#define NANNY_ACTIVE_STATUS "[ active ]" >+#define NANNY_INACTIVE_STATUS "[inactive]" >+ > #define CFGFILE "/etc/sysconfig/ha/lvs.cf" > #define IPVSADM "/sbin/ipvsadm" > #define RESERVE "/usr/sbin/scsi_reserve" >Index: ipvs_exec.c >=================================================================== >RCS file: ipvs_exec.c >diff -N ipvs_exec.c >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ipvs_exec.c 2 May 2007 00:10:11 -0000 >@@ -0,0 +1,201 @@ >+/* >+** ipvs_exec.c -- Run IPVS commands >+** >+** Red Hat Clustering Tools >+** Copyright 1999 Red Hat Inc. >+** >+** Author: Erik Troan <ewt@redhat.com> >+** >+** 5-01-2007 - split from nanny.c by lhh@redhat.com >+*/ >+ >+#include <arpa/inet.h> >+#include <ctype.h> >+#include <errno.h> >+#include <fcntl.h> >+#include <netinet/ip.h> >+#include <netinet/ip_icmp.h> >+#include <popt.h> >+#include <setjmp.h> >+#include <stdlib.h> >+#include <string.h> >+#include <sys/poll.h> >+#include <sys/signal.h> >+#include <sys/socket.h> >+#include <sys/time.h> >+#include <sys/wait.h> >+#include <unistd.h> >+#include <math.h> /* for pow() */ >+#include <time.h> >+#include <sys/types.h> >+#include <regex.h> >+ >+#include "globals.h" >+#include "util.h" >+#include "nanny.h" >+ >+#define _(a) (a) >+#define N_(a) (a) >+ >+int >+runCommand (char *cmd, int flags, char **argv, int log_flag) >+{ >+ int child; >+ int status; >+ int rc; >+ int log_it; >+ >+ log_it = log_flag; >+ if (flags & NANNY_FLAG_VERBOSE) >+ log_it = -1; >+ >+ if (log_it) >+ logArgv (flags, argv); >+ >+ if (flags & NANNY_FLAG_NORUN) >+ return 0; >+ >+ if (!(child = fork ())) { >+ execv (argv[0], argv); >+ exit (1); >+ } >+ >+ rc = waitpid (child, &status, 0); >+ >+ if (!WIFEXITED (status) || WEXITSTATUS (status)) { >+ piranha_log (flags, (char *) "%s command failed!", cmd); >+ return 1; >+ } >+ >+ return 0; >+} >+ >+ >+int >+shutdownDev (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, int service_type, int fm, int udp) >+{ >+ >+ char *argv[40]; >+ char **argp = argv; >+ char virtName[80]; >+ char fwmStr[20]; >+ int rc = 0; >+ >+ if (service_type == SERV_LVS) { >+ /* Virtual Server */ >+ >+ *argp++ = ipvsadm; >+ *argp++ = (char *) "-d"; >+ >+ if (fm) { >+ sprintf (fwmStr, "%d", fm); >+ *argp++ = (char *) "-f"; >+ *argp++ = fwmStr; >+ } else { >+ sprintf (virtName, "%s:%d", virtualAddress, port); >+ if (udp) >+ *argp++ = (char *) "-u"; >+ else >+ *argp++ = (char *) "-t"; >+ *argp++ = virtName; >+ } >+ >+ *argp++ = (char *) "-r"; >+ *argp++ = inet_ntoa (*remoteAddr); >+ *argp = NULL; >+ >+ rc = runCommand (ipvsadm, flags, argv, -1); >+ >+ } >+ /* Nothing needs to be done for FOS */ >+ return rc; >+} >+ >+ >+int >+adjustDevice (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, char *routingMethod, int weight, >+ int fm, int udp) >+{ >+ char *argv[40]; >+ char **argp = argv; >+ char virtName[80]; >+ char weightStr[20]; >+ char fwmStr[20]; >+ >+ sprintf (weightStr, "%d", weight); >+ >+ *argp++ = ipvsadm; >+ *argp++ = (char *) "-e"; >+ >+ if (fm) { >+ sprintf (fwmStr, "%d", fm); >+ *argp++ = (char *) "-f"; >+ *argp++ = fwmStr; >+ } else { >+ sprintf (virtName, "%s:%d", virtualAddress, port); >+ if (udp) >+ *argp++ = (char *) "-u"; >+ else >+ *argp++ = (char *) "-t"; >+ *argp++ = virtName; >+ } >+ >+ *argp++ = (char *) "-r"; >+ *argp++ = inet_ntoa (*remoteAddr); >+ *argp++ = routingMethod; >+ *argp++ = (char *) "-w"; >+ *argp++ = weightStr; >+ *argp = NULL; >+ >+ return runCommand (ipvsadm, flags, argv, 0); >+} >+ >+ >+int >+bringUpDev (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, char *routingMethod, int weight, >+ int service_type, int fm, int udp) >+{ >+ >+ char *argv[40]; >+ char **argp = argv; >+ char virtName[80]; >+ char weightStr[20]; >+ char fwmStr[20]; >+ int rc = 0; >+ >+ if (service_type == SERV_LVS) { >+ /* Virtual Server */ >+ >+ sprintf (weightStr, "%d", weight); >+ >+ *argp++ = ipvsadm; >+ *argp++ = (char *) "-a"; >+ >+ if (fm) { >+ sprintf (fwmStr, "%d", fm); >+ *argp++ = (char *) "-f"; >+ *argp++ = fwmStr; >+ } else { >+ sprintf (virtName, "%s:%d", virtualAddress, port); >+ if (udp) >+ *argp++ = (char *) "-u"; >+ else >+ *argp++ = (char *) "-t"; >+ *argp++ = virtName; >+ } >+ >+ *argp++ = (char *) "-r"; >+ *argp++ = inet_ntoa (*remoteAddr); >+ *argp++ = routingMethod; >+ *argp++ = (char *) "-w"; >+ *argp++ = weightStr; >+ *argp = NULL; >+ >+ rc = runCommand (ipvsadm, flags, argv, -1); >+ } >+ /* Nothing needs to be done for FOS */ >+ return rc; >+} >Index: lvsconfig.c >=================================================================== >RCS file: /cvs/devel/piranha/lvsconfig.c,v >retrieving revision 1.83 >diff -u -p -r1.83 lvsconfig.c >--- lvsconfig.c 15 Nov 2006 22:19:57 -0000 1.83 >+++ lvsconfig.c 2 May 2007 00:10:11 -0000 >@@ -151,6 +151,7 @@ > #define LVS_SAW_VS_FWMARK (1 << 20) > #define LVS_SAW_VS_QUIESCESERVER (1 << 21) > #define LVS_SAW_VS_USEREGEX (1 << 22) >+#define LVS_SAW_VS_SORRYSERVER (1 << 23) > > #define LVS_SAW_AS_ADDRESS (1 << 0) > #define LVS_SAW_AS_ISACTIVE (1 << 1) >@@ -853,7 +854,6 @@ outputVirtualServer (struct outputBuffer > inet_ntoa (eserver->pmask)); > } > >- > if (!(saw & LVS_SAW_VS_PROTOCOL) && eserver->protocol != IPPROTO_TCP) > outputFormat (ob, (char *) "\tprotocol = udp\n"); > >@@ -913,6 +913,7 @@ outputVirtualServer (struct outputBuffer > (char *) "\treentry = %d\n") > OUTPUT_MISSING_IPADDR (LVS_SAW_VS_MASTERSERVER, eserver->masterServer, > (char *) "\tmaster = %s\n") >+ > if (outputRealServers) { > i = -1; > while (++i < eserver->numServers) >@@ -964,6 +965,9 @@ parseVirtualServer (struct fileState *fs > if (rc) > return rc; > >+ /* Zap the sorry server... */ >+ memset(&vserver->sorry_server, 0, sizeof(vserver->sorry_server)); >+ > while (*toks.argv && strcmp (toks.argv[0], "}")) > { > dumpToks (fs, &toks, " virtual server: "); >@@ -998,6 +1002,16 @@ parseVirtualServer (struct fileState *fs > } > > } >+ else if (TOKEN ("sorry_server")) >+ { >+ CHECK_ARGS (1) if (inet_aton (toks.argv[2], &vserver->sorry_server)) >+ { >+ OUTPUT_IPADDR (eserver, sorry_server, 2, LVS_SAW_VS_SORRYSERVER); >+ } >+ else >+ return LVS_ERROR_BADHOSTNAME; >+ >+ } > else if (TOKEN ("vip_nmask")) > { > CHECK_ARGS (1) if (inet_aton (toks.argv[2], &vserver->vip_nmask)) >Index: lvsconfig.h >=================================================================== >RCS file: /cvs/devel/piranha/lvsconfig.h,v >retrieving revision 1.38 >diff -u -p -r1.38 lvsconfig.h >--- lvsconfig.h 28 Jul 2005 17:16:03 -0000 1.38 >+++ lvsconfig.h 2 May 2007 00:10:11 -0000 >@@ -119,10 +119,12 @@ struct lvsVirtualServer > { > char *name; > int isActive; >+ int runstate; > char *virtualDevice; > struct in_addr virtualAddress; /* for Virtual IP address */ > struct in_addr vip_nmask; > struct in_addr broadcast; >+ struct in_addr sorry_server; > > unsigned int fwmark; /* for fwmark-based virtual server */ > int protocol; /* IPPROTO_TCP or IPPROTO_UDP */ >Index: lvsd.c >=================================================================== >RCS file: /cvs/devel/piranha/lvsd.c,v >retrieving revision 1.2 >diff -u -p -r1.2 lvsd.c >--- lvsd.c 15 May 2006 22:37:52 -0000 1.2 >+++ lvsd.c 2 May 2007 00:10:11 -0000 >@@ -112,10 +112,12 @@ > #include <sys/signal.h> > #include <sys/wait.h> > #include <unistd.h> >+#include <assert.h> > > #include "globals.h" > #include "lvsconfig.h" > #include "util.h" >+#include "nanny.h" > > #define _PROGRAM_VERSION LVS /* From globals.h */ > >@@ -129,12 +131,40 @@ static int debug_mode = 0; > > struct clientInfo > { >+ struct lvsVirtualServer *vserver; > struct in_addr vip; > struct in_addr address; > int port, protocol; >+ int clientPipe; >+ int clientActive; > pid_t clientMonitor; /* -1 if died */ > }; > >+ >+int >+shutdownDev (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, int service_type, int fm, int udp); >+ >+int >+bringUpDev (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, char *routingMethod, int weight, >+ int service_type, int fm, int udp); >+ >+char * >+rm_to_str(int redirectType) { >+ switch (redirectType) >+ { >+ case LVS_REDIRECT_NAT: >+ return (char *) "-m"; >+ case LVS_REDIRECT_DIRECT: >+ return (char *) "-g"; >+ case LVS_REDIRECT_TUNNEL: >+ return (char *) "-i"; >+ } >+ return NULL; >+} >+ >+ > /* returns 0 if clients match, 1 otherwise */ > > int cmpRealServers(struct clientInfo *client1, struct clientInfo *client2) >@@ -180,6 +210,11 @@ handleHupSignal (int signal) > } > > >+static void >+handleAlarmSignal (int signal) >+{ >+ /* nothing */ >+} > > > int >@@ -304,7 +339,7 @@ startClientMonitor (struct lvsConfig *co > { > > struct clientInfo clientInfo; >- int rc; >+ int rc, cld_pipe[2], cfl; > char *realAddress; > char *virtAddress; > char *argv[42]; >@@ -316,6 +351,9 @@ startClientMonitor (struct lvsConfig *co > if (!service->isActive) > return 0; > >+ /* assume we're alive */ >+ vserver->runstate = 1; >+ clientInfo.vserver = vserver; > clientInfo.vip = vserver->virtualAddress; > clientInfo.address = service->address; > clientInfo.protocol = vserver->protocol; >@@ -438,14 +476,42 @@ startClientMonitor (struct lvsConfig *co > > if (!(flags & LVS_FLAG_TESTSTARTS)) > { >+ if (pipe(cld_pipe) < 0) { >+ /* do exactly what here? */ >+ assert(0); >+ } >+ > child = fork (); > > if (!child) > { >+ /* Smoke a pipe, yo */ >+ dup2(cld_pipe[0], STDIN_FILENO); >+ dup2(cld_pipe[1], STDOUT_FILENO); >+ dup2(cld_pipe[1], STDERR_FILENO); >+ >+ if (cld_pipe[0] > 2) >+ close(cld_pipe[0]); >+ if (cld_pipe[1] > 2) >+ close(cld_pipe[1]); >+ >+ /* Don't block on writes. Or anything. */ >+ cfl = fcntl(STDIN_FILENO, F_GETFL); >+ fcntl(STDIN_FILENO, F_SETFL, cfl | O_NONBLOCK); >+ cfl = fcntl(STDOUT_FILENO, F_GETFL); >+ fcntl(STDOUT_FILENO, F_SETFL, cfl | O_NONBLOCK); >+ cfl = fcntl(STDERR_FILENO, F_GETFL); >+ fcntl(STDERR_FILENO, F_SETFL, cfl | O_NONBLOCK); >+ > execv (argv[0], argv); > exit (1); > } > >+ /* don't need this half of it */ >+ /* nonblocking I/o */ >+ close(cld_pipe[1]); >+ cfl = fcntl(cld_pipe[0], F_GETFL); >+ fcntl(cld_pipe[0], F_SETFL, cfl | O_NONBLOCK); > piranha_log (flags, > (char *) "create_monitor for %s/%s running as pid %d", > vserver->name, service->name, child); >@@ -459,7 +525,10 @@ startClientMonitor (struct lvsConfig *co > free (virtAddress); > free (realAddress); > >+ clientInfo.vserver = vserver; > clientInfo.clientMonitor = child; >+ clientInfo.clientPipe = cld_pipe[0]; >+ clientInfo.clientActive = 0; > clients[*numClients] = clientInfo; > (*numClients)++; > >@@ -467,8 +536,6 @@ startClientMonitor (struct lvsConfig *co > } > > >- >- > int > shutdownClientMonitor (struct lvsConfig *config, > struct lvsVirtualServer *vserver, >@@ -495,6 +562,10 @@ shutdownClientMonitor (struct lvsConfig > { > kill (clients[which].clientMonitor, SIGTERM); > waitpid (clients[which].clientMonitor, NULL, 0); >+ clients[which].vserver = NULL; >+ clients[which].clientActive = 0; >+ close(clients[which].clientPipe); >+ clients[which].clientPipe = -1; > } > > if (which != (*numClientsPtr - 1)) >@@ -956,6 +1027,149 @@ rereadConfigFiles (struct lvsConfig *old > return 0; > } > >+int >+activeClientCount(struct lvsVirtualServer *vs, struct clientInfo *clients, >+ int numClients) >+{ >+ int count = 0, i; >+ >+ for (i = 0; i < numClients; i++) { >+ if (clients[i].vserver == vs && clients[i].clientActive) { >+ count++; >+ } >+ } >+ >+ return count; >+} >+ >+ >+void >+updateClientStatus(struct clientInfo *client) >+{ >+ char buf[80]; >+ int n; >+ >+ memset(buf, 0, sizeof(buf)); >+ while ((n = read(client->clientPipe, buf, sizeof(buf))) >= 0) { >+ if (n >= NANNY_STATUS_SIZE) { >+ if (strstr(buf, NANNY_ACTIVE_STATUS) && !client->clientActive) { >+ fprintf(stderr, "nanny pid %d activated\n", client->clientMonitor ); >+ client->clientActive = 1; >+ } else if (strstr(buf, NANNY_INACTIVE_STATUS) && client->clientActive) { >+ fprintf(stderr, "nanny pid %d inactive\n", client->clientMonitor ); >+ client->clientActive = 0; >+ } >+ } >+ >+ if (n == 0) >+ break; >+ } >+} >+ >+ >+int >+checkClientMonitor(struct lvsConfig *config, struct lvsVirtualServer *vs, >+ struct clientInfo *clients, >+ int numClients, int flags) >+{ >+ fd_set rfds; >+ int max = -1, i, have_sorry; >+ int nready = 0; >+ struct timeval tv = {0, 0}; >+ char buf[64]; >+ >+ /* Find all clientPipes ... */ >+ /* XXX */ >+ assert(sizeof(buf) > sizeof(config->virtServers[i].sorry_server) ); >+ >+ FD_ZERO(&rfds); >+ for (i = 0; i < numClients; i++) { >+ if (clients[i].vserver == vs && clients[i].clientPipe >= 0) { >+ FD_SET(clients[i].clientPipe, &rfds); >+ if (clients[i].clientPipe > max) { >+ max = clients[i].clientPipe; >+ } >+ } >+ } >+ >+ nready = select(max + 1, &rfds, NULL, NULL, &tv); >+ if (nready < 0) { >+ piranha_log (flags, >+ (char *) "select(): %s", strerror(errno)); >+ return -1; >+ } else if (nready > 0) { >+ >+ /* Ok, update our status... thingies. */ >+ for (i = 0; i < numClients; i++) { >+ if (clients[i].vserver == vs && >+ FD_ISSET(clients[i].clientPipe,&rfds)) { >+ >+ FD_CLR(clients[i].clientPipe, &rfds); >+ updateClientStatus(&clients[i]); >+ } >+ } >+ } >+ >+ /* count active clients and see if we need to activate the >+ sorry_server */ >+ max = activeClientCount(vs, clients, numClients); >+ >+ if (!max && vs->runstate) { >+ vs->runstate = 0; >+ memset(buf, 0, sizeof(buf)); >+ have_sorry = memcmp(&(vs->sorry_server), buf, >+ sizeof(vs->sorry_server)); >+ if (!have_sorry) >+ return 0; >+ >+ inet_ntop(AF_INET, &vs->sorry_server, buf, sizeof(buf)); >+ printf("Virtual Server %s: No real servers; activate sorry_server %s\n", vs->name, buf); >+ inet_ntop(AF_INET, &vs->virtualAddress, buf, sizeof(buf)); >+ bringUpDev(flags, >+ config->vsadm, >+ buf, vs->port, >+ &vs->sorry_server, >+ rm_to_str(config->redirectType), >+ 1, SERV_LVS, >+ vs->fwmark, (vs->protocol == IPPROTO_UDP)); >+ >+ >+ } else if (max && !vs->runstate) { >+ vs->runstate = 1; >+ memset(buf, 0, sizeof(buf)); >+ have_sorry = memcmp(&(vs->sorry_server), buf, >+ sizeof(vs->sorry_server)); >+ if (!have_sorry) >+ return 0; >+ >+ inet_ntop(AF_INET, &vs->sorry_server, buf, sizeof(buf)); >+ printf("Virtual Server %s: %d real servers; deactivate sorry_server %s\n", vs->name, max, buf); >+ inet_ntop(AF_INET, &vs->virtualAddress, buf, sizeof(buf)); >+ shutdownDev(flags, >+ config->vsadm, >+ buf, vs->port, >+ &vs->sorry_server, >+ SERV_LVS, >+ vs->fwmark, (vs->protocol == IPPROTO_UDP)); >+ } >+ >+ return 0; >+} >+ >+ >+int >+checkClientMonitors(struct lvsConfig *config, struct clientInfo *clients, >+ int numClients, int flags) >+{ >+ int i, ret = 0; >+ >+ for (i = 0; i < config->numVirtServers; i++) { >+ ret += checkClientMonitor(config, &config->virtServers[i], clients, numClients, >+ flags); >+ } >+ >+ return ret; >+} > > > int >@@ -990,6 +1204,7 @@ startServices (struct lvsConfig *config, > signal (SIGINT, handleTermSignal); > signal (SIGTERM, handleTermSignal); > signal (SIGHUP, handleHupSignal); >+ signal (SIGALRM, handleAlarmSignal); > > for (i = 0; i < config->numVirtServers; i++) > { >@@ -1005,6 +1220,7 @@ startServices (struct lvsConfig *config, > } > > sigfillset (&sigs); >+ sigdelset (&sigs, SIGALRM); > sigdelset (&sigs, SIGINT); > sigdelset (&sigs, SIGCHLD); > sigdelset (&sigs, SIGTERM); >@@ -1013,7 +1229,9 @@ startServices (struct lvsConfig *config, > > while (!doShutdown) > { >+ alarm(5); > sigsuspend (&sigs); >+ alarm(0); > > while ((pid = waitpid (-1, &status, WNOHANG)) > 0) > { >@@ -1038,10 +1256,17 @@ startServices (struct lvsConfig *config, > config->virtServers[vsn].servers[sn].name); > > doShutdown = 1; >+ >+ /* Clean up client pipes */ > clients[i].clientMonitor = -1; >+ clients[i].clientActive = 0; >+ close(clients[i].clientPipe); >+ clients[i].clientPipe = -1; > } > } > >+ checkClientMonitors(config, clients, numClients, flags); >+ > if (termSignal) > { > piranha_log (flags, >Index: nanny.c >=================================================================== >RCS file: /cvs/devel/piranha/nanny.c,v >retrieving revision 1.30 >diff -u -p -r1.30 nanny.c >--- nanny.c 12 Jun 2006 18:00:56 -0000 1.30 >+++ nanny.c 2 May 2007 00:10:11 -0000 >@@ -177,6 +177,111 @@ unsigned int fwmark = 0; > /* static const char *http_recv_str = "HTTP"; */ > /* Default send/expect for port 80 */ > >+ >+int >+shutdownDev (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, int service_type, int fm, int udp); >+ >+int >+adjustDevice (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, char *routingMethod, int weight, >+ int fm, int udp); >+ >+int >+bringUpDev (int flags, char *ipvsadm, char *virtualAddress, int port, >+ struct in_addr *remoteAddr, char *routingMethod, int weight, >+ int service_type, int fm, int udp); >+ >+char * >+getExecOutput (int flags, char **argv, int timeout) >+{ >+ >+ pid_t child; >+ int status; >+ sigset_t sigs, oldSigs; >+ int p[2]; >+ int rc; >+ char buf[4096]; >+ >+ sigemptyset (&sigs); >+ sigaddset (&sigs, SIGTERM); >+ sigaddset (&sigs, SIGINT); >+ sigaddset (&sigs, SIGALRM); >+ >+ pipe (p); >+ >+ if (!(child = fork ())) { >+ int stdin, stderr; >+ >+ close (p[0]); >+ if (p[1] != STDOUT_FILENO) { >+ close (STDOUT_FILENO); >+ dup2 (p[1], STDOUT_FILENO); >+ close (p[1]); >+ } >+ >+ stdin = open ("/dev/null", O_RDONLY); >+ if (stdin != STDIN_FILENO) { >+ close (STDIN_FILENO); >+ dup2 (stdin, STDIN_FILENO); >+ } >+ stderr = open ("/dev/null", O_WRONLY); >+ if (stderr != STDERR_FILENO) { >+ close (STDERR_FILENO); >+ dup2 (stderr, STDERR_FILENO); >+ } >+ >+ execvp (argv[0], argv); >+ exit (1); >+ } >+ >+ close (p[1]); >+ >+ alarm (timeout); >+ >+ needsKilling = child; >+ sigprocmask (SIG_UNBLOCK, &sigs, &oldSigs); >+ >+ rc = waitpid (child, &status, 0); >+ sigprocmask (SIG_SETMASK, &oldSigs, NULL); >+ needsKilling = 0; >+ >+ if (rc < 0) { >+ if (rc == EINTR) >+ piranha_log (flags, (char *) >+ "unexpected return \"%s\" running the following:"); >+ else >+ piranha_log (flags, >+ (char *) "timeout running the following:"); >+ >+ logArgv (flags, argv); >+ kill (child, SIGKILL); >+ waitpid (child, &status, 0); >+ close (p[0]); /* Per bugzilla #20974 */ >+ return NULL; >+ } >+ >+ if (!WIFEXITED (status) || WEXITSTATUS (status)) { >+ piranha_log (flags, >+ (char *) "The following exited abnormally:"); >+ logArgv (flags, argv); >+ close (p[0]); /* Per bugzilla #20974 */ >+ return NULL; >+ } >+ >+ rc = read (p[0], buf, sizeof (buf) - 1); >+ if (rc >= 1) >+ buf[rc - 1] = '\0'; /* chop */ >+ else >+ buf[0] = '\0'; >+ >+ close (p[0]); >+ >+ return strdup (buf); >+} >+ >+ >+ > static void > handleTermSignal (int signal) > { >@@ -617,252 +722,6 @@ pinger (int flags, int s, struct in_addr > return return_status; > } > >-int >-runCommand (char *cmd, int flags, char **argv, int log_flag) >-{ >- int child; >- int status; >- int rc; >- int log_it; >- >- log_it = log_flag; >- if (flags & NANNY_FLAG_VERBOSE) >- log_it = -1; >- >- if (log_it) >- logArgv (flags, argv); >- >- if (flags & NANNY_FLAG_NORUN) >- return 0; >- >- if (!(child = fork ())) { >- execv (argv[0], argv); >- exit (1); >- } >- >- rc = waitpid (child, &status, 0); >- >- if (!WIFEXITED (status) || WEXITSTATUS (status)) { >- piranha_log (flags, (char *) "%s command failed!", cmd); >- return 1; >- } >- >- return 0; >-} >- >-int >-shutdownDev (int flags, char *ipvsadm, char *virtualAddress, int port, >- struct in_addr *remoteAddr, int service_type) >-{ >- >- char *argv[40]; >- char **argp = argv; >- char virtName[80]; >- char fwmStr[20]; >- int rc = 0; >- >- if (service_type == SERV_LVS) { >- /* Virtual Server */ >- >- *argp++ = ipvsadm; >- *argp++ = (char *) "-d"; >- >- if (fwmark) { >- sprintf (fwmStr, "%d", fwmark); >- *argp++ = (char *) "-f"; >- *argp++ = fwmStr; >- } else { >- sprintf (virtName, "%s:%d", virtualAddress, port); >- if (use_udp) >- *argp++ = (char *) "-u"; >- else >- *argp++ = (char *) "-t"; >- *argp++ = virtName; >- } >- >- *argp++ = (char *) "-r"; >- *argp++ = inet_ntoa (*remoteAddr); >- *argp = NULL; >- >- rc = runCommand (ipvsadm, flags, argv, -1); >- >- } >- /* Nothing needs to be done for FOS */ >- return rc; >-} >- >-int >-adjustDevice (int flags, char *ipvsadm, char *virtualAddress, int port, >- struct in_addr *remoteAddr, char *routingMethod, int weight) >-{ >- char *argv[40]; >- char **argp = argv; >- char virtName[80]; >- char weightStr[20]; >- char fwmStr[20]; >- >- sprintf (weightStr, "%d", weight); >- >- *argp++ = ipvsadm; >- *argp++ = (char *) "-e"; >- >- if (fwmark) { >- sprintf (fwmStr, "%d", fwmark); >- *argp++ = (char *) "-f"; >- *argp++ = fwmStr; >- } else { >- sprintf (virtName, "%s:%d", virtualAddress, port); >- if (use_udp) >- *argp++ = (char *) "-u"; >- else >- *argp++ = (char *) "-t"; >- *argp++ = virtName; >- } >- >- *argp++ = (char *) "-r"; >- *argp++ = inet_ntoa (*remoteAddr); >- *argp++ = routingMethod; >- *argp++ = (char *) "-w"; >- *argp++ = weightStr; >- *argp = NULL; >- >- return runCommand (ipvsadm, flags, argv, 0); >-} >- >-int >-bringUpDev (int flags, char *ipvsadm, char *virtualAddress, int port, >- struct in_addr *remoteAddr, char *routingMethod, int weight, >- int service_type) >-{ >- >- char *argv[40]; >- char **argp = argv; >- char virtName[80]; >- char weightStr[20]; >- char fwmStr[20]; >- int rc = 0; >- >- if (service_type == SERV_LVS) { >- /* Virtual Server */ >- >- sprintf (weightStr, "%d", weight); >- >- *argp++ = ipvsadm; >- *argp++ = (char *) "-a"; >- >- if (fwmark) { >- sprintf (fwmStr, "%d", fwmark); >- *argp++ = (char *) "-f"; >- *argp++ = fwmStr; >- } else { >- sprintf (virtName, "%s:%d", virtualAddress, port); >- if (use_udp) >- *argp++ = (char *) "-u"; >- else >- *argp++ = (char *) "-t"; >- *argp++ = virtName; >- } >- >- *argp++ = (char *) "-r"; >- *argp++ = inet_ntoa (*remoteAddr); >- *argp++ = routingMethod; >- *argp++ = (char *) "-w"; >- *argp++ = weightStr; >- *argp = NULL; >- >- rc = runCommand (ipvsadm, flags, argv, -1); >- } >- /* Nothing needs to be done for FOS */ >- return rc; >-} >- >-char * >-getExecOutput (int flags, char **argv, int timeout) >-{ >- >- pid_t child; >- int status; >- sigset_t sigs, oldSigs; >- int p[2]; >- int rc; >- char buf[4096]; >- >- sigemptyset (&sigs); >- sigaddset (&sigs, SIGTERM); >- sigaddset (&sigs, SIGINT); >- sigaddset (&sigs, SIGALRM); >- >- pipe (p); >- >- if (!(child = fork ())) { >- int stdin, stderr; >- >- close (p[0]); >- if (p[1] != STDOUT_FILENO) { >- close (STDOUT_FILENO); >- dup2 (p[1], STDOUT_FILENO); >- close (p[1]); >- } >- >- stdin = open ("/dev/null", O_RDONLY); >- if (stdin != STDIN_FILENO) { >- close (STDIN_FILENO); >- dup2 (stdin, STDIN_FILENO); >- } >- stderr = open ("/dev/null", O_WRONLY); >- if (stderr != STDERR_FILENO) { >- close (STDERR_FILENO); >- dup2 (stderr, STDERR_FILENO); >- } >- >- execvp (argv[0], argv); >- exit (1); >- } >- >- close (p[1]); >- >- alarm (timeout); >- >- needsKilling = child; >- sigprocmask (SIG_UNBLOCK, &sigs, &oldSigs); >- >- rc = waitpid (child, &status, 0); >- sigprocmask (SIG_SETMASK, &oldSigs, NULL); >- needsKilling = 0; >- >- if (rc < 0) { >- if (rc == EINTR) >- piranha_log (flags, (char *) >- "unexpected return \"%s\" running the following:"); >- else >- piranha_log (flags, >- (char *) "timeout running the following:"); >- >- logArgv (flags, argv); >- kill (child, SIGKILL); >- waitpid (child, &status, 0); >- close (p[0]); /* Per bugzilla #20974 */ >- return NULL; >- } >- >- if (!WIFEXITED (status) || WEXITSTATUS (status)) { >- piranha_log (flags, >- (char *) "The following exited abnormally:"); >- logArgv (flags, argv); >- close (p[0]); /* Per bugzilla #20974 */ >- return NULL; >- } >- >- rc = read (p[0], buf, sizeof (buf) - 1); >- if (rc >= 1) >- buf[rc - 1] = '\0'; /* chop */ >- else >- buf[0] = '\0'; >- >- close (p[0]); >- >- return strdup (buf); >-} > > int > external_check (int flags, char *send_program, char *expect_str, >@@ -1029,7 +888,7 @@ adjustWeight (int flags, char *ipvsadm, > port, newWeight); > > if (adjustDevice (flags, ipvsadm, virtualAddress, >- port, remoteAddr, routingMethod, newWeight)) >+ port, remoteAddr, routingMethod, newWeight, fwmark, use_udp)) > return -1; > } else { > /* Querying the load information and adjusting the >@@ -1076,7 +935,7 @@ adjustWeight (int flags, char *ipvsadm, > if (adjustDevice (flags, ipvsadm, > virtualAddress, port, > remoteAddr, routingMethod, >- newWeight)) >+ newWeight, fwmark, use_udp)) > return -1; > > return newWeight; >@@ -1111,7 +970,8 @@ checkState (int flags, char *ipvsadm, ch > virtualAddress, port, > remoteAddr, > routingMethod, >- weight, service_type)) >+ weight, service_type, >+ fwmark, use_udp)) > return -1; > } > *isActive = 1; >@@ -1126,7 +986,8 @@ checkState (int flags, char *ipvsadm, ch > /* Virtual Server */ > if (shutdownDev (flags, ipvsadm, > virtualAddress, port, >- remoteAddr, service_type)) >+ remoteAddr, service_type, fwmark, >+ use_udp)) > return -1; > } > *isActive = 0; >@@ -1159,7 +1020,7 @@ run (int flags, char *ipvsadm, char *vir > > int isActive = 0; > int currCount = countThresh; >- int isAvail; >+ int isAvail = 0; > int isSrvUp = 0; > int pingSocket; > sigset_t sigs; >@@ -1220,7 +1081,7 @@ run (int flags, char *ipvsadm, char *vir > > if (isActive && service_type == SERV_LVS) { > if (shutdownDev (flags, ipvsadm, virtualAddress, port, >- remoteAddr, service_type)) >+ remoteAddr, service_type, fwmark, use_udp)) > exit (1); > } > >@@ -1316,7 +1177,8 @@ run (int flags, char *ipvsadm, char *vir > int newWeight; > > piranha_log (flags, >- (char *) "making %s:%d available", >+ (char *) "%s making %s:%d available", >+ NANNY_ACTIVE_STATUS, > inet_ntoa (*remoteAddr), port); > > /* compute the initial weight */ >@@ -1329,14 +1191,15 @@ run (int flags, char *ipvsadm, char *vir > (flags, ipvsadm, > virtualAddress, port, > remoteAddr, routingMethod, >- newWeight)) >+ newWeight, fwmark, use_udp)) > return -1; > } else { > if (bringUpDev > (flags, ipvsadm, > virtualAddress, port, > remoteAddr, routingMethod, >- newWeight, service_type)) >+ newWeight, service_type, >+ fwmark, use_udp)) > return -1; > isSrvUp = 1; > } >@@ -1369,20 +1232,21 @@ run (int flags, char *ipvsadm, char *vir > } else if (service_type == SERV_LVS) { > /* Virtual Services */ > piranha_log (flags, (char *) >- "shutting down %s:%d due to connection failure", >+ "%s shutting down %s:%d due to connection failure", >+ NANNY_INACTIVE_STATUS, > inet_ntoa (*remoteAddr), port); > > if (quiesce_srv && isSrvUp) { > if (adjustDevice > (flags, ipvsadm, > virtualAddress, port, >- remoteAddr, routingMethod, 0)) >+ remoteAddr, routingMethod, 0, fwmark, use_udp)) > return -1; > } else { > if (shutdownDev > (flags, ipvsadm, > virtualAddress, port, >- remoteAddr, service_type)) >+ remoteAddr, service_type, fwmark, use_udp)) > return -1; > isSrvUp = 0; > } >Index: util.c >=================================================================== >RCS file: /cvs/devel/piranha/util.c,v >retrieving revision 1.14 >diff -u -p -r1.14 util.c >--- util.c 26 Apr 2002 04:19:57 -0000 1.14 >+++ util.c 2 May 2007 00:10:11 -0000 >@@ -72,6 +72,8 @@ doSyslog (char *format, va_list args) > void > piranha_log (int flags, char *format, ...) > { >+ char logmsg[256]; >+ char totalmsg[320]; > > va_list args; > >@@ -79,9 +81,9 @@ piranha_log (int flags, char *format, .. > > if (flags & LVS_FLAG_PRINTF) > { >- printf ("%s: ", name); >- vprintf (format, args); >- printf ("\n"); >+ vsnprintf (logmsg, sizeof(logmsg), format, args); >+ snprintf(totalmsg, sizeof(totalmsg), "%s: %s\n", name, logmsg); >+ write(STDOUT_FILENO, totalmsg, strlen(totalmsg)); > } > else if (flags & LVS_FLAG_SYSLOG) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 238498
:
153903
|
153907
|
153914
|
153954
|
154052
|
154065
|
154291
|
318124