Review Board 1.7.16


Make ast_carefulwrite() ... be more careful

Review Request #99 - Created Dec. 18, 2008 and submitted

Russell Bryant
/branches/1.4
13546
Reviewers
asterisk-dev
Asterisk
This patch was written to address some cases where users of the Asterisk Manager Interface could observe partial writes of messages.  In Asterisk 1.4, the function ast_carefulwrite() is used to write data to the socket.  While the function was sort of careful, it was not careful enough.  This patch addresses the following issues:

1) It did not previously handle an error of EINTR from write().
2) It did not handle EINTR or EGAIN errors from poll().
I connected to the AMI, made sure I could still log in, and observed normal looking responses and events.
Review request changed
Updated (Dec. 18, 2008, 9:28 a.m.)
Updated diff to address Mark's suggestions
Ship it!
Posted (Dec. 18, 2008, 9:35 a.m.)
Looks good to me. Just make sure to give it a couple of tests since you have changed things around a bit.
  1. Thanks.  I did run it through the same basic tests that I did with the original patch.  It still appears to work.
/branches/1.4/main/utils.c (Diff revision 2)
 
 
 
 
 
poll should never set errno to EAGAIN, but checking for it here and accepting it as a valid error doesn't really hurt. I'd leave it in for safety's sake.
  1. Ah yes, nice observation.  I'll leave it in anyway, since it doesn't hurt, like you said.

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.