WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Make xenstored reopen its trace file on SIGHUP. This all

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Make xenstored reopen its trace file on SIGHUP. This allows one to rotate the
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 07 Nov 2005 13:08:06 +0000
Delivery-date: Mon, 07 Nov 2005 13:08:19 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 19a226d8db165868406ba983b0bae60b9e80f14d
# Parent  1f57d567cf4b4d7d7f53bf2bb8bb11168840298b
Make xenstored reopen its trace file on SIGHUP.  This allows one to rotate the
logs beneath the daemon.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 1f57d567cf4b -r 19a226d8db16 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Mon Nov  7 11:05:15 2005
+++ b/tools/xenstore/xenstored_core.c   Mon Nov  7 11:28:53 2005
@@ -56,6 +56,7 @@
 static bool verbose;
 LIST_HEAD(connections);
 static int tracefd = -1;
+static char *tracefile = NULL;
 static TDB_CONTEXT *tdb_ctx;
 
 #ifdef TESTING
@@ -242,6 +243,21 @@
        talloc_free(str);
 }
 
+void reopen_log()
+{
+       if (!tracefile)
+               return;
+
+       if (tracefd > 0)
+               close(tracefd);
+       tracefd = open(tracefile, O_WRONLY|O_CREAT|O_APPEND, 0600);
+       if (tracefd < 0) {
+               perror("Could not open tracefile");
+               return;
+       }
+       write(tracefd, "\n***\n", strlen("\n***\n"));
+}
+
 static bool write_messages(struct connection *conn)
 {
        int ret;
@@ -1498,11 +1514,7 @@
                        outputpid = true;
                        break;
                case 'T':
-                       tracefd = open(optarg, O_WRONLY|O_CREAT|O_APPEND, 0600);
-                       if (tracefd < 0)
-                               barf_perror("Could not open tracefile %s",
-                                           optarg);
-                        write(tracefd, "\n***\n", strlen("\n***\n"));
+                       tracefile = optarg;
                        break;
                case 'V':
                        verbose = true;
@@ -1511,6 +1523,8 @@
        }
        if (optind != argc)
                barf("%s: No arguments desired", argv[0]);
+
+       reopen_log();
 
        if (dofork) {
                openlog("xenstored", 0, LOG_DAEMON);
@@ -1577,6 +1591,8 @@
                close(STDOUT_FILENO);
                close(STDERR_FILENO);
        }
+
+       signal(SIGHUP, reopen_log);
 
 #ifdef TESTING
        signal(SIGUSR1, stop_failtest);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Make xenstored reopen its trace file on SIGHUP. This allows one to rotate the, Xen patchbot -unstable <=