Problem fixed by adding a select() call to implement a timeout, and retrying writes if needed.
Attach a file by drag & drop or click to upload