lib: zclient.c remove extern struct thread_master *

zclient.c depended upon link time inclusion of a
extern struct thread_master *master.  This is a violation of the
namespace of the calling daemon.  If a library needs the pointer
pass it in and save it for future use.

This code change also makes the zclient code consistent with
the other lib functions that need to schedule work on your behalf

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/lib/zclient.c b/lib/zclient.c
index 0ce46fe..bfff9a3 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -39,8 +39,6 @@
 /* Prototype for event manager. */
 static void zclient_event (enum event, struct zclient *);
 
-extern struct thread_master *master;
-
 const char *zclient_serv_path = NULL;
 
 /* This file local debug flag. */
@@ -48,7 +46,7 @@
 
 /* Allocate zclient structure. */
 struct zclient *
-zclient_new ()
+zclient_new (struct thread_master *master)
 {
   struct zclient *zclient;
   zclient = XCALLOC (MTYPE_ZCLIENT, sizeof (struct zclient));
@@ -56,6 +54,7 @@
   zclient->ibuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
   zclient->obuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
   zclient->wb = buffer_new(0);
+  zclient->master = master;
 
   return zclient;
 }
@@ -258,8 +257,8 @@
       return zclient_failed(zclient);
       break;
     case BUFFER_PENDING:
-      zclient->t_write = thread_add_write(master, zclient_flush_data,
-					  zclient, zclient->sock);
+      zclient->t_write = thread_add_write (zclient->master, zclient_flush_data,
+					   zclient, zclient->sock);
       break;
     case BUFFER_EMPTY:
       break;
@@ -284,8 +283,8 @@
       THREAD_OFF(zclient->t_write);
       break;
     case BUFFER_PENDING:
-      THREAD_WRITE_ON(master, zclient->t_write,
-		      zclient_flush_data, zclient, zclient->sock);
+      THREAD_WRITE_ON (zclient->master, zclient->t_write,
+		       zclient_flush_data, zclient, zclient->sock);
       break;
     }
   return 0;
@@ -1092,7 +1091,7 @@
     case ZCLIENT_SCHEDULE:
       if (! zclient->t_connect)
 	zclient->t_connect =
-	  thread_add_event (master, zclient_connect, zclient, 0);
+	  thread_add_event (zclient->master, zclient_connect, zclient, 0);
       break;
     case ZCLIENT_CONNECT:
       if (zclient->fail >= 10)
@@ -1102,12 +1101,12 @@
 		   zclient->fail < 3 ? 10 : 60);
       if (! zclient->t_connect)
 	zclient->t_connect = 
-	  thread_add_timer (master, zclient_connect, zclient,
+	  thread_add_timer (zclient->master, zclient_connect, zclient,
 			    zclient->fail < 3 ? 10 : 60);
       break;
     case ZCLIENT_READ:
       zclient->t_read = 
-	thread_add_read (master, zclient_read, zclient, zclient->sock);
+	thread_add_read (zclient->master, zclient_read, zclient, zclient->sock);
       break;
     }
 }
diff --git a/lib/zclient.h b/lib/zclient.h
index 3490b32..aa935c1 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -40,6 +40,9 @@
 /* Structure for the zebra client. */
 struct zclient
 {
+  /* The thread master we schedule ourselves on */
+  struct thread_master *master;
+
   /* Socket to zebra daemon. */
   int sock;
 
@@ -132,7 +135,7 @@
 };
 
 /* Prototypes of zebra client service functions. */
-extern struct zclient *zclient_new (void);
+extern struct zclient *zclient_new (struct thread_master *);
 extern void zclient_init (struct zclient *, int);
 extern int zclient_start (struct zclient *);
 extern void zclient_stop (struct zclient *);