HTSP: Handle partial write()s
This commit is contained in:
parent
a9692b9514
commit
d5deb9d19d
1 changed files with 19 additions and 13 deletions
|
@ -1469,24 +1469,30 @@ htsp_write_scheduler(void *aux)
|
|||
|
||||
r = htsmsg_binary_serialize(hm->hm_msg, &dptr, &dlen, INT32_MAX);
|
||||
|
||||
#if 0
|
||||
if(hm->hm_pktref) {
|
||||
usleep(hm->hm_payloadsize * 3);
|
||||
}
|
||||
#endif
|
||||
htsp_msg_destroy(hm);
|
||||
|
||||
/* ignore return value */
|
||||
r = write(htsp->htsp_fd, dptr, dlen);
|
||||
if(r != dlen)
|
||||
tvhlog(LOG_INFO, "htsp", "%s: Write error -- %s",
|
||||
htsp->htsp_logname, strerror(errno));
|
||||
free(dptr);
|
||||
|
||||
void *freeme = dptr;
|
||||
|
||||
while(dlen > 0) {
|
||||
r = write(htsp->htsp_fd, dptr, dlen);
|
||||
if(r < 1) {
|
||||
tvhlog(LOG_INFO, "htsp", "%s: Write error -- %s",
|
||||
htsp->htsp_logname, strerror(errno));
|
||||
break;
|
||||
}
|
||||
|
||||
dptr += r;
|
||||
dlen -= r;
|
||||
}
|
||||
|
||||
free(freeme);
|
||||
pthread_mutex_lock(&htsp->htsp_out_mutex);
|
||||
if(r != dlen)
|
||||
if(dlen)
|
||||
break;
|
||||
}
|
||||
// Shutdown socket to make receive thread terminate entire HTSP connection
|
||||
|
||||
shutdown(htsp->htsp_fd, SHUT_RDWR);
|
||||
pthread_mutex_unlock(&htsp->htsp_out_mutex);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue