Module: sip-router
Branch: kamailio_3.0
Commit: 8bc0c9ba5dc1fd9d863cd58c54ce469a6186d81f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8bc0c9b…
Author: Vincent Stemen <vince.lists(a)ngtek.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 11 16:45:05 2010 +0200
db_text(k) makefile: fix make use
This fixes a bug. It called make directly which breaks on
platforms where it is being compiled under gmake.
Signed-off-by: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
(cherry picked from commit 5d8552087be74332c1a7812ffb01d8298060cc62)
---
modules_k/db_text/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/modules_k/db_text/Makefile b/modules_k/db_text/Makefile
index dd35b11..36bc48b 100644
--- a/modules_k/db_text/Makefile
+++ b/modules_k/db_text/Makefile
@@ -24,7 +24,7 @@ ifeq ($(INSTALL_FLAVOUR),kamailio)
# extra install for kamailio
install-dbtext-scripts: $(bin_prefix)/$(bin_dir)
- DBTEXTON=yes make -C ../../utils/kamctl/ install-modules
+ DBTEXTON=yes $(MAKE) -C ../../utils/kamctl/ install-modules
install-scripts: install-dbtext-scripts
Module: sip-router
Branch: kamailio_3.0
Commit: 4ca0f2295fcb2b93a853edad472c5578b335e72a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4ca0f22…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Sun Jun 20 19:40:55 2010 +0200
tcp: force eof after read if write side hangup
Even if POLLRDHUP is not supported, but we detected a write side close
(POLLHUP) or an error (POLLERR) or such an event was previously detected by
tcp_main (F_CONN_EOF_SEEN), force connection closing after reading all the data
in the socket buffer. In this case we can close() after the first short read
and we save an extra system call (a read() that returns 0).
(cherry picked from commit 28e313250503d6f8d06ebab15c8421c40e7f0fe4)
---
tcp_read.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tcp_read.c b/tcp_read.c
index d201765..9015a8b 100644
--- a/tcp_read.c
+++ b/tcp_read.c
@@ -970,13 +970,13 @@ again:
con, con->id, atomic_get(&con->refcnt));
goto read_error;
}
+ read_flags=((
#ifdef POLLRDHUP
- read_flags=(((events & POLLRDHUP) |
+ (events & POLLRDHUP) |
+#endif /* POLLRDHUP */
+ (events & (POLLHUP|POLLERR)) |
(con->flags & (F_CONN_EOF_SEEN|F_CONN_FORCE_EOF)))
&& !(events & POLLPRI))? RD_CONN_FORCE_EOF: 0;
-#else /* POLLRDHUP */
- read_flags=0;
-#endif /* POLLRDHUP */
resp=tcp_read_req(con, &ret, &read_flags);
if (unlikely(resp<0)){
read_error:
Module: sip-router
Branch: kamailio_3.0
Commit: a160156bdca1708bcbca7e000c2da91c13f67336
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a160156…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Jul 7 11:59:30 2010 +0200
tcp: fix dispatching closed connections to tcp readers
Under very heavy load it is possible that send2child() might try
to send an already closed connection/fd to a tcp reader.
This can happen only if the tcp connection is watched for read
(POLLIN) by tcp_main (and not by a tcp reader), the connection
becomes available for reading (either new data received, EOF or
RST) and tcp_main chooses a specific tcp reader to send the
connection to while in the same time the same tcp reader tries to
send on the same connection, fails for some reason (no more space
for buffering, EOF, RST a.s.o) and sends a close command back to
tcp_main. Because send2child() executes first any pending commands
from the choosen tcp_reader, this might lead to closing the fd
before attempting to send it to the tcp_reader.
Under normal circumstances the impact is only an extra syscall and
some log messages, however it is possible (but highly unlikely)
that after sending the close command the tcp_reader opens a new
connection for sending and sends its fd back to tcp_main. This new
fd might get the same number as the freshly closed fd and
send2child might send the wrong (fd, tcp connection) pair.
(cherry picked from commit d89437a3d7bc25a9c098a04c6ee69fc3848ff0b5)
---
tcp_main.c | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index 6a6c4c0..54334ab 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -2468,6 +2468,7 @@ close_again:
LOG(L_ERR, "ERROR: tcpconn_put_destroy; close() failed: %s (%d)\n",
strerror(errno), errno);
}
+ tcpconn->s=-1;
}
@@ -3378,10 +3379,20 @@ inline static int send2child(struct tcp_connection* tcpconn)
* send a release command, but the master fills its socket buffer
* with new connection commands => deadlock) */
/* answer tcp_send requests first */
- while(handle_ser_child(&pt[tcp_children[idx].proc_no], -1)>0);
+ while(unlikely((tcpconn->state != S_CONN_BAD) &&
+ (handle_ser_child(&pt[tcp_children[idx].proc_no], -1)>0)));
/* process tcp readers requests */
- while(handle_tcp_child(&tcp_children[idx], -1)>0);
-
+ while(unlikely((tcpconn->state != S_CONN_BAD &&
+ (handle_tcp_child(&tcp_children[idx], -1)>0))));
+
+ /* the above possible pending requests might have included a
+ command to close this tcpconn (e.g. CONN_ERROR, CONN_EOF).
+ In this case the fd is already closed here (and possible
+ even replaced by another one with the same number) so it
+ must not be sent to a reader anymore */
+ if (unlikely(tcpconn->state == S_CONN_BAD ||
+ (tcpconn->flags & F_CONN_FD_CLOSED)))
+ return -1;
#ifdef SEND_FD_QUEUE
/* if queue full, try to queue the io */
if (unlikely(send_fd(tcp_children[idx].unix_sock, &tcpconn,
@@ -3501,8 +3512,6 @@ static inline int handle_new_connect(struct socket_info* si)
DBG("handle_new_connect: new connection from %s: %p %d flags: %04x\n",
su2a(&su, sizeof(su)), tcpconn, tcpconn->s, tcpconn->flags);
if(unlikely(send2child(tcpconn)<0)){
- LOG(L_ERR,"ERROR: handle_new_connect: no children "
- "available\n");
tcpconn->flags&=~F_CONN_READER;
tcpconn_put(tcpconn);
tcpconn_try_unhash(tcpconn);
@@ -3676,7 +3685,6 @@ send_to_child:
tcpconn->flags&=~(F_CONN_MAIN_TIMER|F_CONN_READ_W|F_CONN_WANTS_RD);
tcpconn_ref(tcpconn); /* refcnt ++ */
if (unlikely(send2child(tcpconn)<0)){
- LOG(L_ERR,"ERROR: handle_tcpconn_ev: no children available\n");
tcpconn->flags&=~F_CONN_READER;
#ifdef TCP_ASYNC
if (tcpconn->flags & F_CONN_WRITE_W){