aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authormogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-23 20:25:23 +0000
committermogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-23 20:25:23 +0000
commit7c5f693cf41b37b303fa117320aaa30f85b0853c (patch)
treea1b35622ff685579e8950f029dfd01abaa966b8c /res
parentbbff5301f8ca2316323bb77939ba2afa03008651 (diff)
fixes bug where server goes away.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@29825 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r--res/res_jabber.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c
index b3a7bbc73..ed7b5e74f 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -436,7 +436,6 @@ static int aji_act_hook(void *data, int type, iks *node)
pak = iks_packet(node);
-
if (client->component == AJI_CLIENT) {
switch (type) {
case IKS_NODE_START:
@@ -1330,30 +1329,30 @@ int ast_aji_invite_chat(struct aji_client *client, char *user, char *room, char
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 @@ static int aji_client_initialize(struct aji_client *client)
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 @@ static void aji_reload()
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);