[pve-devel] r6409 - in pve-cluster/trunk/data: . PVE src
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu Aug 4 08:03:20 CEST 2011
Author: dietmar
Date: 2011-08-04 08:03:20 +0200 (Thu, 04 Aug 2011)
New Revision: 6409
Modified:
pve-cluster/trunk/data/ChangeLog
pve-cluster/trunk/data/PVE/Cluster.pm
pve-cluster/trunk/data/src/logger.c
pve-cluster/trunk/data/src/logger.h
pve-cluster/trunk/data/src/logtest.c
pve-cluster/trunk/data/src/server.c
Log:
* src/*: remove syslog_cache (not needed)
Modified: pve-cluster/trunk/data/ChangeLog
===================================================================
--- pve-cluster/trunk/data/ChangeLog 2011-08-04 05:34:05 UTC (rev 6408)
+++ pve-cluster/trunk/data/ChangeLog 2011-08-04 06:03:20 UTC (rev 6409)
@@ -1,3 +1,7 @@
+2011-08-04 Proxmox Support Team <support at proxmox.com>
+
+ * src/*: remove syslog_cache (not needed)
+
2011-08-03 Proxmox Support Team <support at proxmox.com>
* src/cfs-plug-func.c: simple plugin to view data returned by
Modified: pve-cluster/trunk/data/PVE/Cluster.pm
===================================================================
--- pve-cluster/trunk/data/PVE/Cluster.pm 2011-08-04 05:34:05 UTC (rev 6408)
+++ pve-cluster/trunk/data/PVE/Cluster.pm 2011-08-04 06:03:20 UTC (rev 6409)
@@ -339,15 +339,6 @@
return &$ipcc_send_rec(8, $bindata);
};
-my $ipcc_get_system_log = sub {
- my ($user, $max) = @_;
-
- $max = 0 if !defined($max);
-
- my $bindata = pack "VVVVZ*", $max, 0, 0, 0, ($user || "");
- return &$ipcc_send_rec(9, $bindata);
-};
-
my $ccache = {};
sub cfs_update {
@@ -644,12 +635,6 @@
return &$ipcc_get_cluster_log($user, $max);
}
-sub get_system_log {
- my ($user, $max) = @_;
-
- return &$ipcc_get_system_log($user, $max);
-}
-
my $file_info = {};
sub cfs_register_file {
Modified: pve-cluster/trunk/data/src/logger.c
===================================================================
--- pve-cluster/trunk/data/src/logger.c 2011-08-04 05:34:05 UTC (rev 6408)
+++ pve-cluster/trunk/data/src/logger.c 2011-08-04 06:03:20 UTC (rev 6409)
@@ -645,245 +645,3 @@
clusterlog_insert(cl, entry);
}
-struct syslog_cache {
- clog_base_t *base;
- time_t last_update;
- int fd;
- char readbuf[8192*8];
- size_t rest;
- size_t filesize;
- ino_t st_ino;
- off_t st_size;
-};
-
-void
-syslog_cache_destroy(syslog_cache_t *slc)
-{
- g_return_if_fail(slc != NULL);
-
- if (slc->fd >= 0)
- close(slc->fd);
-
- if (slc->base)
- g_free(slc->base);
-
- g_free(slc);
-}
-
-static void
-syslog_cache_reset(syslog_cache_t *slc, gboolean clear)
-{
- g_return_if_fail(slc != NULL);
-
- if (slc->fd >= 0) {
- close(slc->fd);
- slc->fd = -1;
- }
-
- if (clear)
- slc->base->cpos = 0;
-
- slc->rest = 0;
- slc->filesize = 0;
- slc->st_ino = 0;
- slc->st_size = 0;
-}
-
-syslog_cache_t *
-syslog_cache_new(void)
-{
- syslog_cache_t *slc = g_new0(syslog_cache_t, 1);
- if (!slc)
- return NULL;
-
- if (!(slc->base = clog_new(0)))
- goto fail;
-
- slc->fd = -1;
- return slc;
-
-fail:
- syslog_cache_destroy(slc);
- return NULL;
-
-}
-
-void
-syslog_cache_dump(
- syslog_cache_t *slc,
- GString *str,
- const char *user,
- guint max_entries)
-{
- g_return_if_fail(slc != NULL);
-
- clog_dump_json(slc->base, str, user, max_entries);
-}
-
-gboolean
-syslog_parse_line(char *line, struct tm *tm, clog_entry_t *entry)
-{
- char *p = line;
-
- if (!(tm && p && *p))
- return FALSE;
-
- if (!(p = strptime(p, "%b %d %T ", tm)))
- goto fail;
-
- time_t date = mktime(tm);
-
- uint8_t priority = 6;
- if (*p && *p >= '0' && *p <= '7' && *(p+1) == 32) {
- priority = *p - '0';
- p+=2;
- while (*p && isblank(*p)) p++;
- }
-
- char *host = p;
- while (*p && !isblank(*p)) p++;
-
- if (!*p)
- goto fail;
-
- *p++ = 0;
-
- while (*p && isblank(*p)) p++;
-
- char *tag = p;
- while (*p && (*p != ':') && (*p != '[')) p++;
-
- uint32_t pid = 0;
- if (*p == '[') {
- *p++ = 0;
- while (isdigit (*p)) {
- pid = pid*10 + *p - '0';
- p++;
- }
- if (*p != ']')
- goto fail;
- p++;
- }
-
- if (*p != ':') /* missing collon */
- goto fail;
-
- *p++ = 0;
- while (*p && isblank(*p)) p++;
-
- char *msg = p;
-
- char *ident = NULL;
- if (*p == '<') {
- p++;
- ident = p;
- char c;
- while ((c = *p) && !isblank(c) && c != '>') { p++; };
- if (*p == '>') {
- *p++= 0;
- while (*p && isblank(*p)) p++;
- msg = p;
- } else {
- ident = NULL;
- }
- }
-
- if (ident && ident[0]) {
- clog_pack(entry, host, ident, tag, pid, date, priority, msg);
- } else {
- clog_pack(entry, host, "", tag, pid, date, priority, msg);
- }
-
- return TRUE;
-
-fail:
- return FALSE;
-}
-
-void
-syslog_cache_update(syslog_cache_t *slc)
-{
- g_return_if_fail(slc != NULL);
-
- time_t ctime = time(NULL);
- if (slc->last_update >= ctime) /* skip frequent updates */
- return;
-
- slc->last_update = ctime;
-
- int fd = slc->fd;
-
- if (fd >= 0) {
- struct stat stbuf;
- if ((fstat(fd, &stbuf)) != 0) {
- syslog_cache_reset(slc, TRUE);
- return;
- }
-
- if (stbuf.st_size < slc->st_size)
- syslog_cache_reset(slc, TRUE);
- }
-
- const char *filename = "/var/log/syslog";
-
- if (fd < 0) {
- if ((fd = open(filename, O_RDONLY)) == -1)
- return;
- struct stat stbuf;
- if ((fstat(fd, &stbuf)) != 0)
- return;
- slc->fd = fd;
- slc->st_ino = stbuf.st_ino;
- slc->st_size = stbuf.st_size;
- }
-
- struct tm tm;
- localtime_r(&ctime, &tm);
-
- clog_entry_t *entry = alloca(CLOG_MAX_ENTRY_SIZE);
-
- ssize_t n;
- char *start = slc->readbuf;
-
- while ((n = safe_read(fd, slc->readbuf + slc->rest, sizeof(slc->readbuf) - slc->rest)) > 0) {
- char *end = slc->readbuf + slc->rest + n;
- char *next = start;
- slc->filesize += n;
-
- do {
- while (next < end && *next && *next != '\n')
- next++;
-
- if (next == end)
- break;
-
- *next++ = 0;
- if ((next-start) < SYSLOG_MAX_LINE_LENGTH) {
- if (syslog_parse_line(start, &tm, entry))
- clog_copy(slc->base, entry);
- }
- start = next;
-
- } while (1);
-
- slc->rest = end - start;
-
- /* simply skip large blocks */
- if (slc->rest >= SYSLOG_MAX_LINE_LENGTH)
- slc->rest = 0;
-
- memmove(slc->readbuf, start, slc->rest);
-
- start = slc->readbuf;
- }
-
- if (n < 0)
- syslog_cache_reset(slc, TRUE);
-
-
- struct stat stbuf;
- if ((stat(filename, &stbuf)) == 0) {
- if (stbuf.st_ino != slc->st_ino)
- syslog_cache_reset(slc, FALSE);
- }
-}
Modified: pve-cluster/trunk/data/src/logger.h
===================================================================
--- pve-cluster/trunk/data/src/logger.h 2011-08-04 05:34:05 UTC (rev 6408)
+++ pve-cluster/trunk/data/src/logger.h 2011-08-04 06:03:20 UTC (rev 6409)
@@ -28,8 +28,6 @@
typedef struct clusterlog clusterlog_t;
-typedef struct syslog_cache syslog_cache_t;
-
typedef struct {
uint32_t prev;
uint32_t next;
@@ -86,22 +84,6 @@
int count,
int local_index);
-syslog_cache_t *
-syslog_cache_new(void);
-
-void
-syslog_cache_destroy(syslog_cache_t *slc);
-
-void
-syslog_cache_update(syslog_cache_t *slc);
-
-void
-syslog_cache_dump(
- syslog_cache_t *slc,
- GString *str,
- const char *user,
- guint max_entries);
-
clog_base_t *
clog_new(uint32_t size);
Modified: pve-cluster/trunk/data/src/logtest.c
===================================================================
--- pve-cluster/trunk/data/src/logtest.c 2011-08-04 05:34:05 UTC (rev 6408)
+++ pve-cluster/trunk/data/src/logtest.c 2011-08-04 06:03:20 UTC (rev 6409)
@@ -49,19 +49,6 @@
uint32_t pid = getpid();
-#if 0
- syslog_cache_t *slc = syslog_cache_new();
-
- for (int i = 0; i < 2000; i++) {
- syslog_cache_update(slc);
- syslog_cache_update(slc);
- sleep(1);
- }
-
- syslog_cache_destroy(slc);
- exit(0);
-#endif
-
#if 1
clusterlog_t *cl3 = clusterlog_new();
Modified: pve-cluster/trunk/data/src/server.c
===================================================================
--- pve-cluster/trunk/data/src/server.c 2011-08-04 05:34:05 UTC (rev 6408)
+++ pve-cluster/trunk/data/src/server.c 2011-08-04 06:03:20 UTC (rev 6409)
@@ -47,7 +47,6 @@
static qb_ipcs_service_t* s1;
static GString *outbuf;
static memdb_t *memdb;
-static syslog_cache_t *syslog_cache;
typedef struct {
struct qb_ipc_request_header req_header;
@@ -280,7 +279,7 @@
result = -EINVAL;
}
}
- } else if (req_pt->id == 8 || req_pt->id == 9) {
+ } else if (req_pt->id == 8) {
cfs_log_get_request_header_t *rh =
(cfs_log_get_request_header_t *)data;
@@ -295,11 +294,7 @@
char *user = data + sizeof(cfs_log_get_request_header_t);
uint32_t max = rh->max_entries ? rh->max_entries : 50;
- if (req_pt->id == 8)
- cfs_cluster_log_dump(outbuf, user, max);
- else
- syslog_cache_dump(syslog_cache, outbuf, user, max);
-
+ cfs_cluster_log_dump(outbuf, user, max);
result = 0;
}
} else if (req_pt->id == 10) {
@@ -394,10 +389,8 @@
static void timer_job(void *data)
{
+ /* we currently do nothing here */
- if (syslog_cache)
- syslog_cache_update(syslog_cache);
-
qb_loop_timer_handle th;
qb_loop_timer_add(loop, QB_LOOP_LOW, 1000000000, NULL, timer_job, &th);
}
@@ -428,8 +421,6 @@
memdb = db;
- syslog_cache = syslog_cache_new();
-
outbuf = g_string_sized_new(8192*8);
if (!(loop = qb_loop_create())) {
@@ -478,9 +469,4 @@
g_string_free(outbuf, TRUE);
outbuf = NULL;
}
-
- if (syslog_cache) {
- syslog_cache_destroy(syslog_cache);
- syslog_cache = NULL;
- }
}
More information about the pve-devel
mailing list