... | ... |
@@ -327,7 +327,7 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p, int proto) |
327 | 327 |
} |
328 | 328 |
#ifdef USE_TCP |
329 | 329 |
else if (proto==PROTO_TCP){ |
330 |
- if (tcp_send(buf, len, to, 0)==-1){ |
|
330 |
+ if (tcp_send(buf, len, to, 0)<0){ |
|
331 | 331 |
ser_error=E_SEND; |
332 | 332 |
p->errors++; |
333 | 333 |
p->ok=0; |
... | ... |
@@ -495,7 +495,7 @@ int forward_reply(struct sip_msg* msg) |
495 | 495 |
DBG("forward_reply: id= %x\n", id); |
496 | 496 |
} |
497 | 497 |
|
498 |
- if (tcp_send(new_buf, new_len, to, id)==-1) |
|
498 |
+ if (tcp_send(new_buf, new_len, to, id)<0) |
|
499 | 499 |
{ |
500 | 500 |
STATS_TX_DROPS; |
501 | 501 |
goto error; |
... | ... |
@@ -275,16 +275,26 @@ no_id: |
275 | 275 |
/* create tcp connection */ |
276 | 276 |
if ((c=tcpconn_connect(to))==0){ |
277 | 277 |
LOG(L_ERR, "ERROR: tcp_send: connect failed\n"); |
278 |
- return 0; |
|
278 |
+ return -1; |
|
279 | 279 |
} |
280 | 280 |
c->refcnt++; |
281 |
+ fd=c->s; |
|
281 | 282 |
|
282 | 283 |
/* send the new tcpconn to "tcp main" */ |
283 | 284 |
response[0]=(long)c; |
284 | 285 |
response[1]=CONN_NEW; |
285 | 286 |
n=write(unix_tcp_sock, response, sizeof(response)); |
287 |
+ if (n<0){ |
|
288 |
+ LOG(L_ERR, "BUG: tcp_send: failed write: %s (%d)\n", |
|
289 |
+ strerror(errno), errno); |
|
290 |
+ goto end; |
|
291 |
+ } |
|
286 | 292 |
n=send_fd(unix_tcp_sock, &c, sizeof(c), c->s); |
287 |
- fd=c->s; |
|
293 |
+ if (n<0){ |
|
294 |
+ LOG(L_ERR, "BUG: tcp_send: failed send_fd: %s (%d)\n", |
|
295 |
+ strerror(errno), errno); |
|
296 |
+ goto end; |
|
297 |
+ } |
|
288 | 298 |
goto send_it; |
289 | 299 |
} |
290 | 300 |
get_fd: |
... | ... |
@@ -295,8 +305,18 @@ get_fd: |
295 | 305 |
response[0]=(long)c; |
296 | 306 |
response[1]=CONN_GET_FD; |
297 | 307 |
n=write(unix_tcp_sock, response, sizeof(response)); |
308 |
+ if (n<0){ |
|
309 |
+ LOG(L_ERR, "BUG: tcp_send: failed to get fd(write):%s (%d)\n", |
|
310 |
+ strerror(errno), errno); |
|
311 |
+ goto release_c; |
|
312 |
+ } |
|
298 | 313 |
DBG("tcp_send, c= %p, n=%d\n", c, n); |
299 | 314 |
n=receive_fd(unix_tcp_sock, &c, sizeof(c), &fd); |
315 |
+ if (n<0){ |
|
316 |
+ LOG(L_ERR, "BUG: tcp_send: failed to get fd(receive_fd):" |
|
317 |
+ " %s (%d)\n", strerror(errno), errno); |
|
318 |
+ goto release_c; |
|
319 |
+ } |
|
300 | 320 |
DBG("tcp_send: after receive_fd: c= %p n=%d fd=%d\n",c, n, fd); |
301 | 321 |
|
302 | 322 |
|
... | ... |
@@ -305,7 +325,9 @@ send_it: |
305 | 325 |
DBG("tcp_send: sending...\n"); |
306 | 326 |
n=write(fd, buf, len); |
307 | 327 |
DBG("tcp_send: after write: c= %p n=%d fd=%d\n",c, n, fd); |
328 |
+end: |
|
308 | 329 |
close(fd); |
330 |
+release_c: |
|
309 | 331 |
tcpconn_put(c); /* release c (lock; dec refcnt; unlock) */ |
310 | 332 |
return n; |
311 | 333 |
} |