raop: Fix check for invalid file descriptor

file descriptor 0 is valid

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
This commit is contained in:
Peter Meerwald-Stadler 2017-03-07 14:29:12 +01:00
parent 6b7b70c472
commit 74abce331b
2 changed files with 16 additions and 16 deletions

View file

@ -968,10 +968,10 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
break; break;
annonce_error: annonce_error:
if (c->udp_cfd > 0) if (c->udp_cfd >= 0)
pa_close(c->udp_cfd); pa_close(c->udp_cfd);
c->udp_cfd = -1; c->udp_cfd = -1;
if (c->udp_tfd > 0) if (c->udp_tfd >= 0)
pa_close(c->udp_tfd); pa_close(c->udp_tfd);
c->udp_tfd = -1; c->udp_tfd = -1;
@ -1073,11 +1073,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
break; break;
setup_error: setup_error:
if (c->tcp_sfd > 0) if (c->tcp_sfd >= 0)
pa_close(c->tcp_sfd); pa_close(c->tcp_sfd);
c->tcp_sfd = -1; c->tcp_sfd = -1;
if (c->udp_sfd > 0) if (c->udp_sfd >= 0)
pa_close(c->udp_sfd); pa_close(c->udp_sfd);
c->udp_sfd = -1; c->udp_sfd = -1;
@ -1135,11 +1135,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
case STATE_TEARDOWN: { case STATE_TEARDOWN: {
pa_log_debug("RAOP: TEARDOWN"); pa_log_debug("RAOP: TEARDOWN");
if (c->tcp_sfd > 0) if (c->tcp_sfd >= 0)
pa_close(c->tcp_sfd); pa_close(c->tcp_sfd);
c->tcp_sfd = -1; c->tcp_sfd = -1;
if (c->udp_sfd > 0) if (c->udp_sfd >= 0)
pa_close(c->udp_sfd); pa_close(c->udp_sfd);
c->udp_sfd = -1; c->udp_sfd = -1;
@ -1163,11 +1163,11 @@ static void rtsp_stream_cb(pa_rtsp_client *rtsp, pa_rtsp_state_t state, pa_rtsp_
c->is_recording = false; c->is_recording = false;
if (c->tcp_sfd > 0) if (c->tcp_sfd >= 0)
pa_close(c->tcp_sfd); pa_close(c->tcp_sfd);
c->tcp_sfd = -1; c->tcp_sfd = -1;
if (c->udp_sfd > 0) if (c->udp_sfd >= 0)
pa_close(c->udp_sfd); pa_close(c->udp_sfd);
c->udp_sfd = -1; c->udp_sfd = -1;
@ -1507,11 +1507,11 @@ bool pa_raop_client_is_alive(pa_raop_client *c) {
switch (c->protocol) { switch (c->protocol) {
case PA_RAOP_PROTOCOL_TCP: case PA_RAOP_PROTOCOL_TCP:
if (c->tcp_sfd > 0) if (c->tcp_sfd >= 0)
return true; return true;
break; break;
case PA_RAOP_PROTOCOL_UDP: case PA_RAOP_PROTOCOL_UDP:
if (c->udp_sfd > 0) if (c->udp_sfd >= 0)
return true; return true;
break; break;
default: default:
@ -1531,11 +1531,11 @@ bool pa_raop_client_can_stream(pa_raop_client *c) {
switch (c->protocol) { switch (c->protocol) {
case PA_RAOP_PROTOCOL_TCP: case PA_RAOP_PROTOCOL_TCP:
if (c->tcp_sfd > 0 && c->is_recording) if (c->tcp_sfd >= 0 && c->is_recording)
return true; return true;
break; break;
case PA_RAOP_PROTOCOL_UDP: case PA_RAOP_PROTOCOL_UDP:
if (c->udp_sfd > 0 && c->is_recording) if (c->udp_sfd >= 0 && c->is_recording)
return true; return true;
break; break;
default: default:
@ -1557,14 +1557,14 @@ int pa_raop_client_stream(pa_raop_client *c) {
switch (c->protocol) { switch (c->protocol) {
case PA_RAOP_PROTOCOL_TCP: case PA_RAOP_PROTOCOL_TCP:
if (c->tcp_sfd > 0 && !c->is_recording) { if (c->tcp_sfd >= 0 && !c->is_recording) {
c->is_recording = true; c->is_recording = true;
c->is_first_packet = true; c->is_first_packet = true;
c->sync_count = 0; c->sync_count = 0;
} }
break; break;
case PA_RAOP_PROTOCOL_UDP: case PA_RAOP_PROTOCOL_UDP:
if (c->udp_sfd > 0 && !c->is_recording) { if (c->udp_sfd >= 0 && !c->is_recording) {
c->is_recording = true; c->is_recording = true;
c->is_first_packet = true; c->is_first_packet = true;
c->sync_count = 0; c->sync_count = 0;
@ -1722,7 +1722,7 @@ pa_volume_t pa_raop_client_adjust_volume(pa_raop_client *c, pa_volume_t volume)
void pa_raop_client_handle_oob_packet(pa_raop_client *c, const int fd, const uint8_t packet[], ssize_t size) { void pa_raop_client_handle_oob_packet(pa_raop_client *c, const int fd, const uint8_t packet[], ssize_t size) {
pa_assert(c); pa_assert(c);
pa_assert(fd > 0); pa_assert(fd >= 0);
pa_assert(packet); pa_assert(packet);
if (c->protocol == PA_RAOP_PROTOCOL_UDP) { if (c->protocol == PA_RAOP_PROTOCOL_UDP) {

View file

@ -247,7 +247,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
if (u->rtpoll_item) { if (u->rtpoll_item) {
pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, &nbfds); pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, &nbfds);
for (i = 0; i < nbfds; i++) { for (i = 0; i < nbfds; i++) {
if (pollfd && pollfd->fd > 0) if (pollfd && pollfd->fd >= 0)
pa_close(pollfd->fd); pa_close(pollfd->fd);
pollfd++; pollfd++;
} }