[stgt] [PATCH 2/3] few logger fixes
Alexander Nezhinsky
alexandern at Voltaire.COM
Thu Jun 3 15:23:10 CEST 2010
added initialization and safety checks for the logarea pointer
Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
---
usr/log.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/usr/log.c b/usr/log.c
index 305e14f..be9b0c2 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -42,7 +42,7 @@
#define logdbg(file, fmt, args...) do {} while (0)
#endif
-static struct logarea *la;
+static struct logarea *la = NULL;
static char *log_name;
int is_debug = 0;
static pid_t pid;
@@ -131,10 +131,13 @@ static int logarea_init (int size)
static void free_logarea (void)
{
+ if (!la)
+ return;
semctl(la->semid, 0, IPC_RMID, la->semarg);
shmdt(la->buff);
shmdt(la->start);
shmdt(la);
+ la = NULL;
}
#if LOGDBG
@@ -308,6 +311,9 @@ static void log_flush(void)
{
struct sembuf ops;
+ if (!la)
+ return;
+
while (!la->empty) {
ops.sem_num = 0;
ops.sem_flg = 0;
--
1.6.5
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list