forked from Mirrors/freeswitch
FS-3612 --resolve
This commit is contained in:
parent
743dbbf992
commit
326de638b2
|
@ -838,12 +838,12 @@ static void do_presence(ldl_handle_t *handle, char *from, char *to, char *type,
|
||||||
char buf[512];
|
char buf[512];
|
||||||
iks *tag;
|
iks *tag;
|
||||||
|
|
||||||
if (!strchr(from, '/')) {
|
if (from && !strchr(from, '/')) {
|
||||||
snprintf(buf, sizeof(buf), "%s/talk", from);
|
snprintf(buf, sizeof(buf), "%s/talk", from);
|
||||||
from = buf;
|
from = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ldl_test_flag(handle, LDL_FLAG_COMPONENT) && ldl_jid_domcmp(from, to)) {
|
if (ldl_test_flag(handle, LDL_FLAG_COMPONENT) && from && to && ldl_jid_domcmp(from, to)) {
|
||||||
globals.logger(DL_LOG_ERR, "Refusal to send presence from and to the same domain in component mode [%s][%s]\n", from, to);
|
globals.logger(DL_LOG_ERR, "Refusal to send presence from and to the same domain in component mode [%s][%s]\n", from, to);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1372,7 +1372,6 @@ static void on_log(ldl_handle_t *handle, const char *data, size_t size, int is_i
|
||||||
} else {
|
} else {
|
||||||
globals.logger(DL_LOG_NOTICE, "+xml:%s%s:%s", iks_is_secure(handle->parser) ? "Sec" : "", is_incoming ? "RECV" : "SEND", data);
|
globals.logger(DL_LOG_NOTICE, "+xml:%s%s:%s", iks_is_secure(handle->parser) ? "Sec" : "", is_incoming ? "RECV" : "SEND", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1444,7 +1443,11 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done)
|
||||||
while(apr_queue_trypop(handle->queue, &pop) == APR_SUCCESS) {
|
while(apr_queue_trypop(handle->queue, &pop) == APR_SUCCESS) {
|
||||||
if (pop) {
|
if (pop) {
|
||||||
msg = (iks *) pop;
|
msg = (iks *) pop;
|
||||||
if (!done) iks_send(handle->parser, msg);
|
if (!done) {
|
||||||
|
if (iks_send(handle->parser, msg) != IKS_OK) {
|
||||||
|
globals.logger(DL_LOG_DEBUG, "Failed sending data!\n");
|
||||||
|
};
|
||||||
|
};
|
||||||
iks_delete(msg);
|
iks_delete(msg);
|
||||||
pop = NULL;
|
pop = NULL;
|
||||||
sent_data = LDL_QUEUE_SENT;
|
sent_data = LDL_QUEUE_SENT;
|
||||||
|
@ -1474,7 +1477,9 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done)
|
||||||
if (globals.debug) {
|
if (globals.debug) {
|
||||||
globals.logger(DL_LOG_DEBUG, "Sending packet %s (%d left)\n", packet_node->id, packet_node->retries);
|
globals.logger(DL_LOG_DEBUG, "Sending packet %s (%d left)\n", packet_node->id, packet_node->retries);
|
||||||
}
|
}
|
||||||
iks_send(handle->parser, packet_node->xml);
|
if (iks_send(handle->parser, packet_node->xml) != IKS_OK) {
|
||||||
|
globals.logger(DL_LOG_DEBUG, "Failed trying re-sending data!\n");
|
||||||
|
};
|
||||||
packet_node->next = now + 5000000;
|
packet_node->next = now + 5000000;
|
||||||
sent_data = LDL_QUEUE_SENT;
|
sent_data = LDL_QUEUE_SENT;
|
||||||
}
|
}
|
||||||
|
@ -1500,8 +1505,8 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done)
|
||||||
|
|
||||||
static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
||||||
{
|
{
|
||||||
int timeout_ka = LDL_KEEPALIVE_TIMEOUT;
|
int count_ka = LDL_KEEPALIVE_TIMEOUT;
|
||||||
int count_ka = timeout_ka;
|
time_t tstart, tnow;
|
||||||
|
|
||||||
while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
|
while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
|
||||||
int e;
|
int e;
|
||||||
|
@ -1532,6 +1537,8 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
||||||
|
|
||||||
j_setup_filter(handle);
|
j_setup_filter(handle);
|
||||||
|
|
||||||
|
globals.logger(DL_LOG_DEBUG, "xmpp connecting\n");
|
||||||
|
|
||||||
e = iks_connect_via(handle->parser,
|
e = iks_connect_via(handle->parser,
|
||||||
handle->server ? handle->server : handle->acc->server,
|
handle->server ? handle->server : handle->acc->server,
|
||||||
handle->port ? handle->port : IKS_JABBER_PORT,
|
handle->port ? handle->port : IKS_JABBER_PORT,
|
||||||
|
@ -1555,17 +1562,13 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->counter = opt_timeout;
|
handle->counter = opt_timeout;
|
||||||
|
if ((tstart = time(NULL)) == -1) {
|
||||||
|
globals.logger(DL_LOG_DEBUG, "error determining connection time");
|
||||||
|
}
|
||||||
|
|
||||||
while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
|
while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
|
||||||
e = iks_recv(handle->parser, 1);
|
e = iks_recv(handle->parser, 1);
|
||||||
|
|
||||||
if (count_ka-- <= 0) {
|
|
||||||
if( iks_send_raw(handle->parser, " ") == IKS_OK) {
|
|
||||||
count_ka = timeout_ka;
|
|
||||||
globals.logger(DL_LOG_DEBUG, "Sent keep alive signal\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handle->loop_callback) {
|
if (handle->loop_callback) {
|
||||||
if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
|
if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
|
||||||
ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
|
ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
|
||||||
|
@ -1582,14 +1585,24 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IKS_OK != e || ldl_test_flag(handle, LDL_FLAG_BREAK)) {
|
if (IKS_OK != e || ldl_test_flag(handle, LDL_FLAG_BREAK)) {
|
||||||
globals.logger(DL_LOG_DEBUG, "io error 2 %d retry in %d second(s)\n", e, ++handle->fail_count);
|
globals.logger(DL_LOG_DEBUG, "io error 2 %d retry in %d second(s)", e, ++handle->fail_count);
|
||||||
|
if ((tnow = time(NULL)) == -1) {
|
||||||
|
globals.logger(DL_LOG_DEBUG, "error deterniming io error time");
|
||||||
|
}
|
||||||
|
if (difftime(tnow, tstart) > 30) {
|
||||||
|
/* this is a new error situation: reset counter */
|
||||||
|
globals.logger(DL_LOG_DEBUG, "resetting fail count");
|
||||||
|
handle->fail_count = 1;
|
||||||
|
}
|
||||||
microsleep(1000 * handle->fail_count);
|
microsleep(1000 * handle->fail_count);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
|
if (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
|
||||||
ldl_flush_queue(handle, 0);
|
if (ldl_flush_queue(handle, 0) == LDL_QUEUE_SENT) {
|
||||||
}
|
count_ka = LDL_KEEPALIVE_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handle->counter--;
|
handle->counter--;
|
||||||
if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
|
if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
|
||||||
|
@ -1606,7 +1619,17 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
microsleep(100);
|
if (count_ka-- <= 0) {
|
||||||
|
if( iks_send_raw(handle->parser, " ") == IKS_OK) {
|
||||||
|
globals.logger(DL_LOG_DEBUG, "Sent keep alive signal");
|
||||||
|
count_ka = LDL_KEEPALIVE_TIMEOUT;
|
||||||
|
} else {
|
||||||
|
globals.logger(DL_LOG_DEBUG, "Failed sending keep alive signal");
|
||||||
|
microsleep(500);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
|
@ -64,8 +64,8 @@ extern "C" {
|
||||||
#define LDL_MAX_PAYLOADS 50
|
#define LDL_MAX_PAYLOADS 50
|
||||||
#define LDL_RETRY 3
|
#define LDL_RETRY 3
|
||||||
#define IKS_NS_COMPONENT "jabber:component:accept"
|
#define IKS_NS_COMPONENT "jabber:component:accept"
|
||||||
/* period between keep alive signals in 0.1sec units*/
|
/* period between keep alive signals in 1sec units*/
|
||||||
#define LDL_KEEPALIVE_TIMEOUT 6000
|
#define LDL_KEEPALIVE_TIMEOUT 300
|
||||||
|
|
||||||
/*! \brief A structure to store a jingle candidate */
|
/*! \brief A structure to store a jingle candidate */
|
||||||
struct ldl_candidate {
|
struct ldl_candidate {
|
||||||
|
|
Loading…
Reference in New Issue