summaryrefslogtreecommitdiff
path: root/usr/src/cmd/zoneadmd/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/zoneadmd/log.c')
-rw-r--r--usr/src/cmd/zoneadmd/log.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/usr/src/cmd/zoneadmd/log.c b/usr/src/cmd/zoneadmd/log.c
index 47f25ced72..a4ecc3e1e8 100644
--- a/usr/src/cmd/zoneadmd/log.c
+++ b/usr/src/cmd/zoneadmd/log.c
@@ -960,6 +960,32 @@ logstream_open(const char *logname, const char *stream, logstream_flags_t flags)
return (ls);
}
+static void
+logstream_reset(logstream_t *lsp)
+{
+ custr_t *buf = lsp->ls_cusbuf;
+ custr_t *obuf = lsp->ls_cusobuf;
+
+ (void) memset(lsp, 0, sizeof (*lsp));
+ lsp->ls_cusbuf = buf;
+ lsp->ls_cusobuf = obuf;
+
+ custr_reset(buf);
+ custr_reset(obuf);
+}
+
+static void
+logfile_reset(logfile_t *lfp)
+{
+ custr_t *buf = lfp->lf_cus;
+
+ (void) memset(lfp, 0, sizeof (*lfp));
+ lfp->lf_cus = buf;
+ lfp->lf_fd = -1;
+
+ custr_reset(buf);
+}
+
void
logstream_close(int ls, boolean_t abrupt)
{
@@ -982,7 +1008,7 @@ logstream_close(int ls, boolean_t abrupt)
VERIFY(lsp->ls_stream[0] != '\0');
VERIFY3P(lfp, !=, NULL);
- (void) memset(lsp, 0, sizeof (*lsp));
+ logstream_reset(lsp);
for (i = 0; i < ARRAY_SIZE(streams); i++) {
if (streams[i].ls_logfile == lfp) {
@@ -995,8 +1021,7 @@ logstream_close(int ls, boolean_t abrupt)
close_log(lfp, "close", abrupt);
- (void) memset(lfp, 0, sizeof (*lfp));
- lfp->lf_fd = -1;
+ logfile_reset(lfp);
logstream_unlock();
}