Merge pull request #531 from qlyoung/fix-stack-ref

lib: fix access to stack value
This commit is contained in:
Lou Berger 2017-05-15 10:34:38 -04:00 committed by GitHub
commit 4b34151b88
2 changed files with 17 additions and 19 deletions

View File

@ -613,6 +613,7 @@ thread_get (struct thread_master *m, u_char type,
thread->arg = arg; thread->arg = arg;
thread->index = -1; thread->index = -1;
thread->yield = THREAD_YIELD_TIME_SLOT; /* default */ thread->yield = THREAD_YIELD_TIME_SLOT; /* default */
thread->ref = NULL;
/* /*
* So if the passed in funcname is not what we have * So if the passed in funcname is not what we have
@ -829,7 +830,6 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
thread_add_fd (m->write, thread); thread_add_fd (m->write, thread);
} }
pthread_mutex_unlock (&thread->mtx); pthread_mutex_unlock (&thread->mtx);
}
if (t_ptr) if (t_ptr)
{ {
@ -837,6 +837,7 @@ funcname_thread_add_read_write (int dir, struct thread_master *m,
thread->ref = t_ptr; thread->ref = t_ptr;
} }
} }
}
pthread_mutex_unlock (&m->mtx); pthread_mutex_unlock (&m->mtx);
} }
@ -869,15 +870,14 @@ funcname_thread_add_timer_timeval (struct thread_master *m,
monotime(&thread->u.sands); monotime(&thread->u.sands);
timeradd(&thread->u.sands, time_relative, &thread->u.sands); timeradd(&thread->u.sands, time_relative, &thread->u.sands);
pqueue_enqueue(thread, queue); pqueue_enqueue(thread, queue);
}
pthread_mutex_unlock (&thread->mtx);
if (t_ptr) if (t_ptr)
{ {
*t_ptr = thread; *t_ptr = thread;
thread->ref = t_ptr; thread->ref = t_ptr;
} }
} }
pthread_mutex_unlock (&thread->mtx);
}
pthread_mutex_unlock (&m->mtx); pthread_mutex_unlock (&m->mtx);
} }

View File

@ -2633,20 +2633,18 @@ static struct thread_master *vty_master;
static void static void
vty_event (enum event event, int sock, struct vty *vty) vty_event (enum event event, int sock, struct vty *vty)
{ {
struct thread *vty_serv_thread;
switch (event) switch (event)
{ {
case VTY_SERV: case VTY_SERV:
vty_serv_thread = NULL; vector_set_index (Vvty_serv_thread, sock, NULL);
thread_add_read(vty_master, vty_accept, vty, sock, &vty_serv_thread); thread_add_read(vty_master, vty_accept, vty, sock,
vector_set_index (Vvty_serv_thread, sock, vty_serv_thread); (struct thread **) &Vvty_serv_thread->index[sock]);
break; break;
#ifdef VTYSH #ifdef VTYSH
case VTYSH_SERV: case VTYSH_SERV:
vty_serv_thread = NULL; vector_set_index (Vvty_serv_thread, sock, NULL);
thread_add_read(vty_master, vtysh_accept, vty, sock, &vty_serv_thread); thread_add_read(vty_master, vtysh_accept, vty, sock,
vector_set_index (Vvty_serv_thread, sock, vty_serv_thread); (struct thread **) &Vvty_serv_thread->index[sock]);
break; break;
case VTYSH_READ: case VTYSH_READ:
vty->t_read = NULL; vty->t_read = NULL;