View | Details | Raw Unified | Return to bug 171134
Collapse All | Expand All

(-)storage/buffindexed/shmem.c (-5 / +9 lines)
Lines 26-32 Link Here
26
static int smcGetSemaphore(const char *name)
26
static int smcGetSemaphore(const char *name)
27
{
27
{
28
    key_t kt = ftok( (char *)name, 0 );
28
    key_t kt = ftok( (char *)name, 0 );
29
    int   id = semget(kt, 0, S_IRWXU|S_IRWXG|S_IRWXO);
29
    int   perm = SEM_R | SEM_A | (SEM_R>>3) | (SEM_A>>3) |
30
	    (SEM_R>>6) | (SEM_A>>6);
31
    int   id = semget(kt, 0, perm);
30
32
31
    if (id < 0) {
33
    if (id < 0) {
32
        syswarn("semget failed to get semaphore for %s", name);
34
        syswarn("semget failed to get semaphore for %s", name);
Lines 37-51 Link Here
37
static int smcCreateSemaphore(const char *name)
39
static int smcCreateSemaphore(const char *name)
38
{
40
{
39
    key_t kt = ftok( (char *)name, 0 );
41
    key_t kt = ftok( (char *)name, 0 );
40
    int   id = semget(kt, 2, IPC_CREAT|S_IRWXU|S_IRWXG|S_IRWXO);
42
    int   perm = SEM_R | SEM_A | (SEM_R>>3) | (SEM_A>>3) |
43
	    (SEM_R>>6) | (SEM_A>>6);
44
    int   id = semget(kt, 2, IPC_CREAT|perm);
41
45
42
    if (id < 0) {
46
    if (id < 0) {
43
        if (errno == EACCES || errno == EINVAL) {
47
        if (errno == EACCES || errno == EINVAL) {
44
            /* looks like a wrong semaphore exists. remove it. */
48
            /* looks like a wrong semaphore exists. remove it. */
45
            id = semget(kt, 0, S_IRWXU|S_IRWXG|S_IRWXO);
49
            id = semget(kt, 0, perm);
46
            if (id < 0) {
50
            if (id < 0) {
47
                /* couldn't even retrieve it. */
51
                /* couldn't even retrieve it. */
48
                syswarn("cant get semaphore using %s", name);
52
                syswarn("cant get semaphore using %s (key=%d)", name, kt);
49
                return id;
53
                return id;
50
            }
54
            }
51
            /* try to remove it */
55
            /* try to remove it */
Lines 65-71 Link Here
65
            }
69
            }
66
#endif
70
#endif
67
            /* and retry creating it */
71
            /* and retry creating it */
68
            id = semget(kt, 2, IPC_CREAT|S_IRWXU|S_IRWXG|S_IRWXO);
72
            id = semget(kt, 2, IPC_CREAT|perm);
69
        }
73
        }
70
    }
74
    }
71
    if (id < 0)
75
    if (id < 0)

Return to bug 171134