提交 bb53daea authored 作者: Anthony Minessale's avatar Anthony Minessale

wanpipe commit we've all been waiting for, HW dtmf, ALARMS, proper bounce of PRIs (testers needed)

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@719 a93c3328-9c30-0410-af19-c9cd2b2d52af
上级 54c7bbec
......@@ -154,10 +154,12 @@ ozmod_skel_la_CFLAGS = $(AM_CFLAGS) $(MY_CFLAGS)
ozmod_skel_la_LDFLAGS = -module -avoid-version
ozmod_skel_la_LIBADD = $(MYLIB)
if LIBSANGOMA
ozmod_wanpipe_la_SOURCES = $(SRC)/ozmod/ozmod_wanpipe/ozmod_wanpipe.c
ozmod_wanpipe_la_CFLAGS = $(AM_CFLAGS) $(MY_CFLAGS)
ozmod_wanpipe_la_LDFLAGS = -module -avoid-version
ozmod_wanpipe_la_CFLAGS = $(AM_CFLAGS) $(MY_CFLAGS) -D__LINUX__ -I/usr/include/wanpipe
ozmod_wanpipe_la_LDFLAGS = -module -avoid-version -lsangoma
ozmod_wanpipe_la_LIBADD = $(MYLIB)
endif
ozmod_isdn_la_SOURCES = \
$(SRC)/isdn/EuroISDNStateNT.c \
......
......@@ -155,6 +155,9 @@ AC_ARG_WITH([libpri],
[AS_HELP_STRING([--with-libpri], [Install ozmod_libpri])], [enable_libpri="yes"], [enable_libpri="no"])
AC_SUBST(enable_libpri)
AC_CHECK_LIB([sangoma], [sangoma_span_chan_toif], [have_libsangoma="yes"])
AM_CONDITIONAL([LIBSANGOMA],[test "${have_libsangoma}" = "yes"])
AM_CONDITIONAL([LIBPRI],[test "${enable_libpri}" = "yes"])
COMP_VENDOR_CFLAGS="$COMP_VENDOR_CFLAGS"
......
......@@ -475,7 +475,7 @@ static switch_status_t channel_on_hangup(switch_core_session_t *session)
break;
default:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled type for channel %s\n", switch_channel_get_name(channel));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unhandled type for channel %s\n", switch_channel_get_name(channel));
}
break;
}
......
......@@ -115,9 +115,14 @@ static int __pri_lpwrap_read(struct pri *pri, void *buf, int buflen)
struct lpwrap_pri *spri = (struct lpwrap_pri *) pri_get_userdata(pri);
zap_size_t len = buflen;
int res;
zap_status_t zst;
if (zap_channel_read(spri->dchan, buf, &len) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_CRIT, "span %d D-READ FAIL! [%s]\n", spri->span->span_id, spri->dchan->last_error);
if ((zst = zap_channel_read(spri->dchan, buf, &len)) != ZAP_SUCCESS) {
if (zst == ZAP_FAIL) {
zap_log(ZAP_LOG_CRIT, "span %d D-READ FAIL! [%s]\n", spri->span->span_id, spri->dchan->last_error);
} else {
zap_log(ZAP_LOG_CRIT, "span %d D-READ TIMEOUT\n", spri->span->span_id);
}
zap_clear_flag(spri, LPWRAP_PRI_READY);
return -1;
}
......@@ -145,7 +150,7 @@ static int __pri_lpwrap_write(struct pri *pri, void *buf, int buflen)
if (zap_channel_write(spri->dchan, buf, buflen, &len) != ZAP_SUCCESS) {
zap_log(ZAP_LOG_CRIT, "span %d D-WRITE FAIL! [%s]\n", spri->span->span_id, spri->dchan->last_error);
zap_clear_flag(spri, LPWRAP_PRI_READY);
return -1;
return -1;
}
#ifdef IODEBUG
......@@ -198,9 +203,9 @@ int lpwrap_one_loop(struct lpwrap_pri *spri)
}
}
if (!zap_test_flag(spri, LPWRAP_PRI_READY)) {
return -1;
}
//if (!zap_test_flag(spri, LPWRAP_PRI_READY)) {
//return -1;
//}
FD_ZERO(&rfds);
FD_ZERO(&efds);
......@@ -246,9 +251,9 @@ int lpwrap_one_loop(struct lpwrap_pri *spri)
}
}
if (zap_test_flag(spri, LPWRAP_PRI_READY)) {
return sel;
}
return sel;
if ((handler = spri->eventmap[LPWRAP_PRI_EVENT_IO_FAIL] ? spri->eventmap[LPWRAP_PRI_EVENT_IO_FAIL] : spri->eventmap[0] ? spri->eventmap[0] : NULL)) {
handler(spri, LPWRAP_PRI_EVENT_IO_FAIL, NULL);
......
......@@ -691,16 +691,103 @@ static int on_ring(lpwrap_pri_t *spri, lpwrap_pri_event_t event_type, pri_event
return ret;
}
static __inline__ zap_status_t process_event(zap_span_t *span, zap_event_t *event)
{
zap_sigmsg_t sig;
zap_libpri_data_t *isdn_data = span->signal_data;
memset(&sig, 0, sizeof(sig));
sig.chan_id = event->channel->chan_id;
sig.span_id = event->channel->span_id;
sig.channel = event->channel;
zap_log(ZAP_LOG_DEBUG, "EVENT [%s][%d][%d:%d] STATE [%s]\n",
zap_oob_event2str(event->enum_id), event->enum_id, event->channel->span_id, event->channel->chan_id, zap_channel_state2str(event->channel->state));
switch(event->enum_id) {
case ZAP_OOB_ALARM_TRAP:
{
sig.event_id = ZAP_OOB_ALARM_TRAP;
if (event->channel->state != ZAP_CHANNEL_STATE_DOWN) {
if (event->channel->type == ZAP_CHAN_TYPE_B) {
zap_set_state_locked(event->channel, ZAP_CHANNEL_STATE_RESTART);
}
}
zap_set_flag(event->channel, ZAP_CHANNEL_SUSPENDED);
zap_channel_get_alarms(event->channel);
isdn_data->sig_cb(&sig);
zap_log(ZAP_LOG_WARNING, "channel %d:%d (%d:%d) has alarms! [%s]\n",
event->channel->span_id, event->channel->chan_id,
event->channel->physical_span_id, event->channel->physical_chan_id,
event->channel->last_error);
}
break;
case ZAP_OOB_ALARM_CLEAR:
{
zap_log(ZAP_LOG_WARNING, "channel %d:%d (%d:%d) alarms Cleared!\n", event->channel->span_id, event->channel->chan_id,
event->channel->physical_span_id, event->channel->physical_chan_id);
sig.event_id = ZAP_OOB_ALARM_CLEAR;
zap_clear_flag(event->channel, ZAP_CHANNEL_SUSPENDED);
zap_channel_get_alarms(event->channel);
isdn_data->sig_cb(&sig);
}
break;
}
return ZAP_SUCCESS;
}
static __inline__ void check_events(zap_span_t *span)
{
zap_status_t status;
status = zap_span_poll_event(span, 5);
switch(status) {
case ZAP_SUCCESS:
{
zap_event_t *event;
while (zap_span_next_event(span, &event) == ZAP_SUCCESS) {
if (event->enum_id == ZAP_OOB_NOOP) {
continue;
}
if (process_event(span, event) != ZAP_SUCCESS) {
break;
}
}
}
break;
case ZAP_FAIL:
{
zap_log(ZAP_LOG_DEBUG, "Event Failure! %d\n", zap_running());
}
break;
default:
break;
}
}
static int check_flags(lpwrap_pri_t *spri)
{
zap_span_t *span = spri->private_info;
check_state(span);
if (!zap_running() || zap_test_flag(span, ZAP_SPAN_STOP_THREAD)) {
return -1;
}
check_state(span);
check_events(span);
return 0;
}
......@@ -769,27 +856,29 @@ static void *zap_libpri_run(zap_thread_t *me, void *obj)
{
zap_span_t *span = (zap_span_t *) obj;
zap_libpri_data_t *isdn_data = span->signal_data;
int x, i;
int i, x = 0;
int down = 0;
int got_d = 0;
zap_set_flag(span, ZAP_SPAN_IN_THREAD);
while(zap_running() && !zap_test_flag(span, ZAP_SPAN_STOP_THREAD)) {
x = 0;
for(i = 1; i <= span->chan_count; i++) {
if (span->channels[i]->type == ZAP_CHAN_TYPE_DQ921) {
if (zap_channel_open(span->span_id, i, &isdn_data->dchan) == ZAP_SUCCESS) {
zap_log(ZAP_LOG_DEBUG, "opening d-channel #%d %d:%d\n", x, isdn_data->dchan->span_id, isdn_data->dchan->chan_id);
isdn_data->dchan->state = ZAP_CHANNEL_STATE_UP;
x++;
break;
if (!got_d) {
for(i = 1; i <= span->chan_count; i++) {
if (span->channels[i]->type == ZAP_CHAN_TYPE_DQ921) {
if (zap_channel_open(span->span_id, i, &isdn_data->dchan) == ZAP_SUCCESS) {
zap_log(ZAP_LOG_DEBUG, "opening d-channel #%d %d:%d\n", x, isdn_data->dchan->span_id, isdn_data->dchan->chan_id);
isdn_data->dchan->state = ZAP_CHANNEL_STATE_UP;
got_d = 1;
x++;
break;
}
}
}
}
if (!x || lpwrap_init_pri(&isdn_data->spri,
if (lpwrap_init_pri(&isdn_data->spri,
span, // span
isdn_data->dchan, // dchan
isdn_data->pswitch,
......@@ -820,9 +909,8 @@ static void *zap_libpri_run(zap_thread_t *me, void *obj)
isdn_data->spri.on_loop = check_flags;
isdn_data->spri.private_info = span;
lpwrap_run_pri(&isdn_data->spri);
zap_channel_close(&isdn_data->dchan);
}
if (!zap_running() || zap_test_flag(span, ZAP_SPAN_STOP_THREAD)) {
......@@ -830,9 +918,15 @@ static void *zap_libpri_run(zap_thread_t *me, void *obj)
}
zap_log(ZAP_LOG_CRIT, "PRI down on span %d\n", isdn_data->spri.span->span_id);
zap_set_state_all(span, ZAP_CHANNEL_STATE_RESTART);
check_state(span);
if (!down) {
zap_set_state_all(span, ZAP_CHANNEL_STATE_RESTART);
check_state(span);
}
check_state(span);
check_events(span);
down++;
zap_sleep(5000);
}
......
......@@ -215,7 +215,11 @@ static ZIO_CHANNEL_REQUEST_FUNCTION(ss7_boost_channel_request)
ss7bc_call_init(&event, caller_data->cid_num.digits, caller_data->ani.digits, r);
zap_set_string(event.calling_name, caller_data->cid_name);
zap_set_string(event.redirection_string, caller_data->rdnis.digits);
zap_set_string(event.isup_in_rdnis, caller_data->rdnis.digits);
if (strlen(caller_data->rdnis.digits)) {
event.isup_in_rdnis_size = strlen(caller_data->rdnis.digits)+1;
}
event.calling_number_screening_ind = caller_data->screen;
event.calling_number_presentation = caller_data->pres;
......@@ -483,7 +487,7 @@ static void handle_call_start(zap_span_t *span, ss7bc_connection_t *mcon, ss7bc_
}
zap_set_string(zchan->caller_data.ani.digits, (char *)event->calling_number_digits);
zap_set_string(zchan->caller_data.dnis.digits, (char *)event->called_number_digits);
zap_set_string(zchan->caller_data.rdnis.digits, (char *)event->redirection_string);
zap_set_string(zchan->caller_data.rdnis.digits, (char *)event->isup_in_rdnis);
zchan->caller_data.screen = event->calling_number_screening_ind;
zchan->caller_data.pres = event->calling_number_presentation;
zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_RING);
......@@ -851,7 +855,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
zap_span_t *span = (zap_span_t *) obj;
zap_ss7_boost_data_t *ss7_boost_data = span->signal_data;
ss7bc_connection_t *mcon, *pcon;
uint32_t ms = 10, too_long = 20000;
uint32_t ms = 10; //, too_long = 20000;
ss7_boost_data->pcon = ss7_boost_data->mcon;
......@@ -942,6 +946,8 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
pcon->hb_elapsed = 0;
}
#if 0
if (pcon->hb_elapsed >= too_long) {
zap_log(ZAP_LOG_CRIT, "Lost Heartbeat!\n");
zap_set_flag_locked(span, ZAP_SPAN_SUSPENDED);
......@@ -953,6 +959,7 @@ static void *zap_ss7_boost_run(zap_thread_t *me, void *obj)
SIGBOOST_EVENT_SYSTEM_RESTART,
0);
}
#endif
if (zap_running()) {
check_state(span);
......@@ -1094,7 +1101,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_ss7_boost_configure_span)
{
zap_ss7_boost_data_t *ss7_boost_data = NULL;
const char *local_ip = "127.0.0.65", *remote_ip = "127.0.0.66";
int local_port = 5300, remote_port = 5300;
int local_port = 53000, remote_port = 53000;
char *var, *val;
int *intval;
......
/****************************************************************************
* sigboost.h $Revision: 1.5 $
* sigboost.h $Revision: 1.13 $
*
* Definitions for the sigboost interface.
*
......@@ -14,6 +14,8 @@
#ifndef _SIGBOOST_H_
#define _SIGBOOST_H_
#define SIGBOOST_VERSION 100
#include <stdint.h>
#include <sys/time.h>
......@@ -48,14 +50,22 @@ enum e_sigboost_release_cause_values
enum e_sigboost_call_setup_ack_nack_cause_values
{
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 117, /* unused Q.850 value */
SIGBOOST_CALL_SETUP_NACK_TEST_CKT_BUSY = 118, /* unused Q.850 value */
SIGBOOST_CALL_SETUP_NACK_INVALID_NUMBER = 28,
/* probable elimination */
//SIGBOOST_CALL_SETUP_RESERVED = 0x00,
//SIGBOOST_CALL_SETUP_CIRCUIT_RESET = 0x10,
//SIGBOOST_CALL_SETUP_NACK_CKT_START_TIMEOUT = 0x11,
//SIGBOOST_CALL_SETUP_NACK_AUTO_CALL_GAP = 0x17,
//SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 34, /* Q.850 value - don't use */
SIGBOOST_CALL_SETUP_NACK_ALL_CKTS_BUSY = 117, /* non Q.850 value indicates local all ckt busy
causing sangoma_mgd to perform automatic call
gapping*/
SIGBOOST_CALL_SETUP_NACK_TEST_CKT_BUSY = 17, /* Q.850 value */
SIGBOOST_CALL_SETUP_NACK_INVALID_NUMBER = 28, /* Q.850 value */
SIGBOOST_CALL_SETUP_CSUPID_DBL_USE = 200, /* unused Q.850 value */
};
enum e_sigboost_huntgroup_values
{
SIGBOOST_HUNTGRP_SEQ_ASC = 0x00, /* sequential with lowest available first */
SIGBOOST_HUNTGRP_SEQ_DESC = 0x01, /* sequential with highest available first */
SIGBOOST_HUNTGRP_RR_ASC = 0x02, /* round-robin with lowest available first */
SIGBOOST_HUNTGRP_RR_DESC = 0x03, /* round-robin with highest available first */
};
#define MAX_DIALED_DIGITS 31
......@@ -67,63 +77,73 @@ enum e_sigboost_call_setup_ack_nack_cause_values
#define CORE_MAX_CHAN_PER_SPAN 30
#define MAX_PENDING_CALLS CORE_MAX_SPANS * CORE_MAX_CHAN_PER_SPAN
/* 0..(MAX_PENDING_CALLS-1) is range of call_setup_id below */
#define SIZE_RDNIS 128
#define SIZE_RDNIS 900
#pragma pack(1)
typedef struct
{
uint8_t capability;
uint8_t uil1p;
}t_sigboost_bearer;
typedef struct
{
uint32_t event_id;
uint16_t version;
uint32_t event_id;
/* delete sequence numbers - SCTP does not need them */
uint32_t fseqno;
uint32_t bseqno;
uint16_t call_setup_id;
uint32_t trunk_group;
uint8_t span;
uint8_t chan;
struct timeval tv;
uint8_t called_number_digits_count;
char called_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
uint8_t calling_number_digits_count; /* it's an array */
char calling_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
uint32_t fseqno;
uint32_t bseqno;
uint16_t call_setup_id;
uint32_t trunk_group;
uint8_t span;
uint8_t chan;
struct timeval tv;
uint8_t called_number_digits_count;
char called_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
uint8_t calling_number_digits_count; /* it's an array */
char calling_number_digits [MAX_DIALED_DIGITS + 1]; /* it's a null terminated string */
/* ref. Q.931 Table 4-11 and Q.951 Section 3 */
uint8_t calling_number_screening_ind;
uint8_t calling_number_presentation;
char calling_name[MAX_DIALED_DIGITS + 1];
uint16_t redirection_string_size;
char redirection_string [SIZE_RDNIS]; /* it's a null terminated string */
/* redir string format:
* http://www.ss7box.com/wiki/tiki-index.php?page=Call+Redirection
* */
uint8_t calling_number_screening_ind;
uint8_t calling_number_presentation;
char calling_name[MAX_DIALED_DIGITS + 1];
t_sigboost_bearer bearer;
uint8_t hunt_group;
uint16_t isup_in_rdnis_size;
char isup_in_rdnis [SIZE_RDNIS]; /* it's a null terminated string */
} t_sigboost_callstart;
#define MIN_SIZE_CALLSTART_MSG (sizeof(t_sigboost_callstart) - SIZE_RDNIS)
#define MIN_SIZE_CALLSTART_MSG sizeof(t_sigboost_callstart) - SIZE_RDNIS
typedef struct
{
uint32_t event_id;
uint16_t version;
uint32_t event_id;
/* delete sequence numbers - SCTP does not need them */
uint32_t fseqno;
uint32_t bseqno;
uint16_t call_setup_id;
uint32_t trunk_group;
uint8_t span;
uint8_t chan;
struct timeval tv;
uint8_t release_cause;
uint32_t fseqno;
uint32_t bseqno;
uint16_t call_setup_id;
uint32_t trunk_group;
uint8_t span;
uint8_t chan;
struct timeval tv;
uint8_t release_cause;
} t_sigboost_short;
#pragma pack()
static inline int boost_full_event(int event_id)
{
switch (event_id) {
case SIGBOOST_EVENT_CALL_START:
case SIGBOOST_EVENT_DIGIT_IN:
return 1;
default:
return 0;
}
return 0;
switch (event_id) {
case SIGBOOST_EVENT_CALL_START:
case SIGBOOST_EVENT_DIGIT_IN:
return 1;
default:
return 0;
}
return 0;
}
#endif
......@@ -73,7 +73,7 @@ static void ss7bc_print_event_call(ss7bc_connection_t *mcon, ss7bc_event_t *even
{
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
return;
zap_log(file, func, line, ZAP_LOG_LEVEL_DEBUG, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s]\n",
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT: %s:(%X) [w%dg%d] CSid=%i Seq=%i Cn=[%s] Cd=[%s] Ci=[%s]\n",
dir ? "TX":"RX",
ss7bc_event_id_name(event->event_id),
event->event_id,
......@@ -91,7 +91,7 @@ static void ss7bc_print_event_short(ss7bc_connection_t *mcon, ss7bc_short_event_
{
if (event->event_id == SIGBOOST_EVENT_HEARTBEAT)
return;
zap_log(file, func, line, ZAP_LOG_LEVEL_DEBUG, "%s EVENT (%s): %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i \n",
zap_log(file, func, line, ZAP_LOG_LEVEL_WARNING, "%s EVENT (%s): %s:(%X) [w%dg%d] Rc=%i CSid=%i Seq=%i \n",
dir ? "TX":"RX",
priority ? "P":"N",
ss7bc_event_id_name(event->event_id),
......@@ -261,6 +261,10 @@ ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration,
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT,
(struct sockaddr *) &mcon->local_addr, &fromlen);
if (mcon->event.version != SIGBOOST_VERSION) {
zap_log(ZAP_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
}
/* Must check for < 0 cannot rely on bytes > MIN_SIZE_... compiler issue */
if (bytes < 0) {
msg_ok=0;
......@@ -293,7 +297,7 @@ ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration,
ss7bc_print_event_short(mcon, (ss7bc_short_event_t*)&mcon->event, 0, 0, file, func, line);
}
#if 1
#if 0
/* NC: NOT USED ANY MORE */
if (mcon->rxseq_reset) {
//if (mcon->event.event_id == SIGBOOST_EVENT_SYSTEM_RESTART_ACK) {
......@@ -310,15 +314,17 @@ ss7bc_event_t *__ss7bc_connection_read(ss7bc_connection_t *mcon, int iteration,
mcon->txwindow = mcon->txseq - mcon->event.bseqno;
mcon->rxseq++;
#if 0
if (mcon->rxseq != mcon->event.fseqno) {
zap_log(ZAP_LOG_CRIT, "Invalid Sequence Number Expect=%i Rx=%i\n", mcon->rxseq, mcon->event.fseqno);
return NULL;
}
#endif
return &mcon->event;
} else {
if (iteration == 0) {
zap_log(ZAP_LOG_CRIT, "Invalid Event length from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
zap_log(ZAP_LOG_CRIT, "NC - Invalid Event length from boost rxlen=%i evsz=%i\n", bytes, sizeof(mcon->event));
return NULL;
}
}
......@@ -332,6 +338,10 @@ ss7bc_event_t *__ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration,
int bytes = 0;
bytes = recvfrom(mcon->socket, &mcon->event, sizeof(mcon->event), MSG_DONTWAIT, (struct sockaddr *) &mcon->local_addr, &fromlen);
if (mcon->event.version != SIGBOOST_VERSION) {
zap_log(ZAP_LOG_CRIT, "Invalid Boost Version %i Expecting %i\n",mcon->event.version, SIGBOOST_VERSION);
}
if (bytes == sizeof(ss7bc_short_event_t)) {
......@@ -356,7 +366,7 @@ ss7bc_event_t *__ss7bc_connection_readp(ss7bc_connection_t *mcon, int iteration,
int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, const char *file, const char *func, int line)
{
int err;
int event_size=sizeof(ss7bc_event_t);
int event_size=MIN_SIZE_CALLSTART_MSG+event->isup_in_rdnis_size;
if (!event || mcon->socket < 0 || !mcon->mutex) {
zap_log(file, func, line, ZAP_LOG_LEVEL_CRIT, "Critical Error: No Event Device\n");
......@@ -395,6 +405,7 @@ int __ss7bc_connection_write(ss7bc_connection_t *mcon, ss7bc_event_t *event, con
event->fseqno = mcon->txseq++;
}
event->bseqno = mcon->rxseq;
event->version = SIGBOOST_VERSION;
err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
zap_mutex_unlock(mcon->mutex);
......@@ -432,6 +443,7 @@ int __ss7bc_connection_writep(ss7bc_connection_t *mcon, ss7bc_event_t *event, co
gettimeofday(&event->tv, NULL);
zap_mutex_lock(mcon->mutex);
event->version = SIGBOOST_VERSION;
err = sendto(mcon->socket, event, event_size, 0, (struct sockaddr *) &mcon->remote_addr, sizeof(mcon->remote_addr));
zap_mutex_unlock(mcon->mutex);
......
......@@ -868,6 +868,9 @@ static ZIO_READ_FUNCTION(zt_read)
if ((r = read(zchan->sockfd, data, *datalen)) > 0) {
break;
}
if (r == 0) {
errs--;
}
}
if (r > 0) {
......@@ -878,7 +881,7 @@ static ZIO_READ_FUNCTION(zt_read)
return ZAP_SUCCESS;
}
return ZAP_FAIL;
return r == 0 ? ZAP_TIMEOUT : ZAP_FAIL;
}
static ZIO_WRITE_FUNCTION(zt_write)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论