Perform more queue management in channels
This commit is contained in:
parent
2aa7a53fb8
commit
edb9fbd1c5
@ -187,7 +187,6 @@ static int _hayes_queue_command(Hayes * hayes, HayesChannel * channel,
|
|||||||
static int _hayes_queue_command_full(Hayes * hayes,
|
static int _hayes_queue_command_full(Hayes * hayes,
|
||||||
char const * attention, HayesCommandCallback callback);
|
char const * attention, HayesCommandCallback callback);
|
||||||
#endif
|
#endif
|
||||||
static int _hayes_queue_pop(Hayes * hayes, HayesChannel * channel);
|
|
||||||
static int _hayes_queue_push(Hayes * hayes, HayesChannel * channel);
|
static int _hayes_queue_push(Hayes * hayes, HayesChannel * channel);
|
||||||
|
|
||||||
/* requests */
|
/* requests */
|
||||||
@ -1064,7 +1063,7 @@ static int _parse_do(Hayes * hayes, HayesChannel * channel)
|
|||||||
/* unqueue if complete */
|
/* unqueue if complete */
|
||||||
if(hayes_command_is_complete(command))
|
if(hayes_command_is_complete(command))
|
||||||
{
|
{
|
||||||
_hayes_queue_pop(hayes, channel);
|
hayeschannel_queue_pop(channel);
|
||||||
_hayes_queue_push(hayes, channel);
|
_hayes_queue_push(hayes, channel);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -1177,24 +1176,6 @@ static int _hayes_queue_command_full(Hayes * hayes,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* hayes_queue_pop */
|
|
||||||
static int _hayes_queue_pop(Hayes * hayes, HayesChannel * channel)
|
|
||||||
{
|
|
||||||
HayesCommand * command;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
|
||||||
#endif
|
|
||||||
_hayes_reset_source(&channel->timeout);
|
|
||||||
if(channel->queue == NULL) /* nothing to send */
|
|
||||||
return 0;
|
|
||||||
command = channel->queue->data; /* XXX assumes it's valid */
|
|
||||||
hayes_command_delete(command);
|
|
||||||
channel->queue = g_slist_remove(channel->queue, command);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* hayes_queue_push */
|
/* hayes_queue_push */
|
||||||
static int _queue_push_do(Hayes * hayes, HayesChannel * channel);
|
static int _queue_push_do(Hayes * hayes, HayesChannel * channel);
|
||||||
|
|
||||||
@ -1226,7 +1207,7 @@ static int _queue_push_do(Hayes * hayes, HayesChannel * channel)
|
|||||||
if(hayes_command_set_status(command, HCS_PENDING) != HCS_PENDING)
|
if(hayes_command_set_status(command, HCS_PENDING) != HCS_PENDING)
|
||||||
{
|
{
|
||||||
/* no longer push the command */
|
/* no longer push the command */
|
||||||
_hayes_queue_pop(hayes, channel);
|
hayeschannel_queue_pop(channel);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
attention = hayes_command_get_attention(command);
|
attention = hayes_command_get_attention(command);
|
||||||
@ -1237,7 +1218,7 @@ static int _queue_push_do(Hayes * hayes, HayesChannel * channel)
|
|||||||
if((p = realloc(channel->wr_buf, channel->wr_buf_cnt + size)) == NULL)
|
if((p = realloc(channel->wr_buf, channel->wr_buf_cnt + size)) == NULL)
|
||||||
{
|
{
|
||||||
hayes_command_set_status(command, HCS_ERROR);
|
hayes_command_set_status(command, HCS_ERROR);
|
||||||
_hayes_queue_pop(hayes, channel);
|
hayeschannel_queue_pop(channel);
|
||||||
return -hayes->helper->error(hayes->helper->modem, strerror(
|
return -hayes->helper->error(hayes->helper->modem, strerror(
|
||||||
errno), 1);
|
errno), 1);
|
||||||
}
|
}
|
||||||
@ -2145,7 +2126,7 @@ static gboolean _on_channel_timeout(gpointer data)
|
|||||||
if(channel->queue == NULL || (command = channel->queue->data) == NULL)
|
if(channel->queue == NULL || (command = channel->queue->data) == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
hayes_command_set_status(command, HCS_TIMEOUT);
|
hayes_command_set_status(command, HCS_TIMEOUT);
|
||||||
_hayes_queue_pop(hayes, channel);
|
hayeschannel_queue_pop(channel);
|
||||||
_hayes_queue_push(hayes, channel);
|
_hayes_queue_push(hayes, channel);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,24 @@ void hayeschannel_queue_flush(HayesChannel * channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* hayeschannel_queue_pop */
|
||||||
|
int hayeschannel_queue_pop(HayesChannel * channel)
|
||||||
|
{
|
||||||
|
HayesCommand * command;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "DEBUG: %s()\n", __func__);
|
||||||
|
#endif
|
||||||
|
_hayeschannel_reset_source(&channel->timeout);
|
||||||
|
if(channel->queue == NULL) /* nothing to send */
|
||||||
|
return 0;
|
||||||
|
command = channel->queue->data; /* XXX assumes it's valid */
|
||||||
|
hayes_command_delete(command);
|
||||||
|
channel->queue = g_slist_remove(channel->queue, command);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
/* functions */
|
/* functions */
|
||||||
/* hayeschannel_reset_source */
|
/* hayeschannel_reset_source */
|
||||||
|
@ -90,5 +90,6 @@ void hayeschannel_destroy(HayesChannel * channel);
|
|||||||
|
|
||||||
/* queue management */
|
/* queue management */
|
||||||
void hayeschannel_queue_flush(HayesChannel * channel);
|
void hayeschannel_queue_flush(HayesChannel * channel);
|
||||||
|
int hayeschannel_queue_pop(HayesChannel * channel);
|
||||||
|
|
||||||
#endif /* PHONE_MODEM_HAYES_CHANNEL_H */
|
#endif /* PHONE_MODEM_HAYES_CHANNEL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user