Changeset 1154 in svn for trunk/xcache/xc_lock.c


Ignore:
Timestamp:
2012-10-18T07:49:35Z (3 years ago)
Author:
Xuefer
Message:

avoid using rand() without seed. use getpid

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache/xc_lock.c

    r1027 r1154  
    8888
    8989    if (pathname == NULL) {
    90         static int i = 0;
     90        static int instanceId = 0;
    9191        const char default_tmpdir[] = { DEFAULT_SLASH, 't', 'm', 'p', '\0' };
    9292        const char *tmpdir;
     
    101101        size = strlen(tmpdir) + sizeof("/.xcache.lock") - 1 + 3 * 10 + 100;
    102102        myname = malloc(size);
    103         snprintf(myname, size - 1, "%s%c.xcache.%d.%d.%d.lock", tmpdir, DEFAULT_SLASH, (int) getuid(), i ++, rand());
     103        snprintf(myname, size - 1, "%s%c.xcache.%d.%d.%d.lock", tmpdir, DEFAULT_SLASH, (int) getuid(), (int) getpid(), ++instanceId);
    104104        pathname = myname;
    105105    }
Note: See TracChangeset for help on using the changeset viewer.