[ libetpan-Bugs-2962732 ] Incorrect write(read) in case send returnes WSAEWOULDBLOCK

"SourceForge.net" <[email protected]> Wed, 03 Mar 2010 17:21:43 +0000
Newsgroups gmane.mail.libetpan.user
Message-ID <[email protected]>
Bugs item #2962732, was opened at 2010-03-03 20:21
Message generated for change (Tracker Item Submitted) made by perminov
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=429696&aid=2962732&group_id=41064

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: SMTP
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Sergey Perminov (perminov)
Assigned to: Nobody/Anonymous (nobody)
Summary: Incorrect write(read) in case send returnes WSAEWOULDBLOCK

Initial Comment:
Version: libetpan-0.58

Problem is in src/data-types/mailstream_socket.c
mailstream_low_socket_write function

Here is code:
return send(socket_data->fd, buf, count, 0);

Actually it may return -1 and WSAGetLastError() in that case could be WSAEWOULDBLOCK
It indicates that it's impossible to write in socket at the moment
but it's not critical. In this case we must just try to write again (obtaining select for FD_WRITE )

As a solution this function may just return 0 in that case, something like

 size_t  ret = send(socket_data->fd, buf, count, 0);
  if (ret <= 0) {
	  int le = WSAGetLastError();
	  if (le == WSAEWOULDBLOCK)
		  return 0;
  }

  return ret;


This problem is well reproducible on MS Exchange server with big emails.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=429696&aid=2962732&group_id=41064

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev