THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#77 - presence_xml with db_postgres
User who did this - Andrey A Berekelya (bandry)
----------
1. For BLOBs \0 is not needed. \0 is needed for string terminate.
2. In db_mysql (km_val.c) all lines are complemented by zero.
3. In presence_xml (notify_body.c) check strlen (body_array[i]->s) and body_array[i]->len shows different values. The value of strlen (body_array[i]->s) is always greater than body_array[i]->len.
4. The output value body_array[i]->s in the log showed that the line does not terminated \0 at the end.
5. It`s work :)
----------
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=77#comment86
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
Module: sip-router
Branch: andrei/raw_sock
Commit: 2f0276f711ba7aad9ffa1de0445f75df015abbad
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2f0276f…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Jun 8 00:21:08 2010 +0200
core: basic raw socket support functions
Basic support for raw sockets. Functions for creating, sending and
receiving udp packets over raw sockets.
Initial version supports only linux.
---
raw_sock.c | 452 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
raw_sock.h | 52 +++++++
2 files changed, 504 insertions(+), 0 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=2f0…
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#77 - presence_xml with db_postgres
User who did this - Klaus Darilion (klaus3000)
----------
Hi Andrey!
Thank's for the patch.
I wonder why BLOBs need to be null-terminated. Have you found a reference in libpq stating that BLOBs need to be null terminated? Or have you just tried it and it works? Or is there some other code in sip-router needed the \0 at the end of the BLOB?
PS: Please next time use unified diffs.
----------
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=77#comment85
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
Module: sip-router
Branch: andrei/tcp_tls_changes
Commit: d01e95b109558e283d91674858af959db9f83f59
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d01e95b…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Jun 18 15:01:01 2010 +0200
io_wait: fix kqueue io_wait_add & POLLIN
A "goto error" was placed outside the error handling "if",
resulting in any io_watch_add(), that tried to enable write
watching on a new FD, returning failure (fortunately this kind
of io_watch_add() usage doesn't happen very often, usually write
watch is enabled via io_watch_chg() on FDs already
io_watch_add()'ed for reading).
Only POLL_KQUEUE was affect by this bug, meaning the default on
all *bsd and darwin.
---
io_wait.h | 105 +++++++++++++++++++++++++++++++++++++------------------------
1 files changed, 64 insertions(+), 41 deletions(-)
diff --git a/io_wait.h b/io_wait.h
index 01df1e6..e04efd8 100644
--- a/io_wait.h
+++ b/io_wait.h
@@ -148,7 +148,9 @@ struct io_wait_handler{
int flags;
struct fd_map* fd_hash;
int fd_no; /* current index used in fd_array and the passed size for
- ep_array & kq_array*/
+ ep_array (for kq_array at least
+ max(twice the size, kq_changes_size) should be
+ be passed). */
int max_fd_no; /* maximum fd no, is also the size of fd_array,
fd_hash and ep_array*/
/* common stuff for POLL, SIGIO_RT and SELECT
@@ -170,6 +172,7 @@ struct io_wait_handler{
struct kevent* kq_array; /* used for the eventlist*/
struct kevent* kq_changes; /* used for the changelist */
size_t kq_nchanges;
+ size_t kq_array_size; /* array size */
size_t kq_changes_size; /* size of the changes array */
#endif
#ifdef HAVE_DEVPOLL
@@ -259,34 +262,33 @@ static inline int kq_ev_change(io_wait_h* h, int fd, int filter, int flag,
again:
n=kevent(h->kq_fd, h->kq_changes, h->kq_nchanges, 0, 0, &tspec);
if (unlikely(n == -1)){
- if (likely(errno == EBADF)) {
+ if (unlikely(errno == EINTR)) goto again;
+ else {
+ /* for a detailed explanation of what follows see
+ io_wait_loop_kqueue EV_ERROR case */
+ if (unlikely(!(errno == EBADF || errno == ENOENT)))
+ BUG("kq_ev_change: kevent flush changes failed"
+ " (unexpected error): %s [%d]\n",
+ strerror(errno), errno);
+ /* ignore error even if it's not a EBADF/ENOENT */
/* one of the file descriptors is bad, probably already
closed => try to apply changes one-by-one */
for (r = 0; r < h->kq_nchanges; r++) {
retry2:
n = kevent(h->kq_fd, &h->kq_changes[r], 1, 0, 0, &tspec);
if (n==-1) {
- if (errno == EBADF)
- continue; /* skip over it */
- if (errno == EINTR)
+ if (unlikely(errno == EINTR))
goto retry2;
- LOG(L_ERR, "ERROR: io_watch_add: kevent flush changes"
- " failed: %s [%d]\n",
- strerror(errno), errno);
- /* shift the array */
- memmove(&h->kq_changes[0], &h->kq_changes[r+1],
- sizeof(h->kq_changes[0])*
- (h->kq_nchanges-r-1));
- h->kq_nchanges-=(r+1);
- return -1;
+ /* for a detailed explanation of what follows see
+ io_wait_loop_kqueue EV_ERROR case */
+ if (unlikely(!(errno == EBADF || errno == ENOENT)))
+ BUG("kq_ev_change: kevent flush changes failed:"
+ " (unexpected error) %s [%d] (%d/%d)\n",
+ strerror(errno), errno,
+ r, h->kq_nchanges);
+ continue; /* skip over it */
}
}
- } else if (errno == EINTR) goto again;
- else {
- LOG(L_ERR, "ERROR: io_watch_add: kevent flush changes"
- " failed: %s [%d]\n", strerror(errno), errno);
- h->kq_nchanges=0; /* reset changes array */
- return -1;
}
}
h->kq_nchanges=0; /* changes array is empty */
@@ -499,7 +501,7 @@ again2:
case POLL_KQUEUE:
if (likely( events & POLLIN)){
if (unlikely(kq_ev_change(h, fd, EVFILT_READ, EV_ADD, e)==-1))
- goto error;
+ goto error;
}
if (unlikely( events & POLLOUT)){
if (unlikely(kq_ev_change(h, fd, EVFILT_WRITE, EV_ADD, e)==-1))
@@ -507,8 +509,8 @@ again2:
if (likely(events & POLLIN)){
kq_ev_change(h, fd, EVFILT_READ, EV_DELETE, 0);
}
+ goto error;
}
- goto error;
}
break;
#endif
@@ -1116,19 +1118,20 @@ inline static int io_wait_loop_kqueue(io_wait_h* h, int t, int repeat)
do {
again:
n=kevent(h->kq_fd, h->kq_changes, apply_changes, h->kq_array,
- h->fd_no, &tspec);
+ h->kq_array_size, &tspec);
if (unlikely(n==-1)){
- if (errno==EINTR) goto again; /* signal, ignore it */
- else if (errno==EBADF) {
+ if (unlikely(errno==EINTR)) goto again; /* signal, ignore it */
+ else {
+ /* for a detailed explanation of what follows see below
+ the EV_ERROR case */
+ if (unlikely(!(errno==EBADF || errno==ENOENT)))
+ BUG("io_wait_loop_kqueue: kevent: unexpected error"
+ " %s [%d]\n", strerror(errno), errno);
/* some of the FDs in kq_changes are bad (already closed)
and there is not enough space in kq_array to return all
of them back */
- apply_changes = h->fd_no;
+ apply_changes = h->kq_array_size;
goto again;
- }else{
- LOG(L_ERR, "ERROR: io_wait_loop_kqueue: kevent:"
- " %s [%d]\n", strerror(errno), errno);
- goto error;
}
}
/* remove applied changes */
@@ -1148,14 +1151,13 @@ again:
r, n, h->kq_array[r].ident, (long)h->kq_array[r].udata,
h->kq_array[r].flags);
#endif
- if (unlikely((h->kq_array[r].flags & EV_ERROR) &&
- (h->kq_array[r].data == EBADF ||
- h->kq_array[r].udata == 0))){
+ if (unlikely((h->kq_array[r].flags & EV_ERROR) ||
+ h->kq_array[r].udata == 0)){
/* error in changes: we ignore it if it has to do with a
bad fd or update==0. It can be caused by trying to remove an
already closed fd: race between adding something to the
- changes array, close() and applying the changes.
- E.g. for ser tcp: tcp_main sends a fd to child fore reading
+ changes array, close() and applying the changes (EBADF).
+ E.g. for ser tcp: tcp_main sends a fd to child for reading
=> deletes it from the watched fds => the changes array
will contain an EV_DELETE for it. Before the changes
are applied (they are at the end of the main io_wait loop,
@@ -1163,6 +1165,16 @@ again:
to tcp_main by a sender (send fail) is processed and causes
the fd to be closed. When the changes are applied =>
error for the EV_DELETE attempt of a closed fd.
+ Something similar can happen when a fd is scheduled
+ for removal, is close()'ed before being removed and
+ re-opened(a new sock. get the same fd). When the
+ watched fd changes will be applied the fd will be valid
+ (so no EBADF), but it's not already watch => ENOENT.
+ We report a BUG for the other errors (there's nothing
+ constructive we can do if we get an error we don't know
+ how to handle), but apart from that we ignore it in the
+ idea that it is better apply the rest of the changes,
+ rather then dropping all of them.
*/
/*
example EV_ERROR for trying to delete a read watched fd,
@@ -1176,9 +1188,12 @@ again:
udata = 0x0
}
*/
- if (h->kq_array[r].data != EBADF)
- LOG(L_INFO, "INFO: io_wait_loop_kqueue: kevent error on "
- "fd %ld: %s [%ld]\n", (long)h->kq_array[r].ident,
+ if (h->kq_array[r].data != EBADF &&
+ h->kq_array[r].data != ENOENT)
+ BUG("io_wait_loop_kqueue: kevent unexpected error on "
+ "fd %ld udata %lx: %s [%ld]\n",
+ (long)h->kq_array[r].ident,
+ (long)h->kq_array[r].udata,
strerror(h->kq_array[r].data),
(long)h->kq_array[r].data);
}else{
@@ -1186,20 +1201,28 @@ again:
if (likely(h->kq_array[r].filter==EVFILT_READ)){
revents=POLLIN |
(((int)!(h->kq_array[r].flags & EV_EOF)-1)&POLLHUP) |
- (((int)!(h->kq_array[r].flags & EV_ERROR)-1)&POLLERR);
+ (((int)!((h->kq_array[r].flags & EV_EOF) &&
+ h->kq_array[r].fflags != 0) - 1)&POLLERR);
while(fm->type && (fm->events & revents) &&
(handle_io(fm, revents, -1)>0) && repeat);
}else if (h->kq_array[r].filter==EVFILT_WRITE){
revents=POLLOUT |
(((int)!(h->kq_array[r].flags & EV_EOF)-1)&POLLHUP) |
- (((int)!(h->kq_array[r].flags & EV_ERROR)-1)&POLLERR);
+ (((int)!((h->kq_array[r].flags & EV_EOF) &&
+ h->kq_array[r].fflags != 0) - 1)&POLLERR);
while(fm->type && (fm->events & revents) &&
(handle_io(fm, revents, -1)>0) && repeat);
+ }else{
+ BUG("io_wait_loop_kqueue: unknown filter: kqueue: event "
+ "%d/%d: fd=%d, filter=%d, flags=0x%x, fflags=0x%x,"
+ " data=%lx, udata=%lx\n",
+ r, n, h->kq_array[r].ident, h->kq_array[r].filter,
+ h->kq_array[r].flags, h->kq_array[r].fflags,
+ (long)h->kq_array[r].data, (long)h->kq_array[r].udata);
}
}
}
} while(unlikely(orig_changes));
-error:
return n;
}
#endif
Module: sip-router
Branch: andrei/tcp_tls_changes
Commit: 2d8cd170ab867ab15296b30f0b784abe1adc1bca
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2d8cd17…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Jun 18 09:48:21 2010 +0200
io_wait: don't update FD watched status on error
If the syscall to change the events or delete a watched FD fails,
don't update/delete the FD status in fd_hash.
For /dev/poll if a change fails when re-adding the FD, delete it
from the hash (in the /dev/poll case to change the events a FD is
watched for one has to remove it and re-add it with the new
events).
The syscalls should never fail in an un-handled way, but in the
unlikely event that it happens this change will make the code more
robust.
---
io_wait.h | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/io_wait.h b/io_wait.h
index 93f1426..01df1e6 100644
--- a/io_wait.h
+++ b/io_wait.h
@@ -627,7 +627,6 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx, int flags)
goto error;
}
events=e->events;
- unhash_fd_map(e);
switch(h->poll_method){
case POLL_POLL:
@@ -647,7 +646,6 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx, int flags)
#endif
#ifdef HAVE_SIGIO_RT
case POLL_SIGIO_RT:
- fix_fd_array;
/* the O_ASYNC flag must be reset all the time, the fd
* can be changed only if O_ASYNC is reset (if not and
* the fd is a duplicate, you will get signals from the dup. fd
@@ -667,6 +665,7 @@ inline static int io_watch_del(io_wait_h* h, int fd, int idx, int flags)
" failed: %s [%d]\n", strerror(errno), errno);
goto error;
}
+ fix_fd_array; /* only on success */
break;
#endif
#ifdef HAVE_EPOLL
@@ -737,6 +736,7 @@ again_devpoll:
h->poll_method);
goto error;
}
+ unhash_fd_map(e); /* only on success */
h->fd_no--;
return 0;
error:
@@ -808,14 +808,14 @@ inline static int io_watch_chg(io_wait_h* h, int fd, short events, int idx )
add_events=events & ~e->events;
del_events=e->events & ~events;
- e->events=events;
switch(h->poll_method){
case POLL_POLL:
+ fd_array_chg(events
#ifdef POLLRDHUP
- /* listen to POLLRDHUP by default (if POLLIN) */
- events|=((int)!(events & POLLIN) - 1) & POLLRDHUP;
+ /* listen to POLLRDHUP by default (if POLLIN) */
+ | (((int)!(events & POLLIN) - 1) & POLLRDHUP)
#endif /* POLLRDHUP */
- fd_array_chg(events);
+ );
break;
#ifdef HAVE_SELECT
case POLL_SELECT:
@@ -921,6 +921,8 @@ again_devpoll2:
LOG(L_ERR, "ERROR: io_watch_chg: re-adding fd to "
"/dev/poll failed: %s [%d]\n",
strerror(errno), errno);
+ /* error re-adding the fd => mark it as removed/unhash */
+ unhash_fd_map(e);
goto error;
}
break;
@@ -931,6 +933,7 @@ again_devpoll2:
h->poll_method);
goto error;
}
+ e->events=events; /* only on success */
return 0;
error:
return -1;
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A new Flyspray task has been opened. Details are below.
User who did this - Andrey A Berekelya (bandry)
Attached to Project - sip-router
Summary - presence_xml with db_postgres
Task Type - Bug Report
Category - Module
Status - Unconfirmed
Assigned To -
Operating System - All
Severity - Medium
Priority - Normal
Reported Version - Development
Due in Version - Undecided
Due Date - Undecided
Details - In modules/db_postgres/km_val.c: the functions db_postgres_str2val string not terminate '\0', as the result the processing of a string BLOB fields is wrong. In particular, presence_xml is not working properly and cause the error:
'ERROR: presence_xml [notify_body.c:515]: while parsing xml body message'
patch:
=====================================================================
75c75,76
< VAL_BLOB(_v).s = pkg_malloc(VAL_BLOB(_v).len);
---
> VAL_BLOB(_v).s = pkg_malloc(VAL_BLOB(_v).len + 1);
>
81c82
< LM_DBG("allocate %d bytes memory for BLOB at %p", VAL_BLOB(_v).len, VAL_BLOB(_v).s);
---
> LM_DBG("allocate %d bytes memory for BLOB at %p", VAL_BLOB(_v).len + 1, VAL_BLOB(_v).s);
82a84,85
> VAL_BLOB(_v).s[VAL_BLOB(_v).len] = '\0';
> VAL_BLOB(_v).len++;
=====================================================================
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=77
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
Module: sip-router
Branch: andrei/tcp_tls_changes
Commit: 05c080a53f88babad6729f79015f555f53fdf957
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=05c080a…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu - Onciul <andrei(a)sfantu-petru.ultima>
Date: Thu Jun 17 16:15:10 2010 +0200
io_wait: fix: check for EV_ERROR for kqueue()
Re-enabled and enhanced the check for EV_ERROR when using kqueue
(*bsd). This is needed to workaround errors reported by kqueue
when trying to delete (EV_DELETE) an already closed FD (this
can happen in the tcp code, where we try to avoid applying
immediately changes in the set of watched FDs and instead
collect them and apply them after all the current kqueue
events are processed => in some corner case situations it's
possible to try to delete the FD from kqueue after the fd
was close()'ed).
This fix will ignore EV_ERROR with data == EBADF. All the other
errors will result in a POLLERR flag for the callback.
It fixes crashes with *bsd under tcp stress tests (lots of very
short lived connections).
---
io_wait.h | 55 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/io_wait.h b/io_wait.h
index 0557c00..44ef60c 100644
--- a/io_wait.h
+++ b/io_wait.h
@@ -45,6 +45,7 @@
* 2007-11-29 support for write (POLLOUT); added io_watch_chg() (andrei)
* 2008-02-04 POLLRDHUP & EPOLLRDHUP support (automatically enabled if POLLIN
* is set) (andrei)
+ * 2010-06-17 re-enabled & enhanced the EV_ERROR for kqueue (andrei)
*/
@@ -1097,31 +1098,55 @@ again:
r, n, h->kq_array[r].ident, (long)h->kq_array[r].udata,
h->kq_array[r].flags);
#endif
-#if 0
- if (unlikely(h->kq_array[r].flags & EV_ERROR)){
- /* error in changes: we ignore it, it can be caused by
- trying to remove an already closed fd: race between
- adding something to the changes array, close() and
- applying the changes */
- LOG(L_INFO, "INFO: io_wait_loop_kqueue: kevent error on "
- "fd %ld: %s [%ld]\n", h->kq_array[r].ident,
+ if (unlikely((h->kq_array[r].flags & EV_ERROR) &&
+ (h->kq_array[r].data == EBADF ||
+ h->kq_array[r].udata == 0))){
+ /* error in changes: we ignore it if it has to do with a
+ bad fd or update==0. It can be caused by trying to remove an
+ already closed fd: race between adding something to the
+ changes array, close() and applying the changes.
+ E.g. for ser tcp: tcp_main sends a fd to child fore reading
+ => deletes it from the watched fds => the changes array
+ will contain an EV_DELETE for it. Before the changes
+ are applied (they are at the end of the main io_wait loop,
+ after all the fd events were processed), a CON_ERR sent
+ to tcp_main by a sender (send fail) is processed and causes
+ the fd to be closed. When the changes are applied =>
+ error for the EV_DELETE attempt of a closed fd.
+ */
+ /*
+ example EV_ERROR for trying to delete a read watched fd,
+ that was already closed:
+ {
+ ident = 63, [fd]
+ filter = -1, [EVFILT_READ]
+ flags = 16384, [EV_ERROR]
+ fflags = 0,
+ data = 9, [errno = EBADF]
+ udata = 0x0
+ }
+ */
+ if (h->kq_array[r].data != EBADF)
+ LOG(L_INFO, "INFO: io_wait_loop_kqueue: kevent error on "
+ "fd %ld: %s [%ld]\n", (long)h->kq_array[r].ident,
strerror(h->kq_array[r].data),
(long)h->kq_array[r].data);
- }else{
-#endif
+ }else{
fm=(struct fd_map*)h->kq_array[r].udata;
if (likely(h->kq_array[r].filter==EVFILT_READ)){
- revents=POLLIN |
- (((int)!(h->kq_array[r].flags & EV_EOF)-1)&POLLHUP);
+ revents=POLLIN |
+ (((int)!(h->kq_array[r].flags & EV_EOF)-1)&POLLHUP) |
+ (((int)!(h->kq_array[r].flags & EV_ERROR)-1)&POLLERR);
while(fm->type && (fm->events & revents) &&
(handle_io(fm, revents, -1)>0) && repeat);
}else if (h->kq_array[r].filter==EVFILT_WRITE){
- revents=POLLOUT |
- (((int)!(h->kq_array[r].flags & EV_EOF)-1)&POLLHUP);
+ revents=POLLOUT |
+ (((int)!(h->kq_array[r].flags & EV_EOF)-1)&POLLHUP) |
+ (((int)!(h->kq_array[r].flags & EV_ERROR)-1)&POLLERR);
while(fm->type && (fm->events & revents) &&
(handle_io(fm, revents, -1)>0) && repeat);
}
- /*} */
+ }
}
error:
return n;
i compared s and k auth_radius modules and they are so different that it
does not make sense to try to merge them.
would it instead make sense to modify k auth_radius to use s auth module
api, i.e., would the benefits that s auth module provides over k auth
module then become available for k auth_radius users?
-- juha