mirror of git://git.sysmocom.de/ofono
gatchat: Replace shutdown by suspend/resume
Shutdown was actually pointless and according to Marcel he only had it in mind for PPP useage.
This commit is contained in:
parent
7b8f4f5dc8
commit
3aa1faddef
|
@ -79,6 +79,7 @@ struct _GAtChat {
|
||||||
GAtDisconnectFunc user_disconnect; /* user disconnect func */
|
GAtDisconnectFunc user_disconnect; /* user disconnect func */
|
||||||
gpointer user_disconnect_data; /* user disconnect data */
|
gpointer user_disconnect_data; /* user disconnect data */
|
||||||
guint read_so_far; /* Number of bytes processed */
|
guint read_so_far; /* Number of bytes processed */
|
||||||
|
gboolean suspended; /* Are we suspended? */
|
||||||
GAtDebugFunc debugf; /* debugging output function */
|
GAtDebugFunc debugf; /* debugging output function */
|
||||||
gpointer debug_data; /* Data to pass to debug func */
|
gpointer debug_data; /* Data to pass to debug func */
|
||||||
char *pdu_notify; /* Unsolicited Resp w/ PDU */
|
char *pdu_notify; /* Unsolicited Resp w/ PDU */
|
||||||
|
@ -638,7 +639,7 @@ static void new_bytes(struct ring_buffer *rbuf, gpointer user_data)
|
||||||
|
|
||||||
g_at_chat_ref(p);
|
g_at_chat_ref(p);
|
||||||
|
|
||||||
while (p->channel && (p->read_so_far < len)) {
|
while (p->suspended == FALSE && (p->read_so_far < len)) {
|
||||||
gsize rbytes = MIN(len - p->read_so_far, wrap - p->read_so_far);
|
gsize rbytes = MIN(len - p->read_so_far, wrap - p->read_so_far);
|
||||||
result = p->syntax->feed(p->syntax, (char *)buf, &rbytes);
|
result = p->syntax->feed(p->syntax, (char *)buf, &rbytes);
|
||||||
|
|
||||||
|
@ -933,6 +934,28 @@ GAtChat *g_at_chat_ref(GAtChat *chat)
|
||||||
return chat;
|
return chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void g_at_chat_suspend(GAtChat *chat)
|
||||||
|
{
|
||||||
|
if (chat == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
chat->suspended = TRUE;
|
||||||
|
|
||||||
|
g_at_io_set_read_handler(chat->io, NULL, NULL);
|
||||||
|
g_at_io_set_debug(chat->io, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void g_at_chat_resume(GAtChat *chat)
|
||||||
|
{
|
||||||
|
if (chat == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
chat->suspended = FALSE;
|
||||||
|
|
||||||
|
g_at_io_set_read_handler(chat->io, new_bytes, chat);
|
||||||
|
g_at_io_set_debug(chat->io, chat->debugf, chat->debug_data);
|
||||||
|
}
|
||||||
|
|
||||||
void g_at_chat_unref(GAtChat *chat)
|
void g_at_chat_unref(GAtChat *chat)
|
||||||
{
|
{
|
||||||
gboolean is_zero;
|
gboolean is_zero;
|
||||||
|
@ -945,23 +968,15 @@ void g_at_chat_unref(GAtChat *chat)
|
||||||
if (is_zero == FALSE)
|
if (is_zero == FALSE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_at_chat_shutdown(chat);
|
|
||||||
g_free(chat);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean g_at_chat_shutdown(GAtChat *chat)
|
|
||||||
{
|
|
||||||
if (chat->io == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (chat->write_watch)
|
if (chat->write_watch)
|
||||||
g_source_remove(chat->write_watch);
|
g_source_remove(chat->write_watch);
|
||||||
|
|
||||||
g_at_io_set_read_handler(chat->io, NULL, NULL);
|
g_at_chat_suspend(chat);
|
||||||
|
|
||||||
g_at_io_unref(chat->io);
|
g_at_io_unref(chat->io);
|
||||||
g_at_chat_cleanup(chat);
|
g_at_chat_cleanup(chat);
|
||||||
|
|
||||||
return TRUE;
|
g_free(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean g_at_chat_set_disconnect_function(GAtChat *chat,
|
gboolean g_at_chat_set_disconnect_function(GAtChat *chat,
|
||||||
|
|
|
@ -46,7 +46,8 @@ GIOChannel *g_at_chat_get_channel(GAtChat *chat);
|
||||||
GAtChat *g_at_chat_ref(GAtChat *chat);
|
GAtChat *g_at_chat_ref(GAtChat *chat);
|
||||||
void g_at_chat_unref(GAtChat *chat);
|
void g_at_chat_unref(GAtChat *chat);
|
||||||
|
|
||||||
gboolean g_at_chat_shutdown(GAtChat *chat);
|
void g_at_chat_suspend(GAtChat *chat);
|
||||||
|
void g_at_chat_resume(GAtChat *chat);
|
||||||
|
|
||||||
gboolean g_at_chat_set_disconnect_function(GAtChat *chat,
|
gboolean g_at_chat_set_disconnect_function(GAtChat *chat,
|
||||||
GAtDisconnectFunc disconnect, gpointer user_data);
|
GAtDisconnectFunc disconnect, gpointer user_data);
|
||||||
|
|
Loading…
Reference in New Issue