[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-internals
Subject:    Re: my_socket that's useful in detecting portability breakage
From:       Joerg Bruehe <joerg () mysql ! com>
Date:       2008-03-28 9:49:39
Message-ID: 47ECBF33.6020308 () mysql ! com
[Download RAW message or body]

Hi Stewart, all,


Stewart Smith wrote:
> Hi Monty,
> 
> thanks for being able to have a look - 
> 
> On Thu, 2008-03-27 at 11:21 +0200, Michael Widenius wrote:
>>>>>>> "Stewart" == Stewart Smith <stewart@mysql.com> writes:
>> [[...]]
> 
>> The only suggestions I have are the following:
>>
>> - Instead of having 3 include files for sockets, do it with one.
>>   ie, let my_socket.h handle all cases with ifdefs.
>>   (Makes it easier to understand the socket interface with one glance)
> 
> I prefer the style without #ifdefs everywhere, to me it makes it harder
> to read. You can currently read the whole implementation, in your native
> platform API (posix-y or win32) in about 3 screens of code. For seeing
> the differences between platforms, xxdiff actually works really well..
> although should only be needed when bugs are found in the abstraction.
> 
> So I'd prefer to keep it how it is... but feel free to convince me
> otherwise or just say "thou shalt change it" :)

I strongly share Monty's preference for just a single file, with #ifdef 
inside it to differentiate (where necessary):

1) It makes handling much easier, you cannot forget to transfer a file
    just because you don't need it on your current platform.

2) When modifying the file, the risk of missing a branch is much reduced
    if all branches are in the same file.

3) In case several branches share code, you avoid duplicating it.

4) If you have the #ifdef within definitions (say, within a typedef, or
    a function), you are absolutely certain that all branches share the
    same interface, and an "#else ; #error" branch will protect you
    against forgetting any implementation for any branch
    (immediately at definition point, not later at use point).

> 
> [[...]]
> 
> 
> 
> Index: mysql-5.0-ndbwin32/include/my_socket.h
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ mysql-5.0-ndbwin32/include/my_socket.h	2008-03-26 15:09:07.246637043 +1100
> @@ -0,0 +1,12 @@
> +
> +#ifndef MY_SOCKET_H
> +#define MY_SOCKET_H
> +
> +
> +#ifdef __WIN__
> +#include <my_socket_win32.h>
> +#else
> +#include <my_socket_posix.h>
> +#endif
> +
> +#endif
> [[...]]

Please imagine adding a non-WIN non-Posix platform to this ...


Regards,
Jörg

-- 
Joerg Bruehe, Senior Production Engineer
MySQL AB, www.mysql.com
Office:  (+49 30) 417 01 487     VoIP: 4464@sip.mysql.com


-- 
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe:    http://lists.mysql.com/internals?unsub=mysql-internals@progressive-comp.com


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic