lib: don't have log functions change errno

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/lib/log.c b/lib/log.c
index 10a771e..e376205 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -151,6 +151,7 @@
 static void
 vzlog (struct zlog *zl, int priority, const char *format, va_list args)
 {
+  int original_errno = errno;
   struct timestamp_control tsctl;
   tsctl.already_rendered = 0;
 
@@ -169,6 +170,7 @@
       fflush (stderr);
 
       /* In this case we return at here. */
+      errno = original_errno;
       return;
     }
   tsctl.precision = zl->timestamp_precision;
@@ -216,6 +218,8 @@
   if (priority <= zl->maxlvl[ZLOG_DEST_MONITOR])
     vty_log ((zl->record_priority ? zlog_priority[priority] : NULL),
 	     zlog_proto_names[zl->protocol], format, &tsctl, args);
+
+  errno = original_errno;
 }
 
 static char *