... | ... |
@@ -100,9 +100,9 @@ struct tcp_connection{ |
100 | 100 |
struct receive_info rcv; /* src & dst ip, ports, proto a.s.o*/ |
101 | 101 |
struct tcp_req req; /* request data */ |
102 | 102 |
volatile int refcnt; |
103 |
- int type; /* PROTO_TCP or a protocol over it, e.g. TLS */ |
|
103 |
+ enum sip_protos type; /* PROTO_TCP or a protocol over it, e.g. TLS */ |
|
104 | 104 |
int flags; /* connection related flags */ |
105 |
- int state; /* connection state */ |
|
105 |
+ enum tcp_conn_states state; /* connection state */ |
|
106 | 106 |
void* extra_data; /* extra data associated to the connection, 0 for tcp*/ |
107 | 107 |
int timeout; /* connection timeout, after this it will be removed*/ |
108 | 108 |
unsigned addr_hash; /* hash indexes in the 2 tables */ |
... | ... |
@@ -487,11 +487,13 @@ send_it: |
487 | 487 |
response[0]=(long)c; |
488 | 488 |
response[1]=CONN_ERROR; |
489 | 489 |
n=write(unix_tcp_sock, response, sizeof(response)); |
490 |
+ /* CONN_ERROR wil auto-dec refcnt => we must not call tcpconn_put !!*/ |
|
490 | 491 |
if (n<0){ |
491 |
- LOG(L_ERR, "BUG: tcp_send: failed to get fd(write):%s (%d)\n", |
|
492 |
+ LOG(L_ERR, "BUG: tcp_send: error return failed (write):%s (%d)\n", |
|
492 | 493 |
strerror(errno), errno); |
493 |
- goto release_c; |
|
494 | 494 |
} |
495 |
+ close(fd); |
|
496 |
+ return n; /* error return, no tcpconn_put */ |
|
495 | 497 |
} |
496 | 498 |
end: |
497 | 499 |
close(fd); |
... | ... |
@@ -853,6 +855,7 @@ read_again: |
853 | 855 |
case CONN_ERROR: |
854 | 856 |
case CONN_DESTROY: |
855 | 857 |
case CONN_EOF: |
858 |
+ /* WARNING: this will auto-dec. refcnt! */ |
|
856 | 859 |
if (pt[r].idx>=0){ |
857 | 860 |
tcp_children[pt[r].idx].busy--; |
858 | 861 |
}else{ |