summaryrefslogtreecommitdiffstats
path: root/lib/zclient.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-09-23 22:26:56 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-09-23 22:26:56 +0200
commit4140ca4d153e8949afd6abc9e00fbbac3d47799c (patch)
treee21a92656dd140a433ce626128fc89801ef926a2 /lib/zclient.c
parentvtysh: Allow display of individual daemons configs (diff)
downloadfrr-4140ca4d153e8949afd6abc9e00fbbac3d47799c.tar.xz
frr-4140ca4d153e8949afd6abc9e00fbbac3d47799c.zip
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.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index 35b18cb95..e071228cc 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;
-
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;
}
@@ -289,7 +288,7 @@ 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->t_write = thread_add_write(zclient->master, zclient_flush_data,
zclient, zclient->sock);
break;
case BUFFER_EMPTY:
@@ -315,7 +314,7 @@ zclient_send_message(struct zclient *zclient)
THREAD_OFF(zclient->t_write);
break;
case BUFFER_PENDING:
- THREAD_WRITE_ON(master, zclient->t_write,
+ THREAD_WRITE_ON(zclient->master, zclient->t_write,
zclient_flush_data, zclient, zclient->sock);
break;
}
@@ -1327,7 +1326,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)
@@ -1337,12 +1336,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;
}
}