[asterisk-commits] trunk r29825 - /trunk/res/res_jabber.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue May 23 13:25:23 MST 2006
Author: mogorman
Date: Tue May 23 15:25:23 2006
New Revision: 29825
URL: http://svn.digium.com/view/asterisk?rev=29825&view=rev
Log:
fixes bug where server goes away.
Modified:
trunk/res/res_jabber.c
Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?rev=29825&r1=29824&r2=29825&view=diff
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Tue May 23 15:25:23 2006
@@ -435,7 +435,6 @@
iks *auth = NULL;
pak = iks_packet(node);
-
if (client->component == AJI_CLIENT) {
switch (type) {
@@ -1330,30 +1329,30 @@
static void *aji_recv_loop(void *data)
{
struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
- int res = 0;
- while (res == IKS_OK) {
+ int res = IKS_HOOK;
+ do {
+ if (res != IKS_OK) {
+ while(res != IKS_OK) {
+ if(option_verbose > 3) ast_verbose("JABBER: reconnecting.\n");
+ sleep(4);
+ res = aji_reconnect(client);
+ }
+ }
res = iks_recv(client->p, 1);
client->timeout--;
if (res == IKS_HOOK) {
ast_log(LOG_WARNING, "JABBER: Got hook event.\n");
break;
} else if (res == IKS_NET_TLSFAIL) {
- ast_log(LOG_ERROR, "JABBER: Failure in tls.\n");
+ ast_log(LOG_WARNING, "JABBER: Failure in tls.\n");
break;
} else if (client->timeout == 0 && client->state != AJI_CONNECTED) {
res = -1;
ast_log(LOG_WARNING, "JABBER: Network Timeout\n");
} else if (res == IKS_NET_RWERR) {
- ast_log(LOG_ERROR, "JABBER: socket read error\n");
- }
-
- if (res != IKS_OK) {
- if(option_verbose > 3) ast_verbose("JABBER: reconnecting %d\n", res);
- aji_reconnect(client);
- res = IKS_OK;
- }
-
- }
+ ast_log(LOG_WARNING, "JABBER: socket read error\n");
+ }
+ } while (res == IKS_OK);
ASTOBJ_UNREF(client, aji_client_destroy);
return 0;
}
@@ -1688,14 +1687,13 @@
if (connected == IKS_NET_NOCONN) {
ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n");
- return 0;
- }
- if (connected == IKS_NET_NODNS) {
+ return IKS_HOOK;
+ } else if (connected == IKS_NET_NODNS) {
ast_log(LOG_ERROR, "JABBER ERROR: No DNS\n");
- return 0;
+ return IKS_HOOK;
} else
iks_recv(client->p, 30);
- return 1;
+ return IKS_OK;
}
/*!
@@ -2164,8 +2162,7 @@
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
ASTOBJ_RDLOCK(iterator);
if(iterator->state == AJI_DISCONNECTED) {
- res = aji_reconnect(iterator);
- if (res != -1 && !iterator->thread)
+ if (!iterator->thread)
ast_pthread_create(&iterator->thread, NULL, aji_recv_loop, iterator);
} else if (iterator->state == AJI_CONNECTED) {
aji_get_roster(iterator);
More information about the asterisk-commits
mailing list