mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-16 01:03:16 -05:00
Rework error handling in daap_reply_songlist_generic()
Kill a bit of code duplication in the error handling.
This commit is contained in:
parent
cac2c032f6
commit
ac82b176a0
@ -1008,9 +1008,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP song list\n");
|
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP song list\n");
|
||||||
|
|
||||||
daap_send_error(req, tag, "Out of memory");
|
daap_send_error(req, tag, "Out of memory");
|
||||||
|
goto out_list_free;
|
||||||
evbuffer_free(songlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
song = evbuffer_new();
|
song = evbuffer_new();
|
||||||
@ -1019,9 +1017,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP song block\n");
|
DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP song block\n");
|
||||||
|
|
||||||
daap_send_error(req, tag, "Out of memory");
|
daap_send_error(req, tag, "Out of memory");
|
||||||
|
goto out_list_free;
|
||||||
evbuffer_free(songlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The buffer will expand if needed */
|
/* The buffer will expand if needed */
|
||||||
@ -1031,10 +1027,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP song block\n");
|
DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP song block\n");
|
||||||
|
|
||||||
daap_send_error(req, tag, "Out of memory");
|
daap_send_error(req, tag, "Out of memory");
|
||||||
|
goto out_song_free;
|
||||||
evbuffer_free(song);
|
|
||||||
evbuffer_free(songlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
param = evhttp_find_header(query, "meta");
|
param = evhttp_find_header(query, "meta");
|
||||||
@ -1053,9 +1046,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
{
|
{
|
||||||
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(song);
|
goto out_song_free;
|
||||||
evbuffer_free(songlist);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1081,13 +1072,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
DPRINTF(E_LOG, L_DAAP, "Could not start query\n");
|
DPRINTF(E_LOG, L_DAAP, "Could not start query\n");
|
||||||
|
|
||||||
daap_send_error(req, tag, "Could not start query");
|
daap_send_error(req, tag, "Could not start query");
|
||||||
|
goto out_query_free;
|
||||||
free(meta);
|
|
||||||
evbuffer_free(song);
|
|
||||||
evbuffer_free(songlist);
|
|
||||||
if (qp.filter)
|
|
||||||
free(qp.filter);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
want_mikd = 0;
|
want_mikd = 0;
|
||||||
@ -1266,8 +1251,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
|
|
||||||
daap_send_error(req, tag, "Error fetching query results");
|
daap_send_error(req, tag, "Error fetching query results");
|
||||||
db_query_end(&qp);
|
db_query_end(&qp);
|
||||||
evbuffer_free(songlist);
|
goto out_list_free;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oom)
|
if (oom)
|
||||||
@ -1276,8 +1260,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
|
|
||||||
daap_send_error(req, tag, "Out of memory");
|
daap_send_error(req, tag, "Out of memory");
|
||||||
db_query_end(&qp);
|
db_query_end(&qp);
|
||||||
evbuffer_free(songlist);
|
goto out_list_free;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add header to evbuf, add songlist to evbuf */
|
/* Add header to evbuf, add songlist to evbuf */
|
||||||
@ -1301,6 +1284,21 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
evhttp_send_reply(req, HTTP_OK, "OK", evbuf);
|
evhttp_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
out_query_free:
|
||||||
|
if (nmeta > 0)
|
||||||
|
free(meta);
|
||||||
|
|
||||||
|
if (qp.filter)
|
||||||
|
free(qp.filter);
|
||||||
|
|
||||||
|
out_song_free:
|
||||||
|
evbuffer_free(song);
|
||||||
|
|
||||||
|
out_list_free:
|
||||||
|
evbuffer_free(songlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user