#include "../../str.h"#include "../../db/db.h"#include "../../locking.h"#include "../tm/tm_load.h"#include "xjab_util.h"#include "tree234.h"


Go to the source code of this file.
| typedef struct _xj_jalias t_xj_jalias |
| typedef struct _xj_wlist t_xj_wlist |
| typedef struct _xj_worker t_xj_worker |
| typedef struct _xj_jalias * xj_jalias |
| typedef struct _xj_worker * xj_worker |
address correction alias A~B: flag == 0 => A->B, otherwise B->A
Definition at line 92 of file xjab_worker.c.
References _xj_pid, _xj_jalias::a, _xj_jalias::d, _xj_jalias::dlm, _xj_jalias::jdm, _str::len, LM_DBG, NULL, s, _str::s, _xj_jalias::size, XJ_ADDRTR_CON, XJ_ADDRTR_J2S, and XJ_ADDRTR_S2J.
Referenced by xj_manage_jab(), xj_worker_check_qmsg(), xj_worker_check_watcher(), and xj_worker_process().
parse incoming message from Jabber server
Definition at line 734 of file xjab_worker.c.
References _xj_jcon::allowed, _xj_pres_cell::cbf, _xj_pres_cell::cbp, _xj_jkey::flag, _xj_jkey::id, _xj_jcon::jkey, _str::len, LM_DBG, LM_ERR, _xj_jconf::nick, NULL, _xj_jcon::plist, _xj_jalias::proxy, _xj_jcon::ready, _str::s, _xj_pres_cell::state, _xj_jconf::status, _xj_jconf::uri, xj_address_translation(), XJ_ADDRTR_J2S, XJ_AIM_LEN, XJ_AIM_NAME, XJ_DMSG_ERR_JCONFNICK, XJ_DMSG_ERR_JCONFREFUSED, XJ_ICQ_LEN, XJ_ICQ_NAME, xj_jcon_check_jconf(), xj_jcon_jconf_presence(), xj_jcon_send_presence(), XJ_JCONF_NULL, XJ_JCONF_READY, XJ_MSN_LEN, XJ_MSN_NAME, XJ_NET_AIM, XJ_NET_ICQ, XJ_NET_MSN, XJ_NET_YAH, xj_pres_cell_free(), xj_pres_cell_init(), xj_pres_cell_new(), xj_pres_list_add(), xj_pres_list_check(), XJ_PS_OFFLINE, XJ_PS_ONLINE, XJ_PS_REFUSED, xj_send_sip_msg(), xj_send_sip_msgz(), XJ_YAH_LEN, XJ_YAH_NAME, xode_free(), xode_from_strx(), xode_get_attrib(), xode_get_data(), xode_get_firstchild(), xode_get_name(), xode_get_nextsibling(), and xode_get_tag().
Referenced by xj_worker_process().
send a SIP MESSAGE message
Definition at line 1147 of file xjab_worker.c.
References buf, CRLF, CRLF_LEN, _str::len, LM_DBG, msg_type, _str::s, tm_binds::t_request, tmb, and xj_tuac_callback().
Referenced by xj_manage_jab(), and xj_send_sip_msgz().
send a SIP MESSAGE message
Definition at line 1201 of file xjab_worker.c.
References _str::len, LM_DBG, LM_ERR, _str::s, and xj_send_sip_msg().
Referenced by xj_manage_jab(), xj_wlist_clean_jobs(), xj_worker_check_jcons(), xj_worker_check_qmsg(), and xj_worker_process().
| void xj_sig_handler | ( | int | s | ) |
Definition at line 1127 of file xjab_worker.c.
References _xj_pid, LM_DBG, main_loop, and xj_sig_handler().
Referenced by xj_sig_handler(), and xj_worker_process().
| void xj_tuac_callback | ( | struct cell * | t, | |
| int | type, | |||
| struct tmcb_params * | ps | |||
| ) |
callback function for TM
Definition at line 1252 of file xjab_worker.c.
References tmcb_params::code, LM_DBG, tmcb_params::param, and XJ_FLAG_CLOSE.
Referenced by xj_send_sip_msg().
return communication pipe with the worker that will process the message for the id 'sid' only if it exists, or -1 if error
Definition at line 205 of file xjab_wlist.c.
References find234(), _xj_jkey::id, _str::len, len, LM_DBG, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, and _xj_worker::wpipe.
Referenced by xjab_manage_sipmsg().
check if the addr contains jdomain or an alias
Definition at line 582 of file xjab_wlist.c.
References _xj_jalias::a, _xj_wlist::aliases, _xj_jalias::jdm, _str::len, s, _str::s, and _xj_jalias::size.
Referenced by xjab_manage_sipmsg().
| int xj_wlist_clean_jobs | ( | xj_wlist | jwl, | |
| int | idx, | |||
| int | fl | |||
| ) |
send disconnected info to all SIP users associated with worker idx and clean the entries from wlist
Definition at line 1224 of file xjab_worker.c.
References _PADDR, delpos234(), _xj_jkey::id, _str::len, _xj_wlist::len, LM_DBG, _xj_worker::nr, NULL, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, XJ_DMSG_INF_DISCONNECTED, xj_jkey_free_p(), and xj_send_sip_msgz().
Referenced by xjab_check_workers().
delete an entity from working list of a worker
Definition at line 628 of file xjab_wlist.c.
References del234(), _xj_jkey::id, _str::len, _xj_wlist::len, LM_DBG, _xj_worker::nr, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, and xj_jkey_free_p().
Referenced by xj_worker_check_jcons(), and xj_worker_process().
| void xj_wlist_free | ( | xj_wlist | jwl | ) |
free jab_wlist
Definition at line 148 of file xjab_wlist.c.
References _M_SHM_FREE, _xj_jalias::a, _xj_wlist::aliases, _xj_jalias::d, free2tree234(), _xj_jalias::jdm, _xj_wlist::len, LM_DBG, NULL, _xj_jalias::proxy, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_jalias::size, _xj_wlist::workers, and xj_jkey_free_p().
return communication pipe with the worker that will process the message for the id 'sid', or -1 if error
Definition at line 250 of file xjab_wlist.c.
References _M_SHM_FREE, _M_SHM_MALLOC, add234(), find234(), _xj_jkey::flag, _xj_jkey::hash, _xj_jkey::id, _str::len, len, LM_DBG, _xj_wlist::maxj, min, _xj_worker::nr, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, _xj_worker::wpipe, and XJ_FLAG_OPEN.
Referenced by xj_register_watcher(), and xjab_manage_sipmsg().
| xj_wlist xj_wlist_init | ( | int ** | pipes, | |
| int | size, | |||
| int | max, | |||
| int | cache_time, | |||
| int | sleep_time, | |||
| int | delay_time | |||
| ) |
init a workers list
Definition at line 54 of file xjab_wlist.c.
References _M_SHM_FREE, _M_SHM_MALLOC, _xj_wlist::aliases, _xj_wlist::cachet, _xj_wlist::delayt, free2tree234(), jwl, _xj_wlist::len, LM_CRIT, LM_DBG, _xj_wlist::maxj, newtree234(), _xj_worker::nr, NULL, _xj_worker::pid, _xj_worker::rpipe, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::sleept, _xj_wlist::workers, _xj_worker::wpipe, xj_jkey_cmp(), and xj_jkey_free_p().
Referenced by mod_init().
| int xj_wlist_set_aliases | ( | xj_wlist | jwl, | |
| char * | als, | |||
| char * | jd, | |||
| char * | pa | |||
| ) |
set IM aliases, jdomain and outbound proxy
return 0 if OK
Definition at line 392 of file xjab_wlist.c.
References _M_SHM_FREE, _M_SHM_MALLOC, _xj_jalias::a, _xj_wlist::aliases, _xj_jalias::d, _xj_jalias::dlm, _xj_jalias::jdm, _str::len, LM_DBG, NULL, _xj_jalias::proxy, _str::s, _xj_jalias::size, and XJ_DEF_JDELIM.
Referenced by mod_init().
set the flag of the connection identified by 'jkey'
Definition at line 344 of file xjab_wlist.c.
References find234(), _xj_jkey::flag, _xj_jkey::hash, _xj_jkey::id, len, _str::len, LM_DBG, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, and _xj_worker::wpipe.
| int xj_wlist_set_pid | ( | xj_wlist | jwl, | |
| int | pid, | |||
| int | idx | |||
| ) |
set the p.id's of the workers
Definition at line 134 of file xjab_wlist.c.
References _xj_wlist::len, NULL, _xj_worker::pid, _xj_wlist::sems, and _xj_wlist::workers.
Referenced by child_init(), and xjab_check_workers().
| void xj_worker_check_jcons | ( | xj_wlist | jwl, | |
| xj_jcon_pool | jcp, | |||
| int | ltime, | |||
| fd_set * | pset | |||
| ) |
check for expired connections
Definition at line 1277 of file xjab_worker.c.
References _PADDR, _xj_pid, delpos234(), _xj_jcon::expire, _xj_jkey::flag, _xj_jkey::id, _xj_jcon::jconf, _xj_jcon::jkey, _str::len, _xj_jcon_pool::len, LM_DBG, main_loop, _xj_jcon::nrjconf, NULL, _xj_jcon_pool::ojc, _xj_jcon::plist, _str::s, _xj_jcon::sock, XJ_DMSG_INF_JOFFLINE, XJ_FLAG_OPEN, xj_jcon_disconnect(), xj_jcon_free(), xj_jcon_jconf_presence(), xj_jconf_free(), xj_pres_list_notifyall(), XJ_PS_TERMINATED, xj_send_sip_msgz(), and xj_wlist_del().
Referenced by xj_worker_process().
| void xj_worker_check_qmsg | ( | xj_wlist | jwl, | |
| xj_jcon_pool | jcp | |||
| ) |
check if there are msg to send or delete from queue
check the msg queue AND if the target connection is ready
delete message from queue
send message from queue
delete message from queue
Definition at line 1338 of file xjab_worker.c.
References _PADDR, _xj_wlist::aliases, _xj_jalias::dlm, _xj_jmsg_queue::expire, _xj_jkey::flag, get_ticks(), _xj_jkey::id, _xj_jcon::jkey, _xj_sipmsg::jkey, _xj_jcon_pool::jmqueue, _xj_jmsg_queue::jsm, _str::len, LM_DBG, LM_ERR, main_loop, _xj_sipmsg::msg, NULL, _xj_jmsg_queue::ojc, _str::s, _xj_jmsg_queue::size, _xj_sipmsg::to, xj_address_translation(), XJ_ADDRTR_CON, XJ_ADDRTR_S2J, XJ_DMSG_ERR_SENDIM, xj_jcon_is_ready(), xj_jcon_pool_del_jmsg(), xj_jcon_send_msg(), xj_jconf_check_addr(), XJ_JMSG_CHAT, XJ_JMSG_GROUPCHAT, xj_send_sip_msgz(), and xj_sipmsg_free().
Referenced by xj_worker_process().
| void xj_worker_check_watcher | ( | xj_wlist | jwl, | |
| xj_jcon_pool | jcp, | |||
| xj_jcon | jbc, | |||
| xj_sipmsg | jsmsg | |||
| ) |
update or register a presence watcher
Definition at line 1434 of file xjab_worker.c.
References _xj_wlist::aliases, _xj_pres_cell::cbf, _xj_sipmsg::cbf, _xj_pres_cell::cbp, _xj_jalias::dlm, _str::len, LM_DBG, NULL, _xj_sipmsg::p, _xj_jcon::plist, _str::s, _xj_pres_cell::state, _xj_pres_cell::status, _xj_sipmsg::to, xj_address_translation(), XJ_ADDRTR_S2J, xj_jcon_send_subscribe(), xj_jconf_check_addr(), xj_pres_cell_free(), xj_pres_cell_init(), xj_pres_cell_new(), xj_pres_cell_update(), xj_pres_list_add(), xj_pres_list_check(), XJ_PRES_STATUS_WAIT, and XJ_PS_OFFLINE.
Referenced by xj_worker_process().
| int xj_worker_process | ( | xj_wlist | jwl, | |
| char * | jaddress, | |||
| int | jport, | |||
| char * | priority, | |||
| int | rank, | |||
| db_con_t * | db_con, | |||
| db_func_t * | dbf | |||
| ) |
worker implementation
add socket descriptor to select
wait for a while - the worker is tired
flush out the socket - set it to nonblocking
flush out the socket - set it back to blocking
Definition at line 252 of file xjab_worker.c.
References _PADDR, _xj_pid, _xj_wlist::aliases, _xj_wlist::cachet, DB_INT, DB_STRING, _xj_wlist::delayt, _xj_jalias::dlm, _xj_jcon::expire, _xj_jkey::flag, db_func::free_result, get_ticks(), _xj_jkey::id, db_val_t::int_val, _xj_jalias::jdm, _xj_jcon::jkey, _xj_sipmsg::jkey, _xj_jcon_pool::jmqueue, _xj_jcon_pool::len, _xj_wlist::len, _str::len, LM_DBG, LM_ERR, main_loop, _xj_wlist::maxj, _xj_sipmsg::msg, _xj_jcon::nrjconf, db_val_t::nul, NULL, _xj_jcon_pool::ojc, db_func::query, registrar, RES_ROW_N, RES_ROWS, ROW_VALUES, _xj_worker::rpipe, _str::s, _xj_jmsg_queue::size, _xj_wlist::sleept, _xj_jcon::sock, _xj_jconf::status, str_init, db_val_t::string_val, _xj_sipmsg::to, _xj_sipmsg::type, db_val_t::type, db_val_t::val, vals, _xj_wlist::workers, xj_address_translation(), XJ_ADDRTR_CON, XJ_ADDRTR_S2J, XJ_DEL_WATCHER, XJ_DMSG_ERR_DISCONNECTED, XJ_DMSG_ERR_JAUTH, XJ_DMSG_ERR_JGWFORB, XJ_DMSG_ERR_JGWFULL, XJ_DMSG_ERR_JOINJCONF, XJ_DMSG_ERR_NEWJCONF, XJ_DMSG_ERR_NOJSRV, XJ_DMSG_ERR_NOREGIM, XJ_DMSG_ERR_NOTJCONF, XJ_DMSG_ERR_SENDJMSG, XJ_DMSG_ERR_STOREJMSG, XJ_DMSG_INF_JCONFEXIT, XJ_EXIT_JCONF, XJ_GO_OFFLINE, XJ_GO_ONLINE, XJ_JCMD_UNSUBSCRIBE, xj_jcon_connect(), xj_jcon_del_jconf(), xj_jcon_disconnect(), xj_jcon_free(), xj_jcon_get_jconf(), xj_jcon_get_roster(), xj_jcon_init(), xj_jcon_is_ready(), xj_jcon_jconf_presence(), xj_jcon_pool_add(), xj_jcon_pool_add_jmsg(), xj_jcon_pool_get(), xj_jcon_pool_init(), xj_jcon_send_msg(), xj_jcon_send_presence(), xj_jcon_set_attrs(), xj_jcon_update(), xj_jcon_user_auth(), xj_jconf_check_addr(), XJ_JCONF_READY, XJ_JCONF_WAITING, XJ_JMSG_CHAT, XJ_JMSG_GROUPCHAT, XJ_JOIN_JCONF, xj_manage_jab(), XJ_MSG_POOL_SIZE, XJ_REG_WATCHER, XJ_SEND_MESSAGE, xj_send_sip_msgz(), xj_sig_handler(), xj_sipmsg_free(), xj_wlist_del(), xj_worker_check_jcons(), xj_worker_check_qmsg(), xj_worker_check_watcher(), and XJAB_RESOURCE.
Referenced by child_init(), and xjab_check_workers().
1.5.6