[zumastor commit] r1731 - trunk/ddsnap

1 view
Skip to first unread message

codesite...@google.com

unread,
Aug 21, 2008, 1:48:12 AM8/21/08
to zumastor...@googlegroups.com
Author: Daniel.Raymond.Phillips
Date: Wed Aug 20 22:45:26 2008
New Revision: 1731

Modified:
trunk/ddsnap/ddsnapd.c

Log:
Crapectomy: remove misconceived and broken memory monitor idea forced on us
by a technically incompetent google manager.


Modified: trunk/ddsnap/ddsnapd.c
==============================================================================
--- trunk/ddsnap/ddsnapd.c (original)
+++ trunk/ddsnap/ddsnapd.c Wed Aug 20 22:45:26 2008
@@ -4219,84 +4219,12 @@
return 0;
}

-#ifdef DDSNAP_MEM_MONITOR
-
-#include <sys/time.h>
-#include <sys/resource.h>
-
-/*
- * itoa() and reverse() lifted straight from K&R C, 2nd edition.
- */
-void reverse(char s[])
-{
- int c, i, j;
-
- for (i = 0, j = strlen(s)-1; i < j; i++, j--) {
- c = s[i];
- s[i] = s[j];
- s[j] = c;
- }
-}
-
-void itoa(int n, char s[])
-{
- int i, sign;
- sign = n;
-
- i = 0;
- do {
- s[i++] = abs(n % 10) + '0';
- } while (n /= 10);
- if (sign < 0)
- s[i++] = '-';
-
- s[i] = '\0';
- reverse(s);
-}
-
-void
-ddsnap_mem_monitor(void)
-{
- extern int mmon_interval;
- static int old_maxrss = -1;
- struct rusage ru;
- char buf[128];
-
- if (mmon_interval <= 0) /* No interval? Don't monitor. */
- return;
- if (getrusage(RUSAGE_SELF, &ru) < 0) {
- perror("getrusage() failed");
- mmon_interval = 0;
- return;
- }
- if (ru.ru_maxrss > old_maxrss) {
- /*
- * Go to great lengths to avoid an allocate as a result of
- * this log message.
- */
- strcpy(buf, "WARNING: RSS increased from ");
- itoa(old_maxrss, &buf[strlen(buf)]);
- strcat(buf, " to ");
- itoa(ru.ru_maxrss, &buf[strlen(buf)]);
- strcat(buf, " @ ");
- itoa(time(NULL), &buf[strlen(buf)]);
- strcat(buf, "\n");
- write(2, buf, strlen(buf));
- old_maxrss = ru.ru_maxrss;
- }
-}
-#endif /* DDSNAP_MEM_MONITOR */
-
int snap_server(struct superblock *sb, int listenfd, int getsigfd, int
agentfd, const char *logfile)
{
unsigned maxclients = 100, clients = 0, others = 3;
struct client *clientvec[maxclients];
struct pollfd pollvec[others+maxclients];
int err = 0;
-#ifdef DDSNAP_MEM_MONITOR
- int poll_timeout = -1;
- extern int mmon_interval;
-#endif

pollvec[0] = (struct pollfd){ .fd = listenfd, .events = POLLIN };
pollvec[1] = (struct pollfd){ .fd = getsigfd, .events = POLLIN };
@@ -4307,19 +4235,12 @@
if ((err = prctl(PR_SET_MEMALLOC, 0, 0, 0, 0)))
warn("failed to enter memalloc mode (may deadlock) (error %i, %s)",
errno, strerror(errno));
event_parse_options();
-#ifdef DDSNAP_MEM_MONITOR
- if (mmon_interval > 0)
- poll_timeout = mmon_interval;
- ddsnap_mem_monitor();
-#endif
+
while (1) {
trace(warn("Waiting for activity"););

-#ifdef DDSNAP_MEM_MONITOR
- int activity = poll(pollvec, others+clients, poll_timeout);
-#else
int activity = poll(pollvec, others+clients, -1);
-#endif
+
if (activity < 0) {
if (errno != EINTR)
error("poll failed: %s", strerror(errno));
@@ -4327,13 +4248,7 @@
}

if (!activity) {
-#ifdef DDSNAP_MEM_MONITOR
- ddsnap_mem_monitor();
- if (mmon_interval == 0) /* If we stopped monitoring, */
- poll_timeout = -1; /* kill timeout. */
-#else
printf("waiting...\n");
-#endif
continue;
}

@@ -4547,10 +4462,6 @@
*/
if (mlockall(MCL_CURRENT|MCL_FUTURE))
warn("Unable to lock self into RAM: %s", strerror(errno));
-
-#ifdef DDSNAP_MEM_MONITOR
- ddsnap_mem_monitor();
-#endif

/* should only return on an error */
if ((ret = snap_server(sb, listenfd, getsigfd, agentfd, logfile)) < 0)

Reply all
Reply to author
Forward
0 new messages