[haiku-commits] Re: r43050 - haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp

  • From: "Ingo Weinhold" <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 01 Nov 2011 12:58:25 +0100

pulkomandy@xxxxxxxxxxxxxxxxx wrote:
> Date: 2011-10-31 23:39:58 +0100 (Mon, 31 Oct 2011)
> New Revision: 43050
> Changeset: https://dev.haiku-os.org/changeset/43050
> Ticket: https://dev.haiku-os.org/ticket/7557
> 
> Modified:
>  haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp
> Log:
> Wrong fd count given to select. Fixes #7557.
> 
> 
> Modified: haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp
> ===================================================================
> --- haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp 
> 2011-10-31 22:05:24 UTC (rev 43049)
> +++ haiku/trunk/src/add-ons/mail_daemon/outbound_protocols/smtp/smtp.cpp 
> 2011-10-31 22:39:58 UTC (rev 43050)
> @@ -964,7 +964,7 @@
>  result = 1;
>  else
>  #endif
> - result = select(32, &fds, NULL, NULL, &tv);
> + result = select(1, &fds, NULL, NULL, &tv);
>   if (result < 0)
>   return errno;

That doesn't look right. The first select() parameter specifies the range of 
FDs to consider, not the number of FDs to actually select. Given that the 
preceding code does a FD_ZERO(&fds) followed by a FD_SET(fSocket, &fds), the 
minimum correct number to pass in this case would be fSocket + 1. More 
generically FD_SETSIZE does always work.

CU, Ingo

Other related posts: