Autore Topic: Modifica importante nella revisione #6691  (Letto 212 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.317
  • Ne mors quidem nos iunget
    • Mostra profilo
Modifica importante nella revisione #6691
« il: 01 Dicembre 2014, 01:54:00 »
Vi riporto questo messaggio di Minisini:


" Hi,

I'm trying to fix a problem in the Gambas process management that annoys
a lot of people for a long time.

Sometimes, the output of the process is not entirely read. Some data is
lost.

This is because I was using a way of detecting data availability that
was not reliable. I thought it was, but I was wrong.

Concretely, the select() system call tells you if there is data
available to read, but, in some cases, it wakes up and there is actually
no data to read.

So I tried to use a end-of-stream check by using various system calls
(it depends on the type of file descriptor: file, pipe, socket...). But
this routine sometimes fails.

To change that, I now read data ahead by chunk of 1KB before actually
raising the Read event.

Apparently, using select() + read() is the correct way of accurately
detecting end of stream, especially on pipes.

Consequently, if the read ahead fails, I decide there is nothing to read
anymore and I close the stream.

Hopefully, this was not a big job, as internally read ahead was already
implemented for optimizing the INPUT and LINE INPUT instruction.

But this is a big change that may have side effects, so I ask people who
run Gambas projects that watch a lot of file descriptors, and read the
output of a lot of external processes, to use that revision and report
any problem.

Regards,

--
Benoît Minisini
"
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »