From: Jason Pleau Date: Tue, 21 Apr 2015 03:11:03 +0000 (-0400) Subject: replace mg_iterate_over_connections with a loop with mg_next X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=19c6d7eb88d8f8606d9dac2d87634b3cac5b8a7e;p=ympd.git replace mg_iterate_over_connections with a loop with mg_next --- diff --git a/src/mpd_client.c b/src/mpd_client.c index 5e2d30e..01a38d2 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -274,8 +274,11 @@ void mpd_poll(struct mg_server *s) if (mpd_connection_get_error(mpd.conn) != MPD_ERROR_SUCCESS) { fprintf(stderr, "MPD connection: %s\n", mpd_connection_get_error_message(mpd.conn)); - mg_iterate_over_connections(s, mpd_notify_callback, - (void *)mpd_connection_get_error_message(mpd.conn)); + for (struct mg_connection *c = mg_next(s, NULL); c != NULL; c = mg_next(s, c)) + { + c->callback_param = (void *)mpd_connection_get_error_message(mpd.conn); + mpd_notify_callback(c, MG_POLL); + } mpd.conn_state = MPD_FAILURE; return; } @@ -283,8 +286,11 @@ void mpd_poll(struct mg_server *s) if(mpd.password && !mpd_run_password(mpd.conn, mpd.password)) { fprintf(stderr, "MPD connection: %s\n", mpd_connection_get_error_message(mpd.conn)); - mg_iterate_over_connections(s, mpd_notify_callback, - (void *)mpd_connection_get_error_message(mpd.conn)); + for (struct mg_connection *c = mg_next(s, NULL); c != NULL; c = mg_next(s, c)) + { + c->callback_param = (void *)mpd_connection_get_error_message(mpd.conn); + mpd_notify_callback(c, MG_POLL); + } mpd.conn_state = MPD_FAILURE; return; } @@ -307,7 +313,11 @@ void mpd_poll(struct mg_server *s) case MPD_CONNECTED: mpd.buf_size = mpd_put_state(mpd.buf, &mpd.song_id, &mpd.queue_version); - mg_iterate_over_connections(s, mpd_notify_callback, NULL); + for (struct mg_connection *c = mg_next(s, NULL); c != NULL; c = mg_next(s, c)) + { + c->callback_param = NULL; + mpd_notify_callback(c, MG_POLL); + } break; } }