mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Fix calls to sendmsg()
Align cmsg buffers properly and use MSG_NOSIGNAL.
This commit is contained in:
parent
90c955c223
commit
c1920163d5
3 changed files with 12 additions and 6 deletions
|
|
@ -877,7 +877,7 @@ static int flush_write(struct state *state, uint64_t current_time)
|
||||||
SPA_AVBTP_PACKET_AAF_SET_SEQ_NUM(pdu, state->pdu_seq++);
|
SPA_AVBTP_PACKET_AAF_SET_SEQ_NUM(pdu, state->pdu_seq++);
|
||||||
SPA_AVBTP_PACKET_AAF_SET_TIMESTAMP(pdu, ptime);
|
SPA_AVBTP_PACKET_AAF_SET_TIMESTAMP(pdu, ptime);
|
||||||
|
|
||||||
n = sendmsg(state->sockfd, &state->msg, 0);
|
n = sendmsg(state->sockfd, &state->msg, MSG_NOSIGNAL);
|
||||||
if (n < 0 || n != (ssize_t)state->pdu_size) {
|
if (n < 0 || n != (ssize_t)state->pdu_size) {
|
||||||
spa_log_error(state->log, "sendmdg() failed: %m");
|
spa_log_error(state->log, "sendmdg() failed: %m");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ static int flush_write(struct stream *stream, uint64_t current_time)
|
||||||
p->timestamp = ptime;
|
p->timestamp = ptime;
|
||||||
p->dbc = dbc;
|
p->dbc = dbc;
|
||||||
|
|
||||||
n = sendmsg(stream->source->fd, &stream->msg, 0);
|
n = sendmsg(stream->source->fd, &stream->msg, MSG_NOSIGNAL);
|
||||||
if (n < 0 || n != (ssize_t)stream->pdu_size) {
|
if (n < 0 || n != (ssize_t)stream->pdu_size) {
|
||||||
pw_log_error("sendmsg() failed %zd != %zd: %m",
|
pw_log_error("sendmsg() failed %zd != %zd: %m",
|
||||||
n, stream->pdu_size);
|
n, stream->pdu_size);
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,10 @@ static int refill_buffer(struct pw_protocol_native_connection *conn, struct buff
|
||||||
struct cmsghdr *cmsg = NULL;
|
struct cmsghdr *cmsg = NULL;
|
||||||
struct msghdr msg = { 0 };
|
struct msghdr msg = { 0 };
|
||||||
struct iovec iov[1];
|
struct iovec iov[1];
|
||||||
char cmsgbuf[CMSG_SPACE(MAX_FDS_MSG * sizeof(int))];
|
union {
|
||||||
|
char cmsgbuf[CMSG_SPACE(MAX_FDS_MSG * sizeof(int))];
|
||||||
|
struct cmsghdr align;
|
||||||
|
} cmsgbuf;
|
||||||
int n_fds = 0;
|
int n_fds = 0;
|
||||||
size_t avail;
|
size_t avail;
|
||||||
|
|
||||||
|
|
@ -231,7 +234,7 @@ static int refill_buffer(struct pw_protocol_native_connection *conn, struct buff
|
||||||
iov[0].iov_len = avail;
|
iov[0].iov_len = avail;
|
||||||
msg.msg_iov = iov;
|
msg.msg_iov = iov;
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
msg.msg_control = cmsgbuf;
|
msg.msg_control = &cmsgbuf;
|
||||||
msg.msg_controllen = sizeof(cmsgbuf);
|
msg.msg_controllen = sizeof(cmsgbuf);
|
||||||
msg.msg_flags = MSG_CMSG_CLOEXEC | MSG_DONTWAIT;
|
msg.msg_flags = MSG_CMSG_CLOEXEC | MSG_DONTWAIT;
|
||||||
|
|
||||||
|
|
@ -755,7 +758,10 @@ int pw_protocol_native_connection_flush(struct pw_protocol_native_connection *co
|
||||||
struct msghdr msg = { 0 };
|
struct msghdr msg = { 0 };
|
||||||
struct iovec iov[1];
|
struct iovec iov[1];
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
char cmsgbuf[CMSG_SPACE(MAX_FDS_MSG * sizeof(int))];
|
union {
|
||||||
|
char cmsgbuf[CMSG_SPACE(MAX_FDS_MSG * sizeof(int))];
|
||||||
|
struct cmsghdr align;
|
||||||
|
} cmsgbuf;
|
||||||
int res = 0, *fds;
|
int res = 0, *fds;
|
||||||
uint32_t fds_len, to_close, n_fds, outfds, i;
|
uint32_t fds_len, to_close, n_fds, outfds, i;
|
||||||
struct buffer *buf;
|
struct buffer *buf;
|
||||||
|
|
@ -786,7 +792,7 @@ int pw_protocol_native_connection_flush(struct pw_protocol_native_connection *co
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
|
|
||||||
if (outfds > 0) {
|
if (outfds > 0) {
|
||||||
msg.msg_control = cmsgbuf;
|
msg.msg_control = &cmsgbuf;
|
||||||
msg.msg_controllen = CMSG_SPACE(fds_len);
|
msg.msg_controllen = CMSG_SPACE(fds_len);
|
||||||
cmsg = CMSG_FIRSTHDR(&msg);
|
cmsg = CMSG_FIRSTHDR(&msg);
|
||||||
cmsg->cmsg_level = SOL_SOCKET;
|
cmsg->cmsg_level = SOL_SOCKET;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue