SPARK-2368 Making FileServerHandler sends gracefully to prevent OOM

Busy wait for the channel to be ready before writing to it to prevent
the buffer from exploding.

Also making some small code changes for clarity.
This method is incorrect - if channel was writable initially, it will exit immediately without any write.
This can, btw, happen between writeAndFlush returning and check for isWritable again.

Has this patch been tested ?