Revision: 5906
http://openser.svn.sourceforge.net/openser/?rev=5906&view=rev
Author: juhe
Date: 2009-07-24 16:19:54 +0000 (Fri, 24 Jul 2009)
Log Message:
-----------
modules/utils: added check on size of http_query reply
- Added check on actual size of http_query reply body that fixes possible
crash if body does not contain a linefeed.
- If body does not contain a linefeed, return whole body as result.
Modified Paths:
--------------
branches/1.5/modules/utils/functions.c
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Hello,
First off as always, thanks ahead of time!
I'm testing out the new http_query kamailio method/function, experiencing
some odd behavior.
When I do: http://sub.domain.com/folder/1111111111 <- 1111111111 being a
"file dynamically created", it may pull results i.e. "XYZ".
When I do: http://domain.com/test.txt <--- it may pull "XYZ", only the later
method is being stored inside of the avp/var that I set on http_query.
I've tried everything from adjusting timeout, matching the end result in
the first with second that http serves, etc. The first one is a result that
is pulled dynamically, however the result is instantly rendered (no delay)
so is essentially the same amount of time between the two methods. At this
point the only difference I can see is the URI, one is on a subdomain, and
one is not, and one has two 'forward /' slashes, vs the other only has one
-- Any thoughts?
HTTP HEADERS
---------------------------------------------
AVP RESULT IS NOT STORED:
T +2.695119 KAMAILIO:50254 -> APACHE_SERVER_1:80 [AP]
GET /cnam/XXXXXXXXXX HTTP/1.1.
Host: APACHE_SERVER_1.
Accept: */*.
.
T +0.077494 APACHE_SERVER:80 -> KAMAILIO:50254 [AP]
HTTP/1.1 200 OK.
Date: Fri, 24 Jul 2009 03:28:44 GMT.
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 PHP/
5.2.9.
X-Powered-By: PHP/5.2.9.
Set-Cookie: PHPSESSID=73ab9eba6da2d51883d386bce2bb5967; path=/.
Expires: Thu, 19 Nov 1981 08:52:00 GMT.
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0.
Pragma: no-cache.
Content-Length: 15.
Content-Type: text/html.
.
Cell Phone CA
AVP RESULT IS APPROPRIATELY STORED:
T +5.883544 KAMAILIO:34652 -> APACHE_SERVER_2:80 [AP]
GET /test.txt HTTP/1.1.
Host: APACHE_SERVER_2.
Accept: */*.
.
T +0.002655 APACHE_SERVER_2:80 -> KAMAILIO:34652 [AP]
HTTP/1.1 200 OK.
Date: Fri, 24 Jul 2009 03:29:14 GMT.
Server: Apache/2.2.11 (Unix) PHP/5.2.9.
Last-Modified: Fri, 24 Jul 2009 03:14:54 GMT.
ETag: "11a117-10-46f6b0215a780".
Accept-Ranges: bytes.
Content-Length: 16.
Content-Type: text/plain.
.
Cell Phone CA
Bugs item #2824350, was opened at 2009-07-20 17:49
Message generated for change (Comment added) made by axlh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2824350&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: ver 1.5.x
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex Hermann (axlh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Presence DB support completely broken
Initial Comment:
As subject.
commit 5840 did the damage
----------------------------------------------------------------------
>Comment By: Alex Hermann (axlh)
Date: 2009-07-24 14:43
Message:
I agree that choice is better, but it requires a major rewrite. Maybe a
common library can be created for all modules using DB and cache. Maybe
even throw in a memcached cache as a choice. And prepared statements in
case the DB is used during runtime.....
Just missing my favorite mode:
=4: cache only at runtime, DB save/restore at shutdown/init time.
----------------------------------------------------------------------
Comment By: Klaus Darilion (klaus_darilion)
Date: 2009-07-21 15:43
Message:
What about having a new parameter like userloc?
db_mode=
=0: no DB
=1: read from cache, write/update to cache and DB
=2: read from cache, write to cache and delayed write/update to DB
=3: db_only, no cache
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-07-21 14:00
Message:
Patch is ok, cleaner with new parameter rather than playing with falback2db
value. I will apply it.
Updating on timer is good for the cases of sudden crash, maybe a new mode
to skip timer updates and store only at shutdown is more appropriate.
----------------------------------------------------------------------
Comment By: Alex Hermann (axlh)
Date: 2009-07-21 13:11
Message:
I decided to dive into the code some more. It's a bit messy. There are 2
modes of operation determined by fallback2db. Both modes don't work
correctly, the documentation for the modes contradict the code it
contradicts ITSELF. So the first thing to do to fix this is to get the
desired behavior for both modes documented.
>From the code I deduced the following behavior:
fallback mode:
init: load from database, keep data in tables
runtime: insert/update records in table on timer event
shutdown: flush cache to db
non-fallback mode:
init: load from database, empty table
runtime: no inserts but try to update table (won't work because table is
emptied)
shutdown: flush cache to db (fails, because all entries are marked
NO_UPDATEDB_FLAG du to the (failed) updates at runtime). Result is an empty
table after shutdown.
The documentation says in fallback mode the cache isn't used. This is
impossible in the current code. Later in the docs it is said only on cache
misses, the db is used. This seems reasonable behavior.
The main question is: should the db be updated during runtime or only on
shutdown when in non-fallback mode?
Attached patch creates the following behavior:
for both modes:
init: load from database, keep table contents
runtime: update/insert into table on timer event
shutdown: update/insert final time
The only difference in the modes is on lookup (as documentation says) and
is untouched by this patch.
The non-fallback mode should be optimized by not updating the table if the
answer to the above question says so, but that is not as trivial as this
patch.
ps. I found some nice descriptive function names: update_db_subs() and
update_subs_db()....
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-07-20 19:52
Message:
fallback to db is in presence and the insert function is used by rls module
as well. I had no time to check the impact now.
With this idea, to be safe, fallback2db param has to be directed to
another variable, fallback2db initialized to 0 and set to param value in
each child, via child_init. Otherwise can be a conflict of loading order.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-07-20 18:37
Message:
I don't know if changing the API and ABI is appropriate for the stable
series.
What about setting the fallback2db variable only AFTER loading the DB
contents?
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-07-20 18:22
Message:
The function is used in presence and rls modules. Does not look like big
changes to add a new param to specify the mode. Do you think of something
else?
----------------------------------------------------------------------
Comment By: Alex Hermann (axlh)
Date: 2009-07-20 18:07
Message:
New subscriptions don't get stored in the DB because the test for
'fallback2db' was wrong.
I just noticed the insert_shtable() function is also used to load from DB
initially, so my patch is wrong. Fix is a bit more non-trivial.
The problem is that the function is used for both DB-load at startup and
new subscriptions during runtime. The db_flag in the hash table record
needs to be INSERTDB_FLAG during runtime, and NO_UPDATEDB_FLAG for initial
load.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2009-07-20 17:53
Message:
Please provide a bit more details of what got broken.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2824350&group_…
Patches item #2826542, was opened at 2009-07-24 14:27
Message generated for change (Tracker Item Submitted) made by axlh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=2826542&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: ver 1.5.x
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex Hermann (axlh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add id parameter to pua_mi's send_publish
Initial Comment:
When using presence with dialog-info, one needs to be able to specify an id, otherwise presentity from different calls for the same presentity-uri will overwrite each other. This patch makes it possible to specify an 'id' in the MI interface for send_publish. Unfortunately it breaks backward compatibility but it's the only way to use dialog-info with MI without having to manually store a the state of the ETag in the proxy.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743022&aid=2826542&group_…
Bugs item #2826540, was opened at 2009-07-24 14:22
Message generated for change (Tracker Item Submitted) made by axlh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2826540&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: ver 1.5.x
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex Hermann (axlh)
Assigned to: Nobody/Anonymous (nobody)
Summary: Presence DB save fails after one failure
Initial Comment:
After one record has failed to insert/update into the database, remaining records aren't tried.
The attached patch tries to insert/update the remaining records in the hashtable after a failure.
This patch surfaced bug #2824350 which led to a lot of failures due to duplicate keys.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743020&aid=2826540&group_…
Hello,
latest master branch of sip-router includes support to execute an event
route when a request is generated by tm module. Right now is a compile
option:
make EXTRA_DEFS="-DWITH_EVENT_LOCAL_REQUEST" cfg
make all
make install
The functionality covers what was previously provided by local_route in
Kamailio 1.5. In addition, parts of the core were updated to allow fine
control of building the output buffer for requests.
Testing and feedback is very much appreciated.
Cheers,
Daniel
--
Daniel-Constantin Mierla
http://www.asipto.com/index.php/sip-router-bootcamp/
Module: sip-router
Branch: master
Commit: 9981e48a4f9517c016402897e6b90916d5f64eb2
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9981e48…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Jul 20 23:51:27 2009 +0200
core: enhanced get_send_socket() version
get_send_socket2() added.
---
forward.c | 53 ++++++++++++++++++++++++++++++++++-------------------
forward.h | 21 +++++++++++++++++++--
2 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/forward.c b/forward.c
index 3a9cb0c..b9e8ead 100644
--- a/forward.c
+++ b/forward.c
@@ -151,43 +151,58 @@ error:
-/* returns a socket_info pointer to the sending socket or 0 on error
- * params: sip msg (can be null), destination socket_union pointer, protocol
- * if msg!=null and msg->force_send_socket, the force_send_socket will be
- * used
+/** get the sending socket for a corresponding destination.
+ * @param force_send_socket - if !=0 and the protocol and af correspond
+ * with the destination, it will be returned.
+ * If the protocol or af check fail, a look-alike
+ * socket will be searched for and mismatch will be
+ * set. If no look-alike socket is found it will
+ * fallback to normal resolution.
+ * @param to - destination
+ * @param proto - protocol
+ * @param mismatch - result parameter, set if a force_send_socket was used, but
+ * there was an error matching it exactly to the destination.
+ * Possible values: 0 ok, SS_MISMATCH_PROTO,
+ * SS_MISMATCH_ADDR, SS_MISMATCH_AF, SS_MISMATCH_MCAST.
+ * @return a socket_info pointer to the sending socket on success (and possibly
+ * sets mismatch) or 0 on error.
*/
-struct socket_info* get_send_socket(struct sip_msg *msg,
- union sockaddr_union* to, int proto)
+struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
+ union sockaddr_union* to, int proto,
+ enum ss_mismatch* mismatch)
{
struct socket_info* send_sock;
+ if (likely(mismatch)) *mismatch=0;
/* check if send interface is not forced */
- if (unlikely(msg && msg->force_send_socket)){
- if (unlikely(msg->force_send_socket->proto!=proto)){
- DBG("get_send_socket: force_send_socket of different proto"
- " (%d)!\n", proto);
- msg->force_send_socket=find_si(&(msg->force_send_socket->address),
- msg->force_send_socket->port_no,
+ if (unlikely(force_send_socket)){
+ if (unlikely(force_send_socket->proto!=proto)){
+ force_send_socket=find_si(&(force_send_socket->address),
+ force_send_socket->port_no,
proto);
- if (unlikely(msg->force_send_socket == 0)){
+ if (unlikely(force_send_socket == 0)){
+ if (likely(mismatch)) *mismatch=SS_MISMATCH_ADDR;
LOG(L_WARN, "WARNING: get_send_socket: "
"protocol/port mismatch\n");
goto not_forced;
}
+ if (likely(mismatch)) *mismatch=SS_MISMATCH_PROTO;
}
- if (unlikely(msg->force_send_socket->address.af!=to->s.sa_family)){
+ if (unlikely(force_send_socket->address.af!=to->s.sa_family)){
DBG("get_send_socket: force_send_socket of different af (dst %d,"
" forced %d)\n",
- to->s.sa_family, msg->force_send_socket->address.af);
+ to->s.sa_family, force_send_socket->address.af);
+ if (likely(mismatch)) *mismatch=SS_MISMATCH_AF;
goto not_forced;
}
- if (likely((msg->force_send_socket->socket!=-1) &&
- !(msg->force_send_socket->flags & SI_IS_MCAST)))
- return msg->force_send_socket;
+ if (likely((force_send_socket->socket!=-1) &&
+ !(force_send_socket->flags & SI_IS_MCAST)))
+ return force_send_socket;
else{
- if (!(msg->force_send_socket->flags & SI_IS_MCAST))
+ if (!(force_send_socket->flags & SI_IS_MCAST))
LOG(L_WARN, "WARNING: get_send_socket: not listening"
" on the requested socket, no fork mode?\n");
+ else if (likely(mismatch)) *mismatch=SS_MISMATCH_MCAST;
}
};
not_forced:
diff --git a/forward.h b/forward.h
index f30703b..0a5750a 100644
--- a/forward.h
+++ b/forward.h
@@ -62,9 +62,26 @@
#include "compiler_opt.h"
+enum ss_mismatch {
+ SS_MISMATCH_OK=0,
+ SS_MISMATCH_PROTO, /* proto mismatch, but found same addr:port */
+ SS_MISMATCH_ADDR, /* proto and addr:port mismatch */
+ SS_MISMATCH_AF, /* af mismatch */
+ SS_MISMATCH_MCAST /* mcast forced send socket */
+};
+
+struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
+ union sockaddr_union* su, int proto,
+ enum ss_mismatch* mismatch);
+
+
+inline static struct socket_info* get_send_socket(struct sip_msg* msg,
+ union sockaddr_union* su, int proto)
+{
+ return get_send_socket2(msg?msg->force_send_socket:0, su, proto, 0);
+}
+
-struct socket_info* get_send_socket(struct sip_msg* msg,
- union sockaddr_union* su, int proto);
struct socket_info* get_out_socket(union sockaddr_union* to, int proto);
int check_self(str* host, unsigned short port, unsigned short proto);
int check_self_port(unsigned short port, unsigned short proto);
Module: sip-router
Branch: master
Commit: bc71de00c3e8cddf76044180315f5ce8c93495f4
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bc71de0…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Jul 21 01:10:05 2009 +0200
core: get_send_socket fix for tcp or tls forced socket
One of the get_send_socket() sanity tests, checks if ser really
listens on the forced socket. For tcp and tls this test should not
be performed (the sockets are closed for the processes that do not
need them => cannot test by looking at the fd).
---
forward.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/forward.c b/forward.c
index b9e8ead..3080b1d 100644
--- a/forward.c
+++ b/forward.c
@@ -195,7 +195,12 @@ struct socket_info* get_send_socket2(struct socket_info* force_send_socket,
if (likely(mismatch)) *mismatch=SS_MISMATCH_AF;
goto not_forced;
}
- if (likely((force_send_socket->socket!=-1) &&
+ /* check if listening on the socket (the check does not work
+ for TCP and TLS, for them socket==-1 on all the processes
+ except tcp_main(), see close_extra_socks() */
+ if (likely((force_send_socket->socket!=-1 ||
+ force_send_socket->proto==PROTO_TCP ||
+ force_send_socket->proto==PROTO_TLS) &&
!(force_send_socket->flags & SI_IS_MCAST)))
return force_send_socket;
else{
Module: sip-router
Branch: master
Commit: ded509e08679fe9f836386badca21c0fe3170de1
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=ded509e…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Jul 21 01:15:02 2009 +0200
tm: new uri2dst() version
- new uri2dst2() function which can have the send_socket passed
directly to it.
- uri2dst() is now a wrapper over uri2dst2().
---
modules/tm/ut.h | 65 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/modules/tm/ut.h b/modules/tm/ut.h
index 436a7b8..0c7afaf 100644
--- a/modules/tm/ut.h
+++ b/modules/tm/ut.h
@@ -209,7 +209,8 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
/*
- * Convert a URI into a dest_info structure
+ * Convert a URI into a dest_info structure.
+ * Same as uri2dst, but uses directly force_send_socket instead of msg.
* If the uri host resolves to multiple ips and dns_h!=0 the first ip for
* which a send socket is found will be used. If no send_socket are found,
* the first ip is selected.
@@ -218,9 +219,8 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
* null. If null or use_dns_failover==0 normal dns lookup will
* be performed (no failover).
* dst - will be filled
- * msg - sip message used to set dst->send_sock, if 0 dst->send_sock
- * will be set to the default w/o using msg->force_send_socket
- * (see get_send_socket())
+ * force_send_sock - if 0 dst->send_sock will be set to the default
+ * (see get_send_socket2())
* uri - uri in str form
* proto - if != PROTO_NONE, this protocol will be forced over the
* uri_proto, otherwise the uri proto will be used if set or
@@ -228,14 +228,14 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
* returns 0 on error, dst on success
*/
#ifdef USE_DNS_FAILOVER
-inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
+inline static struct dest_info *uri2dst2(struct dns_srv_handle* dns_h,
struct dest_info* dst,
- struct sip_msg *msg, str *uri,
- int proto )
+ struct socket_info *force_send_socket,
+ str *uri, int proto )
#else
-inline static struct dest_info *uri2dst(struct dest_info* dst,
- struct sip_msg *msg, str *uri,
- int proto )
+inline static struct dest_info *uri2dst2(struct dest_info* dst,
+ struct socket_info *force_send_socket,
+ str *uri, int proto )
#endif
{
struct sip_uri parsed_uri;
@@ -297,7 +297,8 @@ inline static struct dest_info *uri2dst(struct dest_info* dst,
dst->to=to;
ip_found=1;
}
- dst->send_sock = get_send_socket(msg, &to, dst->proto);
+ dst->send_sock = get_send_socket2(force_send_socket, &to,
+ dst->proto, 0);
if (dst->send_sock){
dst->to=to;
return dst; /* found a good one */
@@ -313,7 +314,8 @@ inline static struct dest_info *uri2dst(struct dest_info* dst,
ERR("failed to resolve \"%.*s\"\n", host->len, ZSW(host->s));
return 0;
}
- dst->send_sock = get_send_socket(msg, &dst->to, dst->proto);
+ dst->send_sock = get_send_socket2(force_send_socket, &dst->to,
+ dst->proto, 0);
if (dst->send_sock==0) {
ERR("no corresponding socket for af %d\n", dst->to.s.sa_family);
/* ser_error = E_NO_SOCKET;*/
@@ -323,6 +325,45 @@ inline static struct dest_info *uri2dst(struct dest_info* dst,
}
+
+/*
+ * Convert a URI into a dest_info structure
+ * If the uri host resolves to multiple ips and dns_h!=0 the first ip for
+ * which a send socket is found will be used. If no send_socket are found,
+ * the first ip is selected.
+ *
+ * params: dns_h - pointer to a valid dns_srv_handle structure (intialized!) or
+ * null. If null or use_dns_failover==0 normal dns lookup will
+ * be performed (no failover).
+ * dst - will be filled
+ * msg - sip message used to set dst->send_sock, if 0 dst->send_sock
+ * will be set to the default w/o using msg->force_send_socket
+ * (see get_send_socket())
+ * uri - uri in str form
+ * proto - if != PROTO_NONE, this protocol will be forced over the
+ * uri_proto, otherwise the uri proto will be used if set or
+ * the proto obtained from the dns lookup
+ * returns 0 on error, dst on success
+ */
+#ifdef USE_DNS_FAILOVER
+inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
+ struct dest_info* dst,
+ struct sip_msg *msg, str *uri,
+ int proto )
+{
+ return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0, uri, proto);
+}
+#else
+inline static struct dest_info *uri2dst(struct dest_info* dst,
+ struct sip_msg *msg, str *uri,
+ int proto )
+{
+ return uri2dst2(dst, msg?msg->force_send_socket:0, uri, proto);
+}
+#endif /* USE_DNS_FAILOVER */
+
+
+
#if 0
/*
* Convert a URI into the corresponding sockaddr_union (address to send to) and