Skip to content

Commit

Permalink
rtpproxy: fix writev error 22:Invalid argument
Browse files Browse the repository at this point in the history
 - align code with rtpengine implementation for systems with no IOV_MAX defined

(cherry picked from commit 565e25b)
  • Loading branch information
ovidiusas committed Jun 29, 2020
1 parent ec888c2 commit 580f6d8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions modules/rtpproxy/rtpproxy.c
Expand Up @@ -2017,42 +2017,47 @@ rtpp_test(struct rtpp_node *node, int isdisabled, int force)


#define RTPPROXY_BUF_SIZE 256
#define OSIP_IOV_MAX 1024

char *
send_rtpp_command(struct rtpp_node *node, struct iovec *v, int vcnt)
{
struct sockaddr_un addr;
int fd, len, i;
int max_vcnt=OSIP_IOV_MAX;
char *cp;
static char buf[RTPPROXY_BUF_SIZE];
struct pollfd fds[1];


#ifdef IOV_MAX
/* normalize vcntl to IOV_MAX, as on some systems this limit is very low (16 on Solaris) */
if (vcnt > IOV_MAX) {
if (IOV_MAX < OSIP_IOV_MAX)
max_vcnt = IOV_MAX;
#endif

/* normalize vcntl to max_vcnt, as on some systems this limit is very low (16 on Solaris) */
if (vcnt > max_vcnt) {
int i, vec_len = 0;
/* use buf if possible :) */
for (i = IOV_MAX - 1; i < vcnt; i++)
for (i = max_vcnt - 1; i < vcnt; i++)
vec_len += v[i].iov_len;
/* use buf, error otherwise */
if (vec_len > RTPPROXY_BUF_SIZE) {
LM_ERR("Command too big %d - max %d\n", vec_len, RTPPROXY_BUF_SIZE);
return NULL;
}
cp = buf;
for (i = IOV_MAX - 1; i < vcnt; i++) {
for (i = max_vcnt - 1; i < vcnt; i++) {
memcpy(cp, v[i].iov_base, v[i].iov_len);
cp += v[i].iov_len;
}
i = IOV_MAX - 1;
i = max_vcnt - 1;
v[i].iov_len = vec_len;
v[i].iov_base = buf;
/* finally solve the problem */
vcnt = IOV_MAX;
vcnt = max_vcnt;

}
#endif

len = 0;
cp = buf;
Expand Down

0 comments on commit 580f6d8

Please sign in to comment.