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);
|
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);
|
htsp_msg_destroy(hm);
|
||||||
|
|
||||||
/* ignore return value */
|
void *freeme = dptr;
|
||||||
|
|
||||||
|
while(dlen > 0) {
|
||||||
r = write(htsp->htsp_fd, dptr, dlen);
|
r = write(htsp->htsp_fd, dptr, dlen);
|
||||||
if(r != dlen)
|
if(r < 1) {
|
||||||
tvhlog(LOG_INFO, "htsp", "%s: Write error -- %s",
|
tvhlog(LOG_INFO, "htsp", "%s: Write error -- %s",
|
||||||
htsp->htsp_logname, strerror(errno));
|
htsp->htsp_logname, strerror(errno));
|
||||||
free(dptr);
|
|
||||||
pthread_mutex_lock(&htsp->htsp_out_mutex);
|
|
||||||
if(r != dlen)
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dptr += r;
|
||||||
|
dlen -= r;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(freeme);
|
||||||
|
pthread_mutex_lock(&htsp->htsp_out_mutex);
|
||||||
|
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);
|
pthread_mutex_unlock(&htsp->htsp_out_mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue