summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLou Berger <lberger@labn.net>2017-05-15 16:34:38 +0200
committerGitHub <noreply@github.com>2017-05-15 16:34:38 +0200
commit4b34151b88cf4de40b4b070522e378bed895dcb1 (patch)
treeb6dc0fe32a932f1ac9397cc5c1a28e224dc8489a /lib
parentdoc: fix VARIABLE <> WORD confusion in cli.md (diff)
parentlib: fix access to stack value (diff)
downloadfrr-4b34151b88cf4de40b4b070522e378bed895dcb1.tar.xz
frr-4b34151b88cf4de40b4b070522e378bed895dcb1.zip
Merge pull request #531 from qlyoung/fix-stack-ref
lib: fix access to stack value
Diffstat (limited to 'lib')
-rw-r--r--lib/thread.c22
-rw-r--r--lib/vty.c14
2 files changed, 17 insertions, 19 deletions
diff --git a/lib/thread.c b/lib/thread.c
index e4dbebe1c..aef9ac5cf 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -613,6 +613,7 @@ thread_get (struct thread_master *m, u_char type,
thread->arg = arg;
thread->index = -1;
thread->yield = THREAD_YIELD_TIME_SLOT; /* default */
+ thread->ref = NULL;
/*
* So if the passed in funcname is not what we have
@@ -829,12 +830,12 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
thread_add_fd (m->write, thread);
}
pthread_mutex_unlock (&thread->mtx);
- }
- if (t_ptr)
- {
- *t_ptr = thread;
- thread->ref = t_ptr;
+ if (t_ptr)
+ {
+ *t_ptr = thread;
+ thread->ref = t_ptr;
+ }
}
}
pthread_mutex_unlock (&m->mtx);
@@ -869,14 +870,13 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
monotime(&thread->u.sands);
timeradd(&thread->u.sands, time_relative, &thread->u.sands);
pqueue_enqueue(thread, queue);
+ if (t_ptr)
+ {
+ *t_ptr = thread;
+ thread->ref = t_ptr;
+ }
}
pthread_mutex_unlock (&thread->mtx);
-
- if (t_ptr)
- {
- *t_ptr = thread;
- thread->ref = t_ptr;
- }
}
pthread_mutex_unlock (&m->mtx);
}
diff --git a/lib/vty.c b/lib/vty.c
index 83dc0106f..e490d30a8 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2633,20 +2633,18 @@ static struct thread_master *vty_master;
static void
vty_event (enum event event, int sock, struct vty *vty)
{
- struct thread *vty_serv_thread;
-
switch (event)
{
case VTY_SERV:
- vty_serv_thread = NULL;
- thread_add_read(vty_master, vty_accept, vty, sock, &vty_serv_thread);
- vector_set_index (Vvty_serv_thread, sock, vty_serv_thread);
+ vector_set_index (Vvty_serv_thread, sock, NULL);
+ thread_add_read(vty_master, vty_accept, vty, sock,
+ (struct thread **) &Vvty_serv_thread->index[sock]);
break;
#ifdef VTYSH
case VTYSH_SERV:
- vty_serv_thread = NULL;
- thread_add_read(vty_master, vtysh_accept, vty, sock, &vty_serv_thread);
- vector_set_index (Vvty_serv_thread, sock, vty_serv_thread);
+ vector_set_index (Vvty_serv_thread, sock, NULL);
+ thread_add_read(vty_master, vtysh_accept, vty, sock,
+ (struct thread **) &Vvty_serv_thread->index[sock]);
break;
case VTYSH_READ:
vty->t_read = NULL;