On Thu, Oct 23, 2008 at 12:14 AM, Dan Kegel <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 22, 2008 at 11:11 AM, Ibrar Ahmed <[EMAIL PROTECTED]> wrote:
>> Agreed, but if we are not wrapping these function then we are doing
>> the same on every call of GetLastError what you want to avoid.
>
> Again, we tend to not do fine-grained #ifdef's like that, we
> port at a higher level of abstraction.
>
But some time we can achieve the paltfarm independence by just
fine-grained #ifdef, for example

[Windows Code]

 char c;
 int rv = recv(socket_, &c, 1, MSG_PEEK);
 if (rv == 0)
   return false;
 if (rv == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK)
   return false;

Currently we have wrapped the whole function (some places created new
OS file) and wrote the same code for Linux like this


[Linux Code]

 // Check if connection is alive.
 char c;
 int rv = recv(socket_, &c, 1, MSG_PEEK);
 if (rv == 0)
   return false;
 if (rv == -1 && errno != EAGAIN && errno != EWOULDBLOCK)
   return false;

 return true;

So whats the big difference between these function just the error
checking. And we have written whole function again just because of
errno :(


But after my suggestion this code looks like this

 char c;
 int rv = recv(socket_, &c, 1, MSG_PEEK);
 if (rv == 0)
   return false;
 if (rv == SOCKET_ERROR && Platfarm::GetLastError() != WSAEWOULDBLOCK)
   return false;

so this code will compile without any change; on different OS.


-- 
   Ibrar Ahmed
   EnterpriseDB   http://www.enterprisedb.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Chromium-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/chromium-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to