mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-01 02:03:45 -04: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");
|
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP playlist list\n");
|
||||||
|
|
||||||
daap_send_error(req, "aply", "Out of memory");
|
daap_send_error(req, "aply", "Out of memory");
|
||||||
|
goto out_list_free;
|
||||||
evbuffer_free(playlistlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist = evbuffer_new();
|
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");
|
DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP playlist block\n");
|
||||||
|
|
||||||
daap_send_error(req, "aply", "Out of memory");
|
daap_send_error(req, "aply", "Out of memory");
|
||||||
|
goto out_list_free;
|
||||||
evbuffer_free(playlistlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The buffer will expand if needed */
|
/* 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");
|
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP playlist block\n");
|
||||||
|
|
||||||
daap_send_error(req, "aply", "Out of memory");
|
daap_send_error(req, "aply", "Out of memory");
|
||||||
|
goto out_pl_free;
|
||||||
evbuffer_free(playlist);
|
|
||||||
evbuffer_free(playlistlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
param = evhttp_find_header(query, "meta");
|
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");
|
DPRINTF(E_LOG, L_DAAP, "Failed to parse meta parameter in DAAP query\n");
|
||||||
|
|
||||||
evbuffer_free(playlist);
|
goto out_pl_free;
|
||||||
evbuffer_free(playlistlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&qp, 0, sizeof(struct query_params));
|
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");
|
DPRINTF(E_LOG, L_DAAP, "Could not start query\n");
|
||||||
|
|
||||||
daap_send_error(req, "aply", "Could not start query");
|
daap_send_error(req, "aply", "Could not start query");
|
||||||
|
goto out_query_free;
|
||||||
free(meta);
|
|
||||||
evbuffer_free(playlist);
|
|
||||||
evbuffer_free(playlistlist);
|
|
||||||
if (qp.filter)
|
|
||||||
free(qp.filter);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
npls = 0;
|
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");
|
daap_send_error(req, "aply", "Error fetching query results");
|
||||||
db_query_end(&qp);
|
db_query_end(&qp);
|
||||||
evbuffer_free(playlistlist);
|
goto out_list_free;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oom)
|
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");
|
daap_send_error(req, "aply", "Out of memory");
|
||||||
db_query_end(&qp);
|
db_query_end(&qp);
|
||||||
evbuffer_free(playlistlist);
|
goto out_list_free;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add header to evbuf, add playlistlist to evbuf */
|
/* 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);
|
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
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user