Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
webui: http streaming - cosmetic changes, check getsockopt return code
  • Loading branch information
perexg committed Oct 26, 2014
1 parent 73f781e commit 68f7aca
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/webui/webui.c
Expand Up @@ -262,23 +262,22 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch,
ts.tv_nsec = tp.tv_usec * 1000;

if(pthread_cond_timedwait(&sq->sq_cond, &sq->sq_mutex, &ts) == ETIMEDOUT) {
timeouts++;

//Check socket status
getsockopt(hc->hc_fd, SOL_SOCKET, SO_ERROR, (char *)&err, &errlen);
if (err) {
tvhlog(LOG_DEBUG, "webui", "Stop streaming %s, client hung up", hc->hc_url_orig);
run = 0;
} else if(timeouts >= grace) {
tvhlog(LOG_WARNING, "webui", "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig);
run = 0;
}
timeouts++;

/* Check socket status */
if (getsockopt(hc->hc_fd, SOL_SOCKET, SO_ERROR, (char *)&err, &errlen) || err) {
tvhlog(LOG_DEBUG, "webui", "Stop streaming %s, client hung up", hc->hc_url_orig);
run = 0;
} else if(timeouts >= grace) {
tvhlog(LOG_WARNING, "webui", "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig);
run = 0;
}
}
pthread_mutex_unlock(&sq->sq_mutex);
continue;
}

timeouts = 0; //Reset timeout counter
timeouts = 0; /* Reset timeout counter */
TAILQ_REMOVE(&sq->sq_queue, sm, sm_link);
pthread_mutex_unlock(&sq->sq_mutex);

Expand Down

0 comments on commit 68f7aca

Please sign in to comment.