forked from external/yambar
module/script: process *all* transactions received in a single read()
When the script module received multiple transactions in a single batch, only the first were processed. This lead to multiple, unprocessed transactions stacking up in the receive buffer. Every time a new transaction was received, we popped the oldest transaction from the buffer, but never actually getting to the last one. This is perceived as "lag" by the user, where the bar displays outdated information. Closes #221
This commit is contained in:
parent
d002919bad
commit
5da1cd4a38
2 changed files with 18 additions and 14 deletions
|
@ -106,13 +106,15 @@
|
||||||
* Crash when a particle is “too wide”, and tries to render outside the
|
* Crash when a particle is “too wide”, and tries to render outside the
|
||||||
bar ([#198][198]).
|
bar ([#198][198]).
|
||||||
* string: crash when failing to convert string to UTF-32.
|
* string: crash when failing to convert string to UTF-32.
|
||||||
|
* script: only first transaction processed when receiving multiple
|
||||||
|
transactions in a single batch ([#221][221]).
|
||||||
|
|
||||||
[169]: https://codeberg.org/dnkl/yambar/issues/169
|
[169]: https://codeberg.org/dnkl/yambar/issues/169
|
||||||
[172]: https://codeberg.org/dnkl/yambar/issues/172
|
[172]: https://codeberg.org/dnkl/yambar/issues/172
|
||||||
[178]: https://codeberg.org/dnkl/yambar/issues/178
|
[178]: https://codeberg.org/dnkl/yambar/issues/178
|
||||||
[177]: https://codeberg.org/dnkl/yambar/issues/177
|
[177]: https://codeberg.org/dnkl/yambar/issues/177
|
||||||
[198]: https://codeberg.org/dnkl/yambar/issues/198
|
[198]: https://codeberg.org/dnkl/yambar/issues/198
|
||||||
|
[221]: https://codeberg.org/dnkl/yambar/issues/221
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
|
@ -313,6 +313,7 @@ data_received(struct module *mod, const char *data, size_t len)
|
||||||
memcpy(&m->recv_buf.data[m->recv_buf.idx], data, len);
|
memcpy(&m->recv_buf.data[m->recv_buf.idx], data, len);
|
||||||
m->recv_buf.idx += len;
|
m->recv_buf.idx += len;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
const char *eot = memmem(m->recv_buf.data, m->recv_buf.idx, "\n\n", 2);
|
const char *eot = memmem(m->recv_buf.data, m->recv_buf.idx, "\n\n", 2);
|
||||||
if (eot == NULL) {
|
if (eot == NULL) {
|
||||||
/* End of transaction not yet available */
|
/* End of transaction not yet available */
|
||||||
|
@ -327,6 +328,7 @@ data_received(struct module *mod, const char *data, size_t len)
|
||||||
&m->recv_buf.data[transaction_size + 1],
|
&m->recv_buf.data[transaction_size + 1],
|
||||||
m->recv_buf.idx - (transaction_size + 1));
|
m->recv_buf.idx - (transaction_size + 1));
|
||||||
m->recv_buf.idx -= transaction_size + 1;
|
m->recv_buf.idx -= transaction_size + 1;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue