Skip to content

Commit

Permalink
pass send_socket when forwarding replies
Browse files Browse the repository at this point in the history
  • Loading branch information
vladut-paiu committed Feb 22, 2012
1 parent aa318ca commit 19e9da1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,6 @@ int forward_reply(struct sip_msg* msg)
goto error;
}

new_buf = build_res_buf_from_sip_res( msg, &new_len);
if (!new_buf){
LM_ERR("failed to build rpl from req failed\n");
goto error;
}

proto=msg->via2->proto;
if (update_sock_struct_from_via( to, msg, msg->via2 )==-1) goto error;

Expand All @@ -620,6 +614,12 @@ int forward_reply(struct sip_msg* msg)

send_sock = get_send_socket(msg, to, proto);

new_buf = build_res_buf_from_sip_res( msg, &new_len, send_sock);
if (!new_buf){
LM_ERR("failed to build rpl from req failed\n");
goto error;
}

if (msg_send(send_sock, proto, to, id, new_buf, new_len)<0) {
update_stat( drp_rpls, 1);
goto error0;
Expand Down
3 changes: 2 additions & 1 deletion modules/tm/t_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,

} else {
relayed_code=relayed_msg->REPLY_STATUS;
buf = build_res_buf_from_sip_res( relayed_msg, &res_len );
buf = build_res_buf_from_sip_res( relayed_msg, &res_len,
uas_rb->dst.send_sock);
/* if we build a message from shmem, we need to remove
via delete lumps which are now stirred in the shmem-ed
structure
Expand Down
11 changes: 5 additions & 6 deletions msg_translator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ char * build_req_buf_from_sip_req( struct sip_msg* msg,


char * build_res_buf_from_sip_res( struct sip_msg* msg,
unsigned int *returned_len)
unsigned int *returned_len, struct socket_info *sock)
{
unsigned int new_len, via_len, body_delta, len;
char *new_buf, *buf;
Expand Down Expand Up @@ -1580,8 +1580,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
goto error;
}

new_len=len+body_delta+lumps_len(msg, msg->add_rm, 0); /*FIXME: we don't
know the send sock */
new_len=len+body_delta+lumps_len(msg, msg->add_rm, sock);

LM_DBG(" old size: %d, new size: %d\n", len, new_len);
new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging
Expand All @@ -1592,9 +1591,9 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
}
new_buf[new_len]=0; /* debug: print the message */
offset=s_offset=0;
/*FIXME: no send sock*/
process_lumps(msg, msg->add_rm, new_buf, &offset, &s_offset, 0);/*FIXME:*/
process_lumps(msg, msg->body_lumps, new_buf, &offset, &s_offset, 0);

process_lumps(msg, msg->add_rm, new_buf, &offset, &s_offset, sock);
process_lumps(msg, msg->body_lumps, new_buf, &offset, &s_offset, sock);
/* copy the rest of the message */
memcpy(new_buf+offset,
buf+s_offset,
Expand Down
2 changes: 1 addition & 1 deletion msg_translator.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ char * build_req_buf_from_sip_req ( struct sip_msg* msg,
int proto, unsigned int flags);

char * build_res_buf_from_sip_res( struct sip_msg* msg,
unsigned int *returned_len);
unsigned int *returned_len, struct socket_info *sock);


char * build_res_buf_from_sip_req( unsigned int code,
Expand Down

0 comments on commit 19e9da1

Please sign in to comment.