summaryrefslogtreecommitdiffstats
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-09-24 09:25:19 -0400
committerPaul Jakma <paul@quagga.net>2015-10-27 10:53:21 +0000
commit7125293d65d73a451ec203c8c1630c236171f5a3 (patch)
treef9d118c9a8f8374d69fb9c75c87531a2ca478fb2 /lib/zclient.c
parentfd1c1a133af47ae5533a5ed41b73ff62e7aa1058 (diff)
downloadquagga-7125293d65d73a451ec203c8c1630c236171f5a3.tar.bz2
quagga-7125293d65d73a451ec203c8c1630c236171f5a3.tar.xz
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>
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 0ce46fef..bfff9a36 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -39,8 +39,6 @@ enum event {ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT};
/* 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 @@ int zclient_debug = 0;
/* 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_new ()
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 @@ zclient_flush_data(struct thread *thread)
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 @@ zclient_send_message(struct zclient *zclient)
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 @@ zclient_event (enum event event, struct zclient *zclient)
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_event (enum event event, struct zclient *zclient)
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;
}
}