diff options
author | Dan Williams <dcbw@redhat.com> | 2010-03-20 02:57:33 -0700 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2010-03-20 02:57:33 -0700 |
commit | ff2182fe1d1fdc6817835839c062129d1adb629d (patch) | |
tree | 0e09fa1733502ee9c5235918653c8f18d11599d6 /src/mm-serial-port.c | |
parent | 4006ca4decaec051aa4449977d92f96545b3aa88 (diff) |
core: let partial serial responses be consumed by the handlers
Diffstat (limited to 'src/mm-serial-port.c')
-rw-r--r-- | src/mm-serial-port.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 46e9c567..609e20de 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -492,7 +492,7 @@ mm_serial_port_schedule_queue_process (MMSerialPort *self) g_source_unref (source); } -static void +static gsize real_handle_response (MMSerialPort *self, GByteArray *response, GError *error, @@ -502,6 +502,7 @@ real_handle_response (MMSerialPort *self, MMSerialResponseFn response_callback = (MMSerialResponseFn) callback; response_callback (self, response, error, callback_data); + return response->len; } static void @@ -509,6 +510,7 @@ mm_serial_port_got_response (MMSerialPort *self, GError *error) { MMSerialPortPrivate *priv = MM_SERIAL_PORT_GET_PRIVATE (self); MMQueueData *info; + gsize consumed = priv->response->len; if (priv->timeout_id) { g_source_remove (priv->timeout_id); @@ -522,11 +524,11 @@ mm_serial_port_got_response (MMSerialPort *self, GError *error) if (info->callback) { g_warn_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->handle_response != NULL); - MM_SERIAL_PORT_GET_CLASS (self)->handle_response (self, - priv->response, - error, - info->callback, - info->user_data); + consumed = MM_SERIAL_PORT_GET_CLASS (self)->handle_response (self, + priv->response, + error, + info->callback, + info->user_data); } g_byte_array_free (info->command, TRUE); @@ -536,8 +538,8 @@ mm_serial_port_got_response (MMSerialPort *self, GError *error) if (error) g_error_free (error); - if (priv->response->len) - g_byte_array_remove_range (priv->response, 0, priv->response->len); + if (consumed) + g_byte_array_remove_range (priv->response, 0, consumed); if (!g_queue_is_empty (priv->queue)) mm_serial_port_schedule_queue_process (self); } |