... | ... |
@@ -60,7 +60,7 @@ MAIN_NAME=ser |
60 | 60 |
VERSION = 0 |
61 | 61 |
PATCHLEVEL = 10 |
62 | 62 |
SUBLEVEL = 99 |
63 |
-EXTRAVERSION = -dev20-tcp |
|
63 |
+EXTRAVERSION = -dev21-tcp |
|
64 | 64 |
|
65 | 65 |
RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
66 | 66 |
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") |
... | ... |
@@ -369,6 +369,12 @@ int add_listen_iface(char* name, unsigned short port, unsigned short proto, |
369 | 369 |
#endif |
370 | 370 |
port_no; |
371 | 371 |
} |
372 |
+#ifdef USE_TLS |
|
373 |
+ else if ((c_proto==PROTO_TLS) && (proto==0)){ |
|
374 |
+ /* -l ip:port => on udp:ip:port; tcp:ip:port and tls:ip:port+1? */ |
|
375 |
+ port++; |
|
376 |
+ } |
|
377 |
+#endif |
|
372 | 378 |
if (new_sock2list(name, port, c_proto, flags, list)<0){ |
373 | 379 |
LOG(L_ERR, "ERROR: add_listen_iface: new_sock2list failed\n"); |
374 | 380 |
goto error; |
... | ... |
@@ -414,6 +414,7 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su, |
414 | 414 |
c->rcv.proto_reserved2=0; |
415 | 415 |
c->state=state; |
416 | 416 |
c->extra_data=0; |
417 |
+ c->flags|=F_CONN_REMOVED; |
|
417 | 418 |
#ifdef USE_TLS |
418 | 419 |
if (type==PROTO_TLS){ |
419 | 420 |
if (tls_tcpconn_init(c, sock)==-1) goto error; |
... | ... |
@@ -1102,6 +1103,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, int fd_i) |
1102 | 1103 |
/* pass it to child, so remove it from the io watch list */ |
1103 | 1104 |
DBG("handle_tcpconn_ev: data available on %p %d\n", tcpconn, tcpconn->s); |
1104 | 1105 |
if (io_watch_del(&io_h, tcpconn->s, fd_i, 0)==-1) goto error; |
1106 |
+ tcpconn->flags|=F_CONN_REMOVED; |
|
1105 | 1107 |
tcpconn_ref(tcpconn); /* refcnt ++ */ |
1106 | 1108 |
if (send2child(tcpconn)<0){ |
1107 | 1109 |
LOG(L_ERR,"ERROR: handle_tcpconn_ev: no children available\n"); |
... | ... |
@@ -1205,6 +1207,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i) |
1205 | 1207 |
tcpconn_put(tcpconn); |
1206 | 1208 |
/* must be after the de-ref*/ |
1207 | 1209 |
io_watch_add(&io_h, tcpconn->s, F_TCPCONN, tcpconn); |
1210 |
+ tcpconn->flags&=~F_CONN_REMOVED; |
|
1208 | 1211 |
DBG("handle_tcp_child: CONN_RELEASE %p refcnt= %d\n", |
1209 | 1212 |
tcpconn, tcpconn->refcnt); |
1210 | 1213 |
break; |
... | ... |
@@ -1311,8 +1314,10 @@ inline static int handle_ser_child(struct process_table* p, int fd_i) |
1311 | 1314 |
} |
1312 | 1315 |
switch(cmd){ |
1313 | 1316 |
case CONN_ERROR: |
1314 |
- if (tcpconn->s!=-1) |
|
1317 |
+ if (!(tcpconn->flags & F_CONN_REMOVED) && (tcpconn->s!=-1)){ |
|
1315 | 1318 |
io_watch_del(&io_h, tcpconn->s, -1, IO_FD_CLOSING); |
1319 |
+ tcpconn->flags|=F_CONN_REMOVED; |
|
1320 |
+ } |
|
1316 | 1321 |
tcpconn_destroy(tcpconn); /* will close also the fd */ |
1317 | 1322 |
break; |
1318 | 1323 |
case CONN_GET_FD: |
... | ... |
@@ -1339,6 +1344,7 @@ inline static int handle_ser_child(struct process_table* p, int fd_i) |
1339 | 1344 |
/* update the timeout*/ |
1340 | 1345 |
tcpconn->timeout=get_ticks()+tcp_con_lifetime; |
1341 | 1346 |
io_watch_add(&io_h, tcpconn->s, F_TCPCONN, tcpconn); |
1347 |
+ tcpconn->flags&=~F_CONN_REMOVED; |
|
1342 | 1348 |
break; |
1343 | 1349 |
default: |
1344 | 1350 |
LOG(L_CRIT, "BUG: handle_ser_child: unknown cmd %d\n", cmd); |
... | ... |
@@ -1423,7 +1429,10 @@ static inline void tcpconn_timeout(int force) |
1423 | 1429 |
#endif |
1424 | 1430 |
_tcpconn_rm(c); |
1425 | 1431 |
if ((fd>0)&&(c->refcnt==0)) { |
1426 |
- io_watch_del(&io_h, fd, -1, IO_FD_CLOSING); |
|
1432 |
+ if (!(c->flags & F_CONN_REMOVED)){ |
|
1433 |
+ io_watch_del(&io_h, fd, -1, IO_FD_CLOSING); |
|
1434 |
+ c->flags|=F_CONN_REMOVED; |
|
1435 |
+ } |
|
1427 | 1436 |
close(fd); |
1428 | 1437 |
} |
1429 | 1438 |
tcp_connections_no--; |
... | ... |
@@ -400,6 +400,7 @@ skip: |
400 | 400 |
int tcp_read_req(struct tcp_connection* con, int* bytes_read) |
401 | 401 |
{ |
402 | 402 |
int bytes; |
403 |
+ int total_bytes; |
|
403 | 404 |
int resp; |
404 | 405 |
long size; |
405 | 406 |
struct tcp_req* req; |
... | ... |
@@ -407,6 +408,7 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read) |
407 | 408 |
char c; |
408 | 409 |
|
409 | 410 |
bytes=-1; |
411 |
+ total_bytes=0; |
|
410 | 412 |
resp=CONN_RELEASE; |
411 | 413 |
s=con->fd; |
412 | 414 |
req=&con->req; |
... | ... |
@@ -437,6 +439,7 @@ again: |
437 | 439 |
resp=CONN_ERROR; |
438 | 440 |
goto end_req; |
439 | 441 |
} |
442 |
+ total_bytes+=bytes; |
|
440 | 443 |
/* eof check: |
441 | 444 |
* is EOF if eof on fd and req. not complete yet, |
442 | 445 |
* if req. is complete we might have a second unparsed |
... | ... |
@@ -533,7 +536,7 @@ again: |
533 | 536 |
|
534 | 537 |
|
535 | 538 |
end_req: |
536 |
- if (bytes_read) *bytes_read=bytes; |
|
539 |
+ if (bytes_read) *bytes_read=total_bytes; |
|
537 | 540 |
return resp; |
538 | 541 |
} |
539 | 542 |
|