Module: sip-router
Branch: kamailio_3.0
Commit: 711e02646dacba1dba16edd6eab1a573a46114e1
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=711e026…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 18:39:43 2010 +0200
tm: don't reply if the reply dest. is not yet set
- relay_reply() doesn't attempt to send the reply if the reply
destination is not yet fully set. This can happen for example
if reply_to_via is set, Via contains a host name (and not an ip)
and before having a chance to resolve the name a reply must be
sent (reply for a message that hasn't been sent yet: very
unlikely, but possible).
- use a membar_write() in init_rb(), before setting the reply send
socket (the reply send socket is also used as a flag for a fully
initialized reply destination and the membar_write() makes sure
that everything else was written before the send socket and no
re-ordering will take place).
(cherry picked from commit 96e1bc629bc7ed78dd64b221bc54b266cd45e3ca)
---
modules/tm/t_lookup.c | 17 ++---------------
modules/tm/t_reply.c | 8 +++++---
2 files changed, 7 insertions(+), 18 deletions(-)
diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c
index 25f9fc4..c706d91 100644
--- a/modules/tm/t_lookup.c
+++ b/modules/tm/t_lookup.c
@@ -1196,7 +1196,6 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
/*struct socket_info* send_sock;*/
struct via_body* via;
int proto;
- int backup_mhomed;
/* rb. timers are init. init_t()/new_cell() */
via=msg->via1;
@@ -1220,20 +1219,8 @@ int init_rb( struct retr_buf *rb, struct sip_msg *msg)
rb->dst.comp=via->comp_no;
#endif
rb->dst.send_flags=msg->rpl_send_flags;
- /* turn off mhomed for generating replies -- they are ideally sent to where
- request came from to make life with NATs and other beasts easier
- */
- backup_mhomed=mhomed;
- mhomed=0;
- mhomed=backup_mhomed;
- /* use for sending replies the incoming interface of the request -bogdan */
- /*send_sock=get_send_socket(msg, &rb->dst.to, proto);
- if (send_sock==0) {
- LOG(L_ERR, "ERROR: init_rb: cannot fwd to af %d, proto %d "
- "no socket\n", rb->dst.to.s.sa_family, proto);
- ser_error=E_BAD_VIA;
- return 0;
- }*/
+
+ membar_write();
rb->dst.send_sock=msg->rcv.bind_address;
return 1;
}
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index e8e26ff..5cc49a1 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -601,7 +601,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
If reply_to_via is set and via contains a host name (and not an ip)
the chances for this increase a lot.
*/
- if (!trans->uas.response.dst.send_sock) {
+ if (unlikely(!trans->uas.response.dst.send_sock)) {
LOG(L_ERR, "ERROR: _reply_light: no resolved dst to send reply to\n");
} else {
if (likely(SEND_PR_BUFFER( rb, buf, len )>=0)){
@@ -1718,7 +1718,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if (reply_status == RPS_COMPLETED) {
start_final_repl_retr(t);
}
- if (SEND_PR_BUFFER( uas_rb, buf, res_len )>=0){
+ if (likely(uas_rb->dst.send_sock &&
+ SEND_PR_BUFFER( uas_rb, buf, res_len ) >= 0)){
if (unlikely(!totag_retr && has_tran_tmcbs(t, TMCB_RESPONSE_OUT))){
run_trans_callbacks( TMCB_RESPONSE_OUT, t, t->uas.request,
relayed_msg, relayed_code);
@@ -1733,7 +1734,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
run_onsend_callbacks2(TMCB_RESPONSE_SENT, t, &onsend_params);
}
#endif
- }
+ } else if (unlikely(uas_rb->dst.send_sock == 0))
+ ERR("no resolved dst to send reply to\n");
/* Call put_on_wait() only if we really send out
* the reply. It can happen that the reply has been already sent from
* failure_route or from a callback and the timer has been already
Module: sip-router
Branch: kamailio_3.0
Commit: a1264e11d3fa77f841ff541ac7fb73956316183e
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a1264e1…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 18 18:36:14 2010 +0200
tcp: fix double increment for the established stats
The counter/stats for established TCP connections were incremented
twice in the case of accept()-ed connections: once immediately
after the accept() and another time after the first packet
received or sent on the connection.
Now they are incremented only after the first successful send or
receive.
(cherry picked from commit 66cda7bc5f642ce892124cfb35f1e5effd78e9d6)
---
tcp_main.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index 255753d..2258bc3 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -3499,7 +3499,15 @@ static inline int handle_new_connect(struct socket_info* si)
return 1; /* success, because the accept was succesfull */
}
(*tcp_connections_no)++;
- TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+ /* stats for established connections are incremented after
+ the first received or sent packet.
+ Alternatively they could be incremented here for accepted
+ connections, but then the connection state must be changed to
+ S_CONN_OK:
+ TCP_STATS_ESTABLISHED(S_CONN_ACCEPT);
+ ...
+ tcpconn=tcpconn_new(new_sock, &su, dst_su, si, si->proto, S_CONN_OK);
+ */
dst_su=&si->su;
if (unlikely(si->flags & SI_IS_ANY)){
Module: sip-router
Branch: kamailio_3.0
Commit: cc3351c1b9ee0df6aa43c6382cf577c382687043
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cc3351c…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Wed Aug 11 19:31:14 2010 +0200
presence_dialoginfo(k): fix bsd compilation
On FreeBSD don't define _XOPEN_SOURCE (define it only on linux).
It's not needed for strptime() and worse will cause some other
defines to be missing, like INADDR_LOOPBACK ( if_XOPEN_SOURCE
is defined, __BSD_VISIBLE will be undefined => lots of missing
defines).
Reported-by: Reported-by: Olle E. Johansson oej edvina net
(cherry picked from commit 850a7b31de86056fc9223d809dfae54b0e490c5f)
---
modules_k/presence_dialoginfo/pidf.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/modules_k/presence_dialoginfo/pidf.c b/modules_k/presence_dialoginfo/pidf.c
index 9285d2b..d90de4c 100644
--- a/modules_k/presence_dialoginfo/pidf.c
+++ b/modules_k/presence_dialoginfo/pidf.c
@@ -36,12 +36,12 @@
* use 600 for 'Single UNIX Specification, Version 3'
* _XOPEN_SOURCE creates conflict in header definitions in Solaris
*/
-#ifndef __OS_solaris
- #define _XOPEN_SOURCE 600 /* glibc2 on linux, bsd */
+#ifdef __OS_linux
+ #define _XOPEN_SOURCE 600 /* glibc2 on linux */
#define _BSD_SOURCE 1 /* needed on linux to "fix" the effect
of the above define on
features.h/unistd.h syscall() */
-#else
+#elif defined __OS_solaris
#define _XOPEN_SOURCE_EXTENDED 1 /* solaris */
#endif
Module: sip-router
Branch: kamailio_3.0
Commit: 5ccc5b3c51f7619b679dde4079b0b35e5f2bfeae
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5ccc5b3…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Aug 13 11:45:39 2010 +0200
core: DragonFly kqueue support enabled
- fixed kqueue support check for DragonFly (seems to be always
supported since it was forked from FreeBSD 4.8).
- in dragonfly case define both __OS_freebsd and __OS_dragonfly so
that we can make some exceptions for dragonfly (e.g. no >= 4.1
version check at runtime before enabling kqueue).
- assume SCTP in 2.6 is at least on par with SCTP in FreeBSD 7.1.
(cherry picked from commit c07c2b5e599a2b97fc21d04731f1f9d409859d43)
---
Makefile.defs | 27 +++++++++++++++------------
io_wait.c | 10 ++++++++--
2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/Makefile.defs b/Makefile.defs
index 7cf0c82..cd1cc46 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -623,18 +623,20 @@ $(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
# adds support for Application Server interface
# Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
-# Tell it that dragonflybsd is equivalent to compiling for freebsd.
-# This will cause __OS_freebsd to be defined below.
ifeq ($(OS), dragonfly)
- EQUIV_OS := freebsd
+ # Tell it that dragonflybsd is equivalent to compiling for freebsd, but
+ # define also __OS_dragonfly (for fine-tunning like kqueue support).
+ os_defs := -D__OS_freebsd -D__OS_dragonfly
+ EQUIV_OS = freebsd
else
- EQUIV_OS := $(OS)
+ os_defs := -D__OS_$(OS)
+ EQUIV_OS = $(OS)
endif
C_DEFS= $(extra_defs) \
-DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
-DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
- -D__CPU_$(ARCH) -D__OS_$(EQUIV_OS) \
+ -D__CPU_$(ARCH) $(os_defs) \
-DSER_VER=$(SER_VER) \
-DCFG_DIR='"$(cfg_target)"'\
-DPKG_MALLOC \
@@ -1814,11 +1816,9 @@ ifeq ($(OS), dragonfly)
else
LIBS= #dlopen is in libc
endif
- # check for ver >= 4.1
- ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
- ifeq ($(NO_KQUEUE),)
- C_DEFS+=-DHAVE_KQUEUE
- endif
+ # dragonfly was forked from freebsd 4.8 => all version have kqueue
+ ifeq ($(NO_KQUEUE),)
+ C_DEFS+=-DHAVE_KQUEUE
endif
ifeq ($(NO_SELECT),)
C_DEFS+=-DHAVE_SELECT
@@ -1834,8 +1834,11 @@ ifeq ($(OS), dragonfly)
$(info "sctp development files not installed -- sctp disabled")
override SCTP :=
endif
- ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
-$(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
+ # FIXME: don't know what's the status of SCTP on dragonfly
+ # (we suppose the 2.6 version is >= the version in
+ # in freebsd 7.0)
+ ifeq ($(shell [ $(OSREL_N) -lt 2006 ] && echo sctp), sctp)
+$(info "old dragonfly version (>= 2.6 needed) -- sctp disabled")
override SCTP :=
endif
diff --git a/io_wait.c b/io_wait.c
index 1b29813..72e34ee 100644
--- a/io_wait.c
+++ b/io_wait.c
@@ -333,10 +333,13 @@ char* check_poll_method(enum poll_types poll_method)
#ifndef HAVE_KQUEUE
ret="kqueue not supported, try re-compiling with -DHAVE_KQUEUE";
#else
- /* only in FreeBSD 4.1, NETBSD 2.0, OpenBSD 2.9, Darwin */
+ /* only in FreeBSD 4.1, NETBSD 2.0, OpenBSD 2.9, Darwin, DragonFly */
#ifdef __OS_freebsd
+ /* all DragonFly versions have kqueque */
+ #ifndef __OS_dragonfly
if (_os_ver<0x0401) /* if ver < 4.1 */
ret="kqueue not supported on FreeBSD < 4.1";
+ #endif /* __OS_dragonfly */
#elif defined (__OS_netbsd)
if (_os_ver<0x020000) /* if ver < 2.0 */
ret="kqueue not supported on NetBSD < 2.0";
@@ -381,9 +384,12 @@ enum poll_types choose_poll_method()
#endif
#ifdef HAVE_KQUEUE
if (poll_method==0)
- /* only in FreeBSD 4.1, NETBSD 2.0, OpenBSD 2.9, Darwin */
+ /* only in FreeBSD 4.1, NETBSD 2.0, OpenBSD 2.9, Darwin, DragonFly */
#ifdef __OS_freebsd
+ /* all DragonFly versions have kqueque */
+ #ifndef __OS_dragonfly
if (_os_ver>=0x0401) /* if ver >= 4.1 */
+ #endif /**__OS_dragonfly
#elif defined (__OS_netbsd)
if (_os_ver>=0x020000) /* if ver >= 2.0 */
#elif defined (__OS_openbsd)