Changeset 693

Show
Ignore:
Timestamp:
02/11/08 04:38:23 (10 months ago)
Author:
dormando
Message:

Seems like -k never worked: it requires privileges to lock the memory,
but they were dropped before the call, and return value was never tested
to see if the call succedded.

Also update -k documentation.
By Tomash Brechko (minor edit by me)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/server/memcached.c

    r667 r693  
    25542554           "-M            return error on memory exhausted (rather than removing items)\n" 
    25552555           "-c <num>      max simultaneous connections, default is 1024\n" 
    2556            "-k            lock down all paged memory\n" 
     2556           "-k            lock down all paged memory.  Note that there is a\n" 
     2557           "              limit on how much memory you may lock.  Trying to\n" 
     2558           "              allocate more than that would fail, so be sure you\n" 
     2559           "              set the limit correctly for the user you started\n" 
     2560           "              the daemon with (not for -u <username> user;\n" 
     2561           "              under sh this is done with 'ulimit -S -l NUM_KB').\n" 
    25572562           "-v            verbose (print errors/warnings while in event loop)\n" 
    25582563           "-vv           very verbose (also print client commands/reponses)\n" 
     
    28612866    } 
    28622867 
     2868    /* lock paged memory if needed */ 
     2869    if (lock_memory) { 
     2870#ifdef HAVE_MLOCKALL 
     2871        int res = mlockall(MCL_CURRENT | MCL_FUTURE); 
     2872        if (res != 0) { 
     2873            fprintf(stderr, "warning: -k invalid, mlockall() failed: %s\n", 
     2874                    strerror(errno)); 
     2875        } 
     2876#else 
     2877        fprintf(stderr, "warning: -k invalid, mlockall() not supported on this platform.  proceeding without.\n"); 
     2878#endif 
     2879    } 
     2880 
    28632881    /* lose root privileges if we have them */ 
    28642882    if (getuid() == 0 || geteuid() == 0) { 
     
    29182936        } 
    29192937        memset(buckets, 0, sizeof(int) * MAX_BUCKETS); 
    2920     } 
    2921  
    2922     /* lock paged memory if needed */ 
    2923     if (lock_memory) { 
    2924 #ifdef HAVE_MLOCKALL 
    2925         mlockall(MCL_CURRENT | MCL_FUTURE); 
    2926 #else 
    2927         fprintf(stderr, "warning: mlockall() not supported on this platform.  proceeding without.\n"); 
    2928 #endif 
    29292938    } 
    29302939