Changeset 555

Show
Ignore:
Timestamp:
05/08/07 00:20:20 (2 years ago)
Author:
plindner
Message:

incorporate win32 patch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/memcached-win32/server/assoc.c

    r551 r555  
    1515 
    1616#include "memcached.h" 
     17 
    1718#include <sys/stat.h> 
    1819#include <sys/socket.h> 
     20 
     21#ifndef WIN32 
    1922#include <sys/signal.h> 
    2023#include <sys/resource.h> 
     
    2225#include <netinet/in.h> 
    2326#include <errno.h> 
     27#else /* !WIN32 */ 
     28#include "Win32-Code/config.h" 
     29#include <Winsock2.h> 
     30#endif /* WIN32 */ 
     31 
    2432#include <stdlib.h> 
    2533#include <stdio.h> 
  • branches/memcached-win32/server/items.c

    r551 r555  
    99#include <netinet/in.h> 
    1010#include <errno.h> 
     11#else /* !WIN32 */ 
     12#include <Winsock2.h> 
     13#endif /* WIN32 */ 
    1114#include <stdlib.h> 
    1215#include <stdio.h> 
  • branches/memcached-win32/server/memcached.c

    r552 r555  
    1818#include "memcached.h" 
    1919#include <sys/stat.h> 
     20 
     21#ifndef WIN32 
    2022#include <sys/socket.h> 
    2123#include <sys/un.h> 
     
    3941#include <arpa/inet.h> 
    4042#include <errno.h> 
     43#else /* !WIN32 */ 
     44#include "Win32-Code/config.h" 
     45#include <Winsock2.h> 
     46#include <process.h> 
     47#include "Win32-Code/ntservice.h" 
     48#include "compat/bsd_getopt.h" 
     49#endif /* WIN32 */ 
    4150#include <stdlib.h> 
    4251#include <stdio.h> 
     
    854863        return; 
    855864    } 
     865#endif /* !WIN32 */ 
    856866 
    857867    command = tokens[COMMAND_TOKEN].value; 
     
    21922202} 
    21932203 
     2204#ifndef WIN32 
    21942205static int server_socket_unix(const char *path) { 
    21952206    int sfd; 
     
    22392250    return sfd; 
    22402251} 
     2252#endif /* WIN32 */ 
     2253 
    22412254 
    22422255/* listening socket */ 
     
    22482261/* invoke right before gdb is called, on assert */ 
    22492262void pre_gdb(void) { 
     2263#ifndef WIN32 
    22502264    int i; 
    22512265    if (l_socket > -1) close(l_socket); 
     
    22532267    for (i = 3; i <= 500; i++) close(i); /* so lame */ 
    22542268    kill(getpid(), SIGABRT); 
     2269#endif 
    22552270} 
    22562271 
     
    23342349           "-s <file>     unix socket path to listen on (disables network support)\n" 
    23352350           "-l <ip_addr>  interface to listen on, default is INDRR_ANY\n" 
     2351#ifndef WIN32 
    23362352           "-d            run as a daemon\n" 
     2353#else /* !WIN32 */ 
     2354           "-d start          tell memcached to start\n" 
     2355           "-d restart        tell running memcached to do a graceful restart\n" 
     2356           "-d stop|shutdown  tell running memcached to shutdown\n" 
     2357           "-d install        install memcached service\n" 
     2358           "-d uninstall      uninstall memcached service\n" 
     2359#endif /* WIN32 */ 
    23372360           "-r            maximize core file limit\n" 
    23382361           "-u <username> assume identity of <username> (only when run as root)\n" 
     
    24212444    "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n" 
    24222445    "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" 
     2446#ifdef WIN32 
     2447        "This product includes software developed by the NetBSD\n" 
     2448        "Foundation, Inc. and its contributors.\n" 
     2449        "\n" 
     2450        "[ bsd_getopts ]\n" 
     2451        "\n" 
     2452        "Copyright (c) 2000 The NetBSD Foundation, Inc.\n" 
     2453        "All rights reserved.\n" 
     2454        "\n" 
     2455        "This code is derived from software contributed to The NetBSD Foundation\n" 
     2456        "by Dieter Baron and Thomas Klausner.\n" 
     2457        "\n" 
     2458        "Redistribution and use in source and binary forms, with or without\n" 
     2459        "modification, are permitted provided that the following conditions\n" 
     2460        "are met:\n" 
     2461        "1. Redistributions of source code must retain the above copyright\n" 
     2462        "   notice, this list of conditions and the following disclaimer.\n" 
     2463        "2. Redistributions in binary form must reproduce the above copyright\n" 
     2464        "   notice, this list of conditions and the following disclaimer in the\n" 
     2465        "   documentation and/or other materials provided with the distribution.\n" 
     2466        "3. All advertising materials mentioning features or use of this software\n" 
     2467        "   must display the following acknowledgement:\n" 
     2468        "       This product includes software developed by the NetBSD\n" 
     2469        "       Foundation, Inc. and its contributors.\n" 
     2470        "4. Neither the name of The NetBSD Foundation nor the names of its\n" 
     2471        "   contributors may be used to endorse or promote products derived\n" 
     2472        "   from this software without specific prior written permission.\n" 
     2473        "\n" 
     2474        "THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS\n" 
     2475        "``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n" 
     2476        "TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n" 
     2477        "PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS\n" 
     2478        "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n" 
     2479        "CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n" 
     2480        "SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n" 
     2481        "INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n" 
     2482        "CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n" 
     2483        "ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n" 
     2484        "POSSIBILITY OF SUCH DAMAGE.\n" 
     2485        "\n" 
     2486        "\n"     
     2487        "Win32 port by Kronuz\n" 
     2488        "This product includes software developed by Kronuz.\n" 
     2489        "\n" 
     2490        "[ ntservice ]\n" 
     2491        "\n" 
     2492        "Copyright (c) 2006 Germán Méndez Bravo (Kronuz) <kronuz@users.sf.net>\n" 
     2493        "All rights reserved.\n" 
     2494        "\n" 
     2495        "Redistribution and use in source and binary forms, with or without\n" 
     2496        "modification, are permitted provided that the following conditions\n" 
     2497        "are met:\n" 
     2498        "1. Redistributions of source code must retain the above copyright\n" 
     2499        "   notice, this list of conditions and the following disclaimer.\n" 
     2500        "2. Redistributions in binary form must reproduce the above copyright\n" 
     2501        "   notice, this list of conditions and the following disclaimer in the\n" 
     2502        "   documentation and/or other materials provided with the distribution.\n" 
     2503        "3. All advertising materials mentioning features or use of this software\n" 
     2504        "   must display the following acknowledgement:\n" 
     2505        "      This product includes software developed by Kronuz.\n" 
     2506        "4. The name of the author may not be used to endorse or promote products\n" 
     2507        "   derived from this software without specific prior written permission.\n" 
     2508        "\n" 
     2509        "THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n" 
     2510        "IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n" 
     2511        "OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n" 
     2512        "IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n" 
     2513        "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n" 
     2514        "NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n" 
     2515        "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n" 
     2516        "THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n" 
     2517        "(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n" 
     2518        "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" 
     2519#endif /* WIN32 */ 
    24232520    ); 
    24242521 
     
    24672564    char *username = NULL; 
    24682565    char *pid_file = NULL; 
     2566 
     2567#ifndef WIN32 
    24692568    struct passwd *pw; 
    24702569    struct sigaction sa; 
     
    24732572    /* handle SIGINT */ 
    24742573    signal(SIGINT, sig_handler); 
     2574#else /* !WIN32 */ 
     2575    WSADATA wsaData; 
     2576    if(WSAStartup(MAKEWORD(2,0), &wsaData) != 0) { 
     2577        fprintf(stderr, "Socket Initialization Error. Program  aborted\n"); 
     2578        return; 
     2579    } 
     2580#endif /* WIN32 */ 
    24752581 
    24762582    /* init settings */ 
     
    25962702        } 
    25972703    } 
     2704#endif /* !WIN32 */ 
    25982705 
    25992706    /* 
     
    26422749    } 
    26432750 
     2751#ifndef WIN32 
    26442752    /* lose root privileges if we have them */ 
    26452753    if (getuid() == 0 || geteuid() == 0) { 
     
    26662774        } 
    26672775    } 
    2668  
     2776#endif /* !WIN32 */ 
     2777 
     2778#ifndef WIN32 
    26692779    /* daemonize if requested */ 
    26702780    /* if we want to ensure our ability to dump core, don't chdir to / */ 
     
    27072817    } 
    27082818 
     2819#ifndef WIN32 
    27092820    /* 
    27102821     * ignore SIGPIPE signals; we can use errno==EPIPE if we 
     
    27182829        exit(EXIT_FAILURE); 
    27192830    } 
     2831#endif /* !WIN32 */ 
    27202832    /* create the initial listening connection */ 
    27212833    if (!(listen_conn = conn_new(l_socket, conn_listening, 
  • branches/memcached-win32/server/memcached.h

    r552 r555  
    22/* $Id$ */ 
    33 
     4 
     5 
     6#ifndef WIN32 
    47#include "config.h" 
    58#include <sys/types.h> 
     
    811#include <netinet/in.h> 
    912#include <event.h> 
     13 
     14#else 
     15#include "Win32-Code/win32.h" 
     16#endif /* WIN32 */ 
    1017 
    1118#define DATA_BUFFER_SIZE 2048 
  • branches/memcached-win32/server/slabs.c

    r551 r555  
    1212#include "memcached.h" 
    1313#include <sys/stat.h> 
     14 
     15#ifndef WIN32 
    1416#include <sys/socket.h> 
    1517#include <sys/signal.h> 
     
    1820#include <netinet/in.h> 
    1921#include <errno.h> 
     22#else /* !WIN32 */ 
     23#include <Winsock2.h> 
     24#endif /* WIN32 */ 
    2025#include <stdlib.h> 
    2126#include <stdio.h>