* [PATCHv2] gattrib: Fix not changing the buffer size when mtu is reduced
@ 2014-12-01 12:54 Jakub Tyszkowski
2014-12-03 11:48 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Tyszkowski @ 2014-12-01 12:54 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jakub Tyszkowski
Using larger buffer than mtu resulted in not sending the message at all
as encode_pdu() in shared/att.c fails when provided data buffer is
larger than current mtu.
---
attrib/gattrib.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index a04a0ee..cfa3b78 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -324,11 +324,17 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
{
- /* Clients of this expect a buffer to use. */
- if (mtu > attrib->buflen) {
+ /*
+ * Clients of this expect a buffer to use.
+ *
+ * Pdu encoding in sharred/att verifies if whole buffer fits the mtu,
+ * thus we should set the buflen also when mtu is reduced. But we
+ * need to reallocate the buffer only if mtu is larger.
+ */
+ if (mtu > attrib->buflen)
attrib->buf = g_realloc(attrib->buf, mtu);
- attrib->buflen = mtu;
- }
+
+ attrib->buflen = mtu;
return bt_att_set_mtu(attrib->att, mtu);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2] gattrib: Fix not changing the buffer size when mtu is reduced
2014-12-01 12:54 [PATCHv2] gattrib: Fix not changing the buffer size when mtu is reduced Jakub Tyszkowski
@ 2014-12-03 11:48 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-12-03 11:48 UTC (permalink / raw)
To: Jakub Tyszkowski; +Cc: linux-bluetooth
Hi Jakub,
On Monday 01 of December 2014 13:54:06 Jakub Tyszkowski wrote:
> Using larger buffer than mtu resulted in not sending the message at all
> as encode_pdu() in shared/att.c fails when provided data buffer is
> larger than current mtu.
> ---
> attrib/gattrib.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/attrib/gattrib.c b/attrib/gattrib.c
> index a04a0ee..cfa3b78 100644
> --- a/attrib/gattrib.c
> +++ b/attrib/gattrib.c
> @@ -324,11 +324,17 @@ uint8_t *g_attrib_get_buffer(GAttrib *attrib, size_t *len)
>
> gboolean g_attrib_set_mtu(GAttrib *attrib, int mtu)
> {
> - /* Clients of this expect a buffer to use. */
> - if (mtu > attrib->buflen) {
> + /*
> + * Clients of this expect a buffer to use.
> + *
> + * Pdu encoding in sharred/att verifies if whole buffer fits the mtu,
> + * thus we should set the buflen also when mtu is reduced. But we
> + * need to reallocate the buffer only if mtu is larger.
> + */
> + if (mtu > attrib->buflen)
> attrib->buf = g_realloc(attrib->buf, mtu);
> - attrib->buflen = mtu;
> - }
> +
> + attrib->buflen = mtu;
>
> return bt_att_set_mtu(attrib->att, mtu);
> }
Pushed, thanks.
--
Best regards,
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-03 11:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-01 12:54 [PATCHv2] gattrib: Fix not changing the buffer size when mtu is reduced Jakub Tyszkowski
2014-12-03 11:48 ` Szymon Janc
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.