mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-28 16:15:57 -05:00
Rework error handling in daap_reply_playlists()
Kill a bit of code duplication in the error handling.
This commit is contained in:
parent
ac82b176a0
commit
e033d35195
@ -1367,9 +1367,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP playlist list\n");
|
||||
|
||||
daap_send_error(req, "aply", "Out of memory");
|
||||
|
||||
evbuffer_free(playlistlist);
|
||||
return;
|
||||
goto out_list_free;
|
||||
}
|
||||
|
||||
playlist = evbuffer_new();
|
||||
@ -1378,9 +1376,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP playlist block\n");
|
||||
|
||||
daap_send_error(req, "aply", "Out of memory");
|
||||
|
||||
evbuffer_free(playlistlist);
|
||||
return;
|
||||
goto out_list_free;
|
||||
}
|
||||
|
||||
/* The buffer will expand if needed */
|
||||
@ -1390,10 +1386,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP playlist block\n");
|
||||
|
||||
daap_send_error(req, "aply", "Out of memory");
|
||||
|
||||
evbuffer_free(playlist);
|
||||
evbuffer_free(playlistlist);
|
||||
return;
|
||||
goto out_pl_free;
|
||||
}
|
||||
|
||||
param = evhttp_find_header(query, "meta");
|
||||
@ -1409,9 +1402,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
{
|
||||
DPRINTF(E_LOG, L_DAAP, "Failed to parse meta parameter in DAAP query\n");
|
||||
|
||||
evbuffer_free(playlist);
|
||||
evbuffer_free(playlistlist);
|
||||
return;
|
||||
goto out_pl_free;
|
||||
}
|
||||
|
||||
memset(&qp, 0, sizeof(struct query_params));
|
||||
@ -1424,13 +1415,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
DPRINTF(E_LOG, L_DAAP, "Could not start query\n");
|
||||
|
||||
daap_send_error(req, "aply", "Could not start query");
|
||||
|
||||
free(meta);
|
||||
evbuffer_free(playlist);
|
||||
evbuffer_free(playlistlist);
|
||||
if (qp.filter)
|
||||
free(qp.filter);
|
||||
return;
|
||||
goto out_query_free;
|
||||
}
|
||||
|
||||
npls = 0;
|
||||
@ -1519,8 +1504,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
|
||||
daap_send_error(req, "aply", "Error fetching query results");
|
||||
db_query_end(&qp);
|
||||
evbuffer_free(playlistlist);
|
||||
return;
|
||||
goto out_list_free;
|
||||
}
|
||||
|
||||
if (oom)
|
||||
@ -1529,8 +1513,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
|
||||
daap_send_error(req, "aply", "Out of memory");
|
||||
db_query_end(&qp);
|
||||
evbuffer_free(playlistlist);
|
||||
return;
|
||||
goto out_list_free;
|
||||
}
|
||||
|
||||
/* Add header to evbuf, add playlistlist to evbuf */
|
||||
@ -1554,6 +1537,19 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
|
||||
}
|
||||
|
||||
evhttp_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
|
||||
return;
|
||||
|
||||
out_query_free:
|
||||
free(meta);
|
||||
if (qp.filter)
|
||||
free(qp.filter);
|
||||
|
||||
out_pl_free:
|
||||
evbuffer_free(playlist);
|
||||
|
||||
out_list_free:
|
||||
evbuffer_free(playlistlist);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user