Fix the crash issue in free_connections

This commit is contained in:
Kery Wu
2016-01-01 10:32:57 +08:00
parent f09d280af0
commit a0098cfdb9
2 changed files with 4 additions and 8 deletions
+2 -4
View File
@@ -198,10 +198,8 @@ int create_and_bind(const char *addr, const char *port)
static void free_connections(struct ev_loop *loop)
{
struct cork_dllist_item *curr;
for (curr = cork_dllist_start(&connections);
!cork_dllist_is_end(&connections, curr);
curr = curr->next) {
struct cork_dllist_item *curr, *next;
cork_dllist_foreach_void (&connections, curr, next) {
server_t *server = cork_container_of(curr, server_t, entries);
remote_t *remote = server->remote;
close_and_free_server(loop, server);
+2 -4
View File
@@ -205,10 +205,8 @@ static void stat_update_cb(EV_P_ ev_timer *watcher, int revents)
static void free_connections(struct ev_loop *loop)
{
struct cork_dllist_item *curr;
for (curr = cork_dllist_start(&connections);
!cork_dllist_is_end(&connections, curr);
curr = curr->next) {
struct cork_dllist_item *curr, *next;
cork_dllist_foreach_void (&connections, curr, next) {
server_t *server = cork_container_of(curr, server_t, entries);
remote_t *remote = server->remote;
close_and_free_server(loop, server);