Don’t you just love being compatible?

/* Force server down. kill all connections and threads and exit */

#if defined(OS2) || defined(__NETWARE__)
extern "C" void kill_server(int sig_ptr)
#define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN
#elif !defined(__WIN__)
static void *kill_server(void *sig_ptr)
#define RETURN_FROM_KILL_SERVER DBUG_RETURN(0)
#else
static void __cdecl kill_server(int sig_ptr)
#define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN
#endif
{
DBUG_ENTER("kill_server");

(from sql/mysqld.cc)

There just has to be a better way to do this….

maybe we need a kill_server which is platform defined (e.g. in a mythical win32.cc, netware.cc or generic_sane_unix.cc) and the generic _kill_server in mysqld.cc? possibly some variation of… some platforms seem to do strange things.

i don’t know. it just doesn’t look that clean to me…. maybe i need more coffee.

2 thoughts on “Don’t you just love being compatible?

  1. Slightly more readable, but still annoying :)

    #if !defined(__WIN__)
    #define RETURN_FROM_KILL_SERVER DBUG_RETURN(0)
    #else
    #define RETURN_FROM_KILL_SERVER DBUG_VOID_RETURN
    #endif

    #if defined(OS2) || defined(__NETWARE__)
    extern “C” void kill_server(int sig_ptr)
    #elif !defined(__WIN__)
    static void *kill_server(void *sig_ptr)
    #else
    static void __cdecl kill_server(int sig_ptr)
    #endif
    {
    DBUG_ENTER(“kill_server”);

    But I do agree it would be a cleaner organization to put platform-dependent definitions in their own files under /include, so that instead of repeating these platform switches all over the place, they only had to be done once in the main server file /sql/mysqld.cc. It would allow for easier maintenance and make the code more readable.

    Cheers,

    J

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.