[Freeswitch-svn] [commit] r4968 - in freeswitch/trunk/libs: iksemel/include iksemel/src libdingaling/src
Freeswitch SVN
anthm at freeswitch.org
Wed Apr 18 12:10:47 EDT 2007
Author: anthm
Date: Wed Apr 18 12:10:46 2007
New Revision: 4968
Modified:
freeswitch/trunk/libs/iksemel/include/iksemel.h
freeswitch/trunk/libs/iksemel/src/filter.c
freeswitch/trunk/libs/iksemel/src/iks.c
freeswitch/trunk/libs/iksemel/src/ikstack.c
freeswitch/trunk/libs/iksemel/src/sax.c
freeswitch/trunk/libs/iksemel/src/utility.c
freeswitch/trunk/libs/libdingaling/src/libdingaling.c
Log:
update
Modified: freeswitch/trunk/libs/iksemel/include/iksemel.h
==============================================================================
--- freeswitch/trunk/libs/iksemel/include/iksemel.h (original)
+++ freeswitch/trunk/libs/iksemel/include/iksemel.h Wed Apr 18 12:10:46 2007
@@ -24,12 +24,13 @@
char *iks_stack_strdup (ikstack *s, const char *src, size_t len);
char *iks_stack_strcat (ikstack *s, char *old, size_t old_len, const char *src, size_t src_len);
void iks_stack_stat (ikstack *s, size_t *allocated, size_t *used);
-void iks_stack_delete (ikstack *s);
+void iks_stack_delete (ikstack **sp);
+
/***** utilities *****/
void *iks_malloc (size_t size);
-void iks_free (void *ptr);
+void iks_real_free (void *ptr);
void iks_set_mem_funcs (void *(*malloc_func)(size_t size), void (*free_func)(void *ptr));
char *iks_strdup (const char *src);
@@ -42,6 +43,8 @@
char *iks_escape (ikstack *s, char *src, size_t len);
char *iks_unescape (ikstack *s, char *src, size_t len);
+#define iks_free(p) if (p) {iks_real_free(p) ; p = NULL;}
+
/***** dom tree *****/
enum ikstype {
Modified: freeswitch/trunk/libs/iksemel/src/filter.c
==============================================================================
--- freeswitch/trunk/libs/iksemel/src/filter.c (original)
+++ freeswitch/trunk/libs/iksemel/src/filter.c Wed Apr 18 12:10:46 2007
@@ -96,7 +96,7 @@
if (rule->next) rule->next->prev = rule->prev;
if (f->rules == rule) f->rules = rule->next;
if (f->last_rule == rule) f->last_rule = rule->prev;
- iks_stack_delete (rule->s);
+ iks_stack_delete (&rule->s);
}
void
@@ -174,7 +174,7 @@
rule = f->rules;
while (rule) {
tmp = rule->next;
- iks_stack_delete (rule->s);
+ iks_stack_delete (&rule->s);
rule = tmp;
}
iks_free (f);
Modified: freeswitch/trunk/libs/iksemel/src/iks.c
==============================================================================
--- freeswitch/trunk/libs/iksemel/src/iks.c (original)
+++ freeswitch/trunk/libs/iksemel/src/iks.c Wed Apr 18 12:10:46 2007
@@ -60,7 +60,7 @@
if (!s) return NULL;
x = iks_new_within (name, s);
if (!x) {
- iks_stack_delete (s);
+ iks_stack_delete (&s);
return NULL;
}
return x;
@@ -202,7 +202,7 @@
void
iks_delete (iks *x)
{
- if (x) iks_stack_delete (x->s);
+ if (x) iks_stack_delete (&x->s);
}
/***** Node Traversing *****/
Modified: freeswitch/trunk/libs/iksemel/src/ikstack.c
==============================================================================
--- freeswitch/trunk/libs/iksemel/src/ikstack.c (original)
+++ freeswitch/trunk/libs/iksemel/src/ikstack.c Wed Apr 18 12:10:46 2007
@@ -182,10 +182,20 @@
}
void
-iks_stack_delete (ikstack *s)
+iks_stack_delete (ikstack **sp)
{
ikschunk *c, *tmp;
+ ikstack *s;
+ if (!sp) {
+ return;
+ }
+
+ s = *sp;
+
+ if (!s) {
+ return;
+ }
c = s->meta->next;
while (c) {
tmp = c->next;
@@ -199,4 +209,5 @@
c = tmp;
}
iks_free (s);
+ *sp = NULL;
}
Modified: freeswitch/trunk/libs/iksemel/src/sax.c
==============================================================================
--- freeswitch/trunk/libs/iksemel/src/sax.c (original)
+++ freeswitch/trunk/libs/iksemel/src/sax.c Wed Apr 18 12:10:46 2007
@@ -629,5 +629,5 @@
if (prs->deleteHook) prs->deleteHook (prs->user_data);
if (prs->stack) iks_free (prs->stack);
if (prs->atts) iks_free (prs->atts);
- if (prs->s) iks_stack_delete (prs->s); else iks_free (prs);
+ if (prs->s) iks_stack_delete (&prs->s); else iks_free (prs);
}
Modified: freeswitch/trunk/libs/iksemel/src/utility.c
==============================================================================
--- freeswitch/trunk/libs/iksemel/src/utility.c (original)
+++ freeswitch/trunk/libs/iksemel/src/utility.c Wed Apr 18 12:10:46 2007
@@ -22,7 +22,7 @@
}
void
-iks_free (void *ptr)
+iks_real_free (void *ptr)
{
if (my_free_func)
my_free_func (ptr);
Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c (original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c Wed Apr 18 12:10:46 2007
@@ -595,8 +595,8 @@
iks_insert_attrib(tag, "var", FEATURES[x].name);
}
}
-
- iks_send(handle->parser, iq);
+ apr_queue_push(handle->queue, iq);
+ iq = NULL;
send = 1;
}
fail:
@@ -919,8 +919,8 @@
iks_insert_attrib(x, "xmlns:gr", "google:roster");
iks_insert_attrib(x, "gr:ext", "2");
iks_insert_attrib(x, "gr:include", "all");
- iks_send(handle->parser, iq);
- iks_delete(iq);
+ apr_queue_push(handle->queue, iq);
+ iq = NULL;
break;
}
#endif
@@ -1123,14 +1123,14 @@
iks *t;
if (handle->features & IKS_STREAM_BIND) {
t = iks_make_resource_bind(handle->acc);
- iks_send(handle->parser, t);
- iks_delete(t);
+ apr_queue_push(handle->queue, t);
+ t = NULL;
}
if (handle->features & IKS_STREAM_SESSION) {
t = iks_make_session();
iks_insert_attrib(t, "id", "auth");
- iks_send(handle->parser, t);
- iks_delete(t);
+ apr_queue_push(handle->queue, t);
+ t = NULL;
}
} else {
if (handle->features & IKS_STREAM_SASL_MD5) {
@@ -1150,8 +1150,8 @@
slen = (uint32_t)(strlen(handle->acc->user) + strlen(handle->password) + 2);
b64encode((unsigned char *)s, slen, (unsigned char *) base64, sizeof(base64));
iks_insert_cdata(x, base64, 0);
- iks_send(handle->parser, x);
- iks_delete(x);
+ apr_queue_push(handle->queue, x);
+ x = NULL;
} else {
globals.logger(DL_LOG_DEBUG, "Memory ERROR!\n");
break;
@@ -1303,45 +1303,57 @@
static void ldl_flush_queue(ldl_handle_t *handle, int done)
{
iks *msg;
- void *pop;
+ void *pop = NULL;
unsigned int len = 0, x = 0;
while(apr_queue_trypop(handle->queue, &pop) == APR_SUCCESS) {
- msg = (iks *) pop;
- iks_send(handle->parser, msg);
- iks_delete(msg);
+ if (pop) {
+ msg = (iks *) pop;
+ iks_send(handle->parser, msg);
+ iks_delete(msg);
+ pop = NULL;
+ } else {
+ break;
+ }
}
len = apr_queue_size(handle->retry_queue);
-
if (globals.debug && len) {
globals.logger(DL_LOG_DEBUG, "Processing %u packets in retry queue\n", len);
}
apr_thread_mutex_lock(handle->lock);
+
+ pop = NULL;
+
while(x < len && apr_queue_trypop(handle->retry_queue, &pop) == APR_SUCCESS) {
- struct packet_node *packet_node = (struct packet_node *) pop;
- apr_time_t now = apr_time_now();
- x++;
-
- if (packet_node->next <= now) {
- if (packet_node->retries > 0) {
- packet_node->retries--;
- if (globals.debug) {
- globals.logger(DL_LOG_DEBUG, "Sending packet %s (%d left)\n", packet_node->id, packet_node->retries);
+ if (!pop) {
+ break;
+ } else {
+ struct packet_node *packet_node = (struct packet_node *) pop;
+ apr_time_t now = apr_time_now();
+ x++;
+
+ if (packet_node->next <= now) {
+ if (packet_node->retries > 0) {
+ packet_node->retries--;
+ if (globals.debug) {
+ globals.logger(DL_LOG_DEBUG, "Sending packet %s (%d left)\n", packet_node->id, packet_node->retries);
+ }
+ iks_send(handle->parser, packet_node->xml);
+ packet_node->next = now + 5000000;
}
- iks_send(handle->parser, packet_node->xml);
- packet_node->next = now + 5000000;
}
- }
- if (packet_node->retries == 0 || done) {
- if (globals.debug) {
- globals.logger(DL_LOG_DEBUG, "Discarding packet %s\n", packet_node->id);
+ if (packet_node->retries == 0 || done) {
+ if (globals.debug) {
+ globals.logger(DL_LOG_DEBUG, "Discarding packet %s\n", packet_node->id);
+ }
+ apr_hash_set(handle->retry_hash, packet_node->id, APR_HASH_KEY_STRING, NULL);
+ iks_delete(packet_node->xml);
+ free(packet_node);
+ } else {
+ apr_queue_push(handle->retry_queue, packet_node);
}
- apr_hash_set(handle->retry_hash, packet_node->id, APR_HASH_KEY_STRING, NULL);
- iks_delete(packet_node->xml);
- free(packet_node);
- } else {
- apr_queue_push(handle->retry_queue, packet_node);
+ pop = NULL;
}
}
apr_thread_mutex_unlock(handle->lock);
More information about the Freeswitch-svn
mailing list