better handling of disconnections by monitor clients.

This commit is contained in:
gardners 2012-05-04 03:58:34 +09:30
parent e71b2385e6
commit 6bc8f5643f
2 changed files with 38 additions and 30 deletions

View File

@ -227,8 +227,9 @@ int monitor_poll()
bytes=-1;
break;
}
errno=0;
bytes=read(c->socket,&c->line[c->line_length],1);
if (bytes==-1) {
if (bytes<1) {
switch(errno) {
case EAGAIN: case EINTR:
/* transient errors */
@ -263,10 +264,11 @@ int monitor_poll()
}
break;
case MONITOR_STATE_DATA:
errno=0;
bytes=read(c->socket,
&c->buffer[c->data_offset],
c->data_expected-c->data_offset);
if (bytes==-1) {
if (bytes<1) {
switch(errno) {
case EAGAIN: case EINTR:
/* transient errors */
@ -451,9 +453,13 @@ int monitor_process_data(int index)
int monitor_call_status(vomp_call_state *call)
{
int i;
WHYF("Tell call monitor about call %06x:%06x",
call->local.session,call->remote.session);
char msg[1024];
int show=0;
if (call->local.state>call->local.last_state) show=1;
if (call->remote.state>call->remote.last_state) show=1;
call->local.last_state=call->local.state;
call->remote.last_state=call->remote.state;
if (show) {
snprintf(msg,1024,"CALLSTATUS:%06x:%06x:%d:%d\n",
call->local.session,call->remote.session,
call->local.state,call->remote.state);
@ -483,6 +489,7 @@ int monitor_call_status(vomp_call_state *call)
}
}
}
}
return 0;
}

View File

@ -1275,6 +1275,7 @@ typedef struct vomp_call_half {
unsigned char sid[SID_SIZE];
unsigned char did[64];
unsigned char state;
unsigned char last_state; // last state communicated to monitoring parties
unsigned char codec;
unsigned int session;
#define VOMP_SESSION_MASK 0xffffff