struct listnode *node, *nnode;
struct peer *peer;
- if ((bm->process_main_queue == NULL) ||
- (bm->process_rsclient_queue == NULL))
- bgp_process_queue_init();
-
/* Stop the processing of queued work. Enqueue shall continue */
work_queue_plug(bm->process_main_queue);
work_queue_plug(bm->process_rsclient_queue);
void
bgp_process_queue_init (void)
{
- bm->process_main_queue
- = work_queue_new (bm->master, "process_main_queue");
- bm->process_rsclient_queue
- = work_queue_new (bm->master, "process_rsclient_queue");
-
+ if (!bm->process_main_queue)
+ {
+ bm->process_main_queue
+ = work_queue_new (bm->master, "process_main_queue");
+ }
+
+ if (!bm->process_rsclient_queue)
+ {
+ bm->process_rsclient_queue
+ = work_queue_new (bm->master, "process_rsclient_queue");
+ }
+
if ( !(bm->process_main_queue && bm->process_rsclient_queue) )
{
zlog_err ("%s: Failed to allocate work queue", __func__);
/* already scheduled for processing? */
if (CHECK_FLAG (rn->flags, BGP_NODE_PROCESS_SCHEDULED))
return;
-
- if ( (bm->process_main_queue == NULL) ||
- (bm->process_rsclient_queue == NULL) )
- bgp_process_queue_init ();
-
+
pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
sizeof (struct bgp_process_queue));
if (!pqnode)
{
struct bgp_process_queue *pqnode;
- if ( (bm->process_main_queue == NULL) ||
- (bm->process_rsclient_queue == NULL) )
- bgp_process_queue_init ();
-
pqnode = XCALLOC (MTYPE_BGP_PROCESS_QUEUE,
sizeof (struct bgp_process_queue));
if (!pqnode)
if (srcfilter->usmap.name)
XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->usmap.name);
+
+ if (src->host)
+ XFREE(MTYPE_BGP_PEER_HOST, src->host);
+ src->host = NULL;
}
static void
UPDGRP_GLOBAL_STAT (updgrp, updgrps_created) += 1;
+ conf_release(&tmp_conf, paf->afi, paf->safi);
return updgrp;
}
if (peer->notify.data)
XFREE(MTYPE_TMP, peer->notify.data);
+ if (peer->clear_node_queue)
+ work_queue_free(peer->clear_node_queue);
+
bgp_sync_delete (peer);
if (peer->conf_if)
if (list_isempty(bm->bgp))
bgp_close ();
+ thread_master_free_unused(bm->master);
bgp_unlock(bgp); /* initial reference */
return 0;
bm->port = BGP_PORT_DEFAULT;
bm->master = thread_master_create ();
bm->start_time = bgp_clock ();
+
+ bgp_process_queue_init();
}
thread_array[thread->u.fd] = thread;
}
+/* Thread list is empty or not. */
+static int
+thread_empty (struct thread_list *list)
+{
+ return list->head ? 0 : 1;
+}
+
+/* Delete top of the list and return it. */
+static struct thread *
+thread_trim_head (struct thread_list *list)
+{
+ if (!thread_empty (list))
+ return thread_list_delete (list, list->head);
+ return NULL;
+}
+
/* Move thread to unuse list. */
static void
thread_add_unuse (struct thread_master *m, struct thread *thread)
pqueue_delete(queue);
}
+/*
+ * thread_master_free_unused
+ *
+ * As threads are finished with they are put on the
+ * unuse list for later reuse.
+ * If we are shutting down, Free up unused threads
+ * So we can see if we forget to shut anything off
+ */
+void
+thread_master_free_unused (struct thread_master *m)
+{
+ struct thread *t;
+ while ((t = thread_trim_head(&m->unuse)) != NULL)
+ {
+ XFREE(MTYPE_THREAD, t);
+ }
+}
+
/* Stop thread scheduler. */
void
thread_master_free (struct thread_master *m)
}
}
-/* Thread list is empty or not. */
-static int
-thread_empty (struct thread_list *list)
-{
- return list->head ? 0 : 1;
-}
-
-/* Delete top of the list and return it. */
-static struct thread *
-thread_trim_head (struct thread_list *list)
-{
- if (!thread_empty (list))
- return thread_list_delete (list, list->head);
- return NULL;
-}
-
/* Return remain time in second. */
unsigned long
thread_timer_remain_second (struct thread *thread)
/* Prototypes. */
extern struct thread_master *thread_master_create (void);
extern void thread_master_free (struct thread_master *);
+extern void thread_master_free_unused(struct thread_master *);
extern struct thread *funcname_thread_add_read (struct thread_master *,
int (*)(struct thread *),
if (sysctl (mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0)
{
zlog (NULL, LOG_WARNING, "sysctl error by %s", safe_strerror (errno));
+ XFREE(MTYPE_TMP, ref);
return;
}
if (sysctl (mib, MIBSIZ, buf, &bufsiz, NULL, 0) < 0)
{
zlog_warn ("sysctl() fail by %s", safe_strerror (errno));
+ XFREE(MTYPE_TMP, ref);
return;
}