forked from Mirrors/freeswitch
bs
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3118 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
458b6012a2
commit
747ab41f78
@ -1247,7 +1247,7 @@ static void j_setup_filter(ldl_handle_t *handle)
|
||||
|
||||
}
|
||||
|
||||
static void ldl_flush_queue(ldl_handle_t *handle)
|
||||
static void ldl_flush_queue(ldl_handle_t *handle, int done)
|
||||
{
|
||||
iks *msg;
|
||||
void *pop;
|
||||
@ -1280,7 +1280,7 @@ static void ldl_flush_queue(ldl_handle_t *handle)
|
||||
packet_node->next = now + 5000000;
|
||||
}
|
||||
}
|
||||
if (packet_node->retries == 0) {
|
||||
if (packet_node->retries == 0 || done) {
|
||||
if (globals.debug) {
|
||||
globals.logger(DL_LOG_DEBUG, "Discarding packet %s\n", packet_node->id);
|
||||
}
|
||||
@ -1302,7 +1302,7 @@ static void *APR_THREAD_FUNC queue_thread(apr_thread_t *thread, void *obj)
|
||||
ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
|
||||
|
||||
while (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
|
||||
ldl_flush_queue(handle);
|
||||
ldl_flush_queue(handle, 0);
|
||||
|
||||
if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
|
||||
int fd;
|
||||
@ -1414,7 +1414,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
|
||||
|
||||
|
||||
if (!ldl_test_flag(handle, LDL_FLAG_TLS) && ldl_test_flag(handle, LDL_FLAG_READY)) {
|
||||
ldl_flush_queue(handle);
|
||||
ldl_flush_queue(handle, 0);
|
||||
}
|
||||
|
||||
if (!ldl_test_flag(handle, LDL_FLAG_CONNECTED)) {
|
||||
@ -2022,7 +2022,7 @@ ldl_status ldl_handle_destroy(ldl_handle_t **handle)
|
||||
{
|
||||
apr_pool_t *pool = (*handle)->pool;
|
||||
|
||||
ldl_flush_queue(*handle);
|
||||
ldl_flush_queue(*handle, 1);
|
||||
|
||||
|
||||
apr_pool_destroy(pool);
|
||||
|
@ -413,6 +413,59 @@ static void roster_event_handler(switch_event_t *event)
|
||||
|
||||
}
|
||||
|
||||
static int so_callback(void *pArg, int argc, char **argv, char **columnNames)
|
||||
{
|
||||
struct mdl_profile *profile = (struct mdl_profile *) pArg;
|
||||
|
||||
char *sub_from = argv[0];
|
||||
char *sub_to = argv[1];
|
||||
|
||||
|
||||
ldl_handle_send_presence(profile->handle, sub_to, sub_from, "unavailable", "dnd", "Bub-Bye");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sign_off(void)
|
||||
{
|
||||
struct mdl_profile *profile = NULL;
|
||||
switch_hash_index_t *hi;
|
||||
void *val;
|
||||
char *sql;
|
||||
switch_core_db_t *db;
|
||||
|
||||
|
||||
sql = switch_mprintf("select * from subscriptions");
|
||||
|
||||
|
||||
for (hi = switch_hash_first(apr_hash_pool_get(globals.profile_hash), globals.profile_hash); hi; hi = switch_hash_next(hi)) {
|
||||
char *errmsg;
|
||||
switch_hash_this(hi, NULL, NULL, &val);
|
||||
profile = (struct mdl_profile *) val;
|
||||
|
||||
if (!(profile->user_flags & LDL_FLAG_COMPONENT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (sql) {
|
||||
if (!(db = switch_core_db_open_file(profile->dbname))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB %s\n", profile->dbname);
|
||||
continue;
|
||||
}
|
||||
switch_mutex_lock(profile->mutex);
|
||||
switch_core_db_exec(db, sql, so_callback, profile, &errmsg);
|
||||
switch_mutex_unlock(profile->mutex);
|
||||
switch_core_db_close(db);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch_yield(1000000);
|
||||
switch_safe_free(sql);
|
||||
|
||||
}
|
||||
|
||||
static void terminate_session(switch_core_session_t **session, int line, switch_call_cause_t cause)
|
||||
{
|
||||
if (*session) {
|
||||
@ -1549,6 +1602,8 @@ static switch_status_t init_profile(struct mdl_profile *profile, uint8_t login)
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void)
|
||||
{
|
||||
sign_off();
|
||||
|
||||
if (globals.running) {
|
||||
int x = 0;
|
||||
globals.running = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user