亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? smsc_wrapper.c

?? 主要包括sms網關和wap網關實現說明和源碼
?? C
字號:
/* ====================================================================  * The Kannel Software License, Version 1.0  *  * Copyright (c) 2001-2005 Kannel Group   * Copyright (c) 1998-2001 WapIT Ltd.    * All rights reserved.  *  * Redistribution and use in source and binary forms, with or without  * modification, are permitted provided that the following conditions  * are met:  *  * 1. Redistributions of source code must retain the above copyright  *    notice, this list of conditions and the following disclaimer.  *  * 2. Redistributions in binary form must reproduce the above copyright  *    notice, this list of conditions and the following disclaimer in  *    the documentation and/or other materials provided with the  *    distribution.  *  * 3. The end-user documentation included with the redistribution,  *    if any, must include the following acknowledgment:  *       "This product includes software developed by the  *        Kannel Group (http://www.kannel.org/)."  *    Alternately, this acknowledgment may appear in the software itself,  *    if and wherever such third-party acknowledgments normally appear.  *  * 4. The names "Kannel" and "Kannel Group" must not be used to  *    endorse or promote products derived from this software without  *    prior written permission. For written permission, please   *    contact org@kannel.org.  *  * 5. Products derived from this software may not be called "Kannel",  *    nor may "Kannel" appear in their name, without prior written  *    permission of the Kannel Group.  *  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE  * DISCLAIMED.  IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,   * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT   * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  * ====================================================================  *  * This software consists of voluntary contributions made by many  * individuals on behalf of the Kannel Group.  For more information on   * the Kannel Group, please see <http://www.kannel.org/>.  *  * Portions of this software are based upon software originally written at   * WapIT Ltd., Helsinki, Finland for the Kannel project.   */ /* * SMSC Connection wrapper * * Interface to old SMS center implementations * * Kalle Marjola 2000 */#include "gwlib/gwlib.h"#include "smscconn.h"#include "smscconn_p.h"#include "bb_smscconn_cb.h"#include "smsc.h"#include "smsc_p.h"typedef struct smsc_wrapper {    SMSCenter	*smsc;    List	*outgoing_queue;    List	*stopped;	/* list-trick for suspend/isolate */     long     	receiver_thread;    long	sender_thread;    Mutex	*reconnect_mutex;} SmscWrapper;static void smscwrapper_destroy(SmscWrapper *wrap){    if (wrap == NULL)	return;    gwlist_destroy(wrap->outgoing_queue, NULL);    gwlist_destroy(wrap->stopped, NULL);    mutex_destroy(wrap->reconnect_mutex);    if (wrap->smsc != NULL)	smsc_close(wrap->smsc);    gw_free(wrap);}static int reconnect(SMSCConn *conn){    SmscWrapper *wrap = conn->data;    Msg *msg;    int ret;    int wait = 1;    /* disable double-reconnect     * NOTE: it is still possible that we do double-connect if     *   first thread gets through this if-statement and then     *   execution switches to another thread.. this can be avoided     *   via double-mutex system, but I do not feel it is worth it,     *   maybe later --rpr     */    if (conn->status == SMSCCONN_RECONNECTING) {	mutex_lock(wrap->reconnect_mutex);	/* wait here */	mutex_unlock(wrap->reconnect_mutex);	return 0;    }    mutex_lock(wrap->reconnect_mutex);    debug("bb.sms", 0, "smsc_wrapper <%s>: reconnect started",	  octstr_get_cstr(conn->name));    while((msg = gwlist_extract_first(wrap->outgoing_queue))!=NULL) {	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_TEMPORARILY, NULL);    }    conn->status = SMSCCONN_RECONNECTING;        while(conn->why_killed == SMSCCONN_ALIVE) {	ret = smsc_reopen(wrap->smsc);	if (ret == 0) {	    info(0, "Re-open of %s succeeded.", octstr_get_cstr(conn->name));	    mutex_lock(conn->flow_mutex);	    conn->status = SMSCCONN_ACTIVE;	    conn->connect_time = time(NULL);	    mutex_unlock(conn->flow_mutex);	    bb_smscconn_connected(conn);	    break;	}	else if (ret == -2) {	    error(0, "Re-open of %s failed permanently",		  octstr_get_cstr(conn->name));	    mutex_lock(conn->flow_mutex);	    conn->status = SMSCCONN_DISCONNECTED;	    mutex_unlock(wrap->reconnect_mutex);	    mutex_unlock(conn->flow_mutex);	    return -1;	/* permanent failure */	}	else {	    error(0, "Re-open to <%s> failed, retrying after %d minutes...",		  octstr_get_cstr(conn->name), wait);	    gwthread_sleep(wait*60.0);	    wait = wait > 10 ? 10 : wait * 2 + 1;	}    }    mutex_unlock(wrap->reconnect_mutex);    return 0;}static Msg *sms_receive(SMSCConn *conn){    SmscWrapper *wrap = conn->data;    int ret;    Msg *newmsg = NULL;    if (smscenter_pending_smsmessage(wrap->smsc) == 1) {        ret = smscenter_receive_msg(wrap->smsc, &newmsg);        if (ret == 1) {            /* if any smsc_id available, use it */            newmsg->sms.smsc_id = octstr_duplicate(conn->id);	    return newmsg;        } else if (ret == 0) { /* "NEVER" happens */            warning(0, "SMSC %s: Pending message returned '1', "                    "but nothing to receive!", octstr_get_cstr(conn->name));            msg_destroy(newmsg);            return NULL;        } else {            msg_destroy(newmsg);	    if (reconnect(conn) == -1)		smscconn_shutdown(conn, 0);	    return NULL;        }    }    return NULL;}static void wrapper_receiver(void *arg){    Msg 	*msg;    SMSCConn 	*conn = arg;    SmscWrapper *wrap = conn->data;    /* SmscWrapper *wrap = conn->data; ** non-used */    double 	sleep = 0.0001;        /* Make sure we log into our own log-file if defined */    log_thread_to(conn->log_idx);        /* remove messages from SMSC until we are killed */    while(conn->why_killed == SMSCCONN_ALIVE) {        gwlist_consume(wrap->stopped); /* block here if suspended/isolated */	msg = sms_receive(conn);	if (msg) {            debug("bb.sms", 0, "smscconn (%s): new message received",		  octstr_get_cstr(conn->name));            sleep = 0.0001;	    bb_smscconn_receive(conn, msg);        }        else {	    /* note that this implementations means that we sleep even	     * when we fail connection.. but time is very short, anyway	     */            gwthread_sleep(sleep);            /* gradually sleep longer and longer times until something starts to             * happen - this of course reduces response time, but that's better than             * extensive CPU usage when it is not used             */            sleep *= 2;            if (sleep >= 2.0)                sleep = 1.999999;        }    }    conn->why_killed = SMSCCONN_KILLED_SHUTDOWN;    /* this thread is joined at sender */}static int sms_send(SMSCConn *conn, Msg *msg){    SmscWrapper *wrap = conn->data;    int ret;    debug("bb.sms", 0, "smscconn_sender (%s): sending message",	  octstr_get_cstr(conn->name));    ret = smscenter_submit_msg(wrap->smsc, msg);    if (ret == -1) {	bb_smscconn_send_failed(conn, msg,	            SMSCCONN_FAILED_REJECTED, octstr_create("REJECTED"));	if (reconnect(conn) == -1)	    smscconn_shutdown(conn, 0);        return -1;    } else {	bb_smscconn_sent(conn, msg, NULL);        return 0;    }}static void wrapper_sender(void *arg){    Msg 	*msg;    SMSCConn 	*conn = arg;    SmscWrapper *wrap = conn->data;    /* Make sure we log into our own log-file if defined */    log_thread_to(conn->log_idx);    /* send messages to SMSC until our outgoing_list is empty and     * no producer anymore (we are set to shutdown) */    while(conn->status != SMSCCONN_DEAD) {	if ((msg = gwlist_consume(wrap->outgoing_queue)) == NULL)            break;        if (octstr_search_char(msg->sms.receiver, ' ', 0) != -1) {            /*             * multi-send: this should be implemented in corresponding             *  SMSC protocol, but while we are waiting for that...             */            int i;	    Msg *newmsg;            /* split from spaces: in future, split with something more sensible,             * this is dangerous... (as space is url-encoded as '+')             */            List *nlist = octstr_split_words(msg->sms.receiver);	    debug("bb.sms", 0, "Handling multi-receiver message");            for(i=0; i < gwlist_len(nlist); i++) {		newmsg = msg_duplicate(msg);                octstr_destroy(newmsg->sms.receiver);                newmsg->sms.receiver = gwlist_get(nlist, i);                sms_send(conn, newmsg);            }            gwlist_destroy(nlist, NULL);            msg_destroy(msg);        }        else	    sms_send(conn,msg);    }    /* cleanup, we are now dying */    debug("bb.sms", 0, "SMSCConn %s sender died, waiting for receiver",	  octstr_get_cstr(conn->name));        conn->why_killed = SMSCCONN_KILLED_SHUTDOWN;    if (conn->is_stopped) {	gwlist_remove_producer(wrap->stopped);	conn->is_stopped = 0;    }    gwthread_wakeup(wrap->receiver_thread);    gwthread_join(wrap->receiver_thread);    /* call 'failed' to all messages still in queue */        mutex_lock(conn->flow_mutex);    conn->status = SMSCCONN_DEAD;    while((msg = gwlist_extract_first(wrap->outgoing_queue))!=NULL) {	bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);    }    smscwrapper_destroy(wrap);    conn->data = NULL;        mutex_unlock(conn->flow_mutex);    bb_smscconn_killed();}static int wrapper_add_msg(SMSCConn *conn, Msg *sms){    SmscWrapper *wrap = conn->data;    Msg *copy;    copy = msg_duplicate(sms);    gwlist_produce(wrap->outgoing_queue, copy);    return 0;}static int wrapper_shutdown(SMSCConn *conn, int finish_sending){    SmscWrapper *wrap = conn->data;    debug("bb.sms", 0, "Shutting down SMSCConn %s, %s",	  octstr_get_cstr(conn->name), finish_sending ? "slow" : "instant");        if (finish_sending == 0) {	Msg *msg; 	while((msg = gwlist_extract_first(wrap->outgoing_queue))!=NULL) {	    bb_smscconn_send_failed(conn, msg, SMSCCONN_FAILED_SHUTDOWN, NULL);	}    }    gwlist_remove_producer(wrap->outgoing_queue);    gwthread_wakeup(wrap->sender_thread);    gwthread_wakeup(wrap->receiver_thread);    return 0;}static void wrapper_stop(SMSCConn *conn){    SmscWrapper *wrap = conn->data;    debug("smscconn", 0, "Stopping wrapper");    gwlist_add_producer(wrap->stopped);}static void wrapper_start(SMSCConn *conn){    SmscWrapper *wrap = conn->data;    debug("smscconn", 0, "Starting wrapper");    gwlist_remove_producer(wrap->stopped);}static long wrapper_queued(SMSCConn *conn){    SmscWrapper *wrap = conn->data;    long ret = gwlist_len(wrap->outgoing_queue);    /* use internal queue as load, maybe something else later */        conn->load = ret;    return ret;}int smsc_wrapper_create(SMSCConn *conn, CfgGroup *cfg){    /* 1. Call smsc_open()     * 2. create sender/receiver threads     * 3. fill up the conn     *     * XXX open() SHOULD be done in distinct thread, not here!     */    SmscWrapper *wrap;    wrap = gw_malloc(sizeof(SmscWrapper));    wrap->smsc = NULL;    conn->data = wrap;    conn->send_msg = wrapper_add_msg;            wrap->outgoing_queue = gwlist_create();    wrap->stopped = gwlist_create();    wrap->reconnect_mutex = mutex_create();    gwlist_add_producer(wrap->outgoing_queue);        if ((wrap->smsc = smsc_open(cfg)) == NULL)	goto error;    conn->name = octstr_create(smsc_name(wrap->smsc));    conn->status = SMSCCONN_ACTIVE;    conn->connect_time = time(NULL);    if (conn->is_stopped)	gwlist_add_producer(wrap->stopped);	    /* XXX here we could fail things... specially if the second one     *     fails.. so fix this ASAP     *     * moreover, open should be in sender/receiver, so that we can continue     * while trying to open... maybe move this, or just wait for new     * implementations of various SMSC protocols     */        if ((wrap->receiver_thread = gwthread_create(wrapper_receiver, conn))==-1)	goto error;    if ((wrap->sender_thread = gwthread_create(wrapper_sender, conn))==-1)	goto error;    conn->shutdown = wrapper_shutdown;    conn->queued = wrapper_queued;    conn->stop_conn = wrapper_stop;    conn->start_conn = wrapper_start;        return 0;error:    error(0, "Failed to create Smsc wrapper");    conn->data = NULL;    smscwrapper_destroy(wrap);    conn->why_killed = SMSCCONN_KILLED_CANNOT_CONNECT;    conn->status = SMSCCONN_DEAD;    return -1;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区在线观看免费 | 国产精品99久久久久| 亚洲天堂成人在线观看| 欧美一区二区三级| 91久久精品一区二区| 国产一区二区电影| 亚洲成人免费看| 一区二区中文视频| 久久先锋影音av鲁色资源| 欧美日韩国产色站一区二区三区| 国产精品亚洲视频| 五月综合激情网| 亚洲欧美区自拍先锋| 精品国产自在久精品国产| 欧美日韩一区二区三区在线看| 国产精品中文欧美| 久国产精品韩国三级视频| 亚洲大片精品永久免费| 亚洲欧美日本在线| 中文字幕日韩精品一区| 国产欧美精品区一区二区三区| 欧美日本国产视频| 91福利社在线观看| 色婷婷av一区二区三区之一色屋| 国产福利一区二区三区| 国产一区二区伦理片| 男女激情视频一区| 视频精品一区二区| 婷婷成人激情在线网| 亚洲一二三区在线观看| 亚洲国产美女搞黄色| 亚洲国产精品久久人人爱| 亚洲欧美日韩国产一区二区三区| 亚洲人成在线播放网站岛国| 最近中文字幕一区二区三区| 国产精品欧美一级免费| 欧美韩日一区二区三区四区| 日本一区二区三区国色天香 | 日韩免费在线观看| 欧美一区二区女人| 欧美一区二区三级| 欧美精品一区二区三| 精品国产免费人成在线观看| 精品国产一区二区三区四区四| 亚洲精品在线免费播放| 久久老女人爱爱| 国产日韩欧美亚洲| 亚洲视频在线观看一区| 亚洲日本在线天堂| 一区二区三区在线视频观看| 亚洲一区二区精品视频| 视频一区二区三区在线| 激情文学综合丁香| 粉嫩久久99精品久久久久久夜| 成人国产精品免费观看动漫| 色综合久久天天综合网| 欧美日韩国产免费一区二区| 欧美一区日本一区韩国一区| 日韩欧美国产午夜精品| 国产欧美日韩不卡| 一区二区三区在线免费播放| 无吗不卡中文字幕| 国产美女精品一区二区三区| 99久久久久免费精品国产| 欧美性大战久久久久久久| 欧美一级欧美一级在线播放| 久久久亚洲欧洲日产国码αv| 国产精品久久久久久久久快鸭| 一区二区三区在线视频免费观看| 日韩av一区二区三区四区| 国产精品1区2区| 欧美日韩视频在线第一区| 精品欧美黑人一区二区三区| 中文字幕一区免费在线观看| 亚洲高清在线视频| 极品少妇一区二区| 色综合一个色综合| 日韩一区二区三区免费看| 欧美精彩视频一区二区三区| 亚洲已满18点击进入久久| 国模娜娜一区二区三区| 色哟哟在线观看一区二区三区| 欧美一区二区在线视频| 亚洲欧美综合另类在线卡通| 日韩精品欧美精品| 懂色av中文字幕一区二区三区| 欧美日韩一级二级| 国产欧美综合色| 石原莉奈在线亚洲三区| 成人的网站免费观看| 337p亚洲精品色噜噜狠狠| 国产精品美女久久久久高潮| 婷婷成人激情在线网| 99麻豆久久久国产精品免费| 日韩三级在线免费观看| 一个色综合网站| 国产v综合v亚洲欧| 日韩一区二区三区电影| 亚洲免费av在线| 国产精品一品视频| 欧美一区三区二区| 亚洲一区视频在线| 成人黄色片在线观看| 精品美女被调教视频大全网站| 亚洲国产精品久久艾草纯爱| 成人av电影免费观看| 久久影院午夜片一区| 亚洲一区二区综合| 91在线视频播放地址| 久久久国产一区二区三区四区小说 | 亚洲激情自拍视频| 韩国视频一区二区| 欧美一级精品在线| 性久久久久久久久| 日本精品一区二区三区高清| 中文字幕欧美激情| 国产**成人网毛片九色| 精品国产91九色蝌蚪| 美女脱光内衣内裤视频久久影院| caoporn国产精品| 欧美国产精品v| 国产乱码字幕精品高清av | 成人av在线影院| 久久网站最新地址| 久久99精品国产麻豆婷婷| 在线不卡a资源高清| 五月婷婷久久综合| 欧美剧情片在线观看| 亚洲国产日韩精品| 欧美日韩久久一区二区| 亚洲国产日韩一区二区| 欧美三级韩国三级日本三斤| 亚洲国产视频一区| 欧美午夜电影在线播放| 亚洲国产视频直播| 欧美精品三级日韩久久| 亚洲成av人片| 欧美一区二区视频在线观看2022 | 视频在线观看91| 91麻豆精品国产91久久久久久久久| 亚洲国产欧美在线人成| 欧美日韩成人激情| 美腿丝袜亚洲综合| 精品国产免费人成电影在线观看四季 | 99国产精品久久久久| 国产精品美女久久久久久久久 | 亚洲一区二区三区爽爽爽爽爽 | 国产中文字幕一区| 久久免费看少妇高潮| 成人午夜视频在线观看| 国产精品国产三级国产普通话蜜臀| 91亚洲精品久久久蜜桃网站| 亚洲一区中文日韩| 欧美一区二区三区精品| 国产一区二区三区精品视频| 久久精品欧美一区二区三区麻豆 | 欧美私人免费视频| 日韩av在线播放中文字幕| 精品理论电影在线| 99综合影院在线| 日韩和欧美一区二区| 国产亚洲短视频| 99久久精品国产导航| 三级在线观看一区二区| 久久婷婷综合激情| 在线免费观看视频一区| 日本在线不卡视频| 国产精品视频一二| 欧美优质美女网站| 韩国视频一区二区| 亚洲欧美一区二区三区久本道91| 欧美二区三区的天堂| 国产精品一区免费在线观看| 欧美激情一区二区三区| 欧美日韩亚州综合| 成人午夜视频网站| 日韩精品一区第一页| 中文字幕高清不卡| 5566中文字幕一区二区电影| 高清国产午夜精品久久久久久| 亚洲一区电影777| 久久奇米777| 欧美三级中文字| 国产精品1区二区.| 天堂成人免费av电影一区| 国产精品女同一区二区三区| 7799精品视频| 91在线免费视频观看| 韩国一区二区三区| 亚洲成人av电影在线| 国产精品高清亚洲| 日韩精品一区二| 在线观看中文字幕不卡| 国产美女主播视频一区| 日韩不卡一二三区| 亚洲男人的天堂一区二区| 2020日本不卡一区二区视频| 欧美人与z0zoxxxx视频| 91丨porny丨首页| 国产精品99久久久|