semget fails when there a semaphore with semid 0
martinkoehler opened this issue · comments
I ran in the same bug as Siarhei Kuchynski:
The following code in line 64 of Log::Log4perl::Util::Semaphore should fix this:
64 defined($self->{id} = semget( $self->{ikey}, 1, 0 ))
He observes:
"When a semaphore with specified key (0x6f6e616e) and semid = 0 already
exists, semget fails for this semaphore:
bash-4.0# ipcs -s
Verberge zitierten Text
------ Semaphore Arrays --------
key semid owner perms nsems
0x6f6e616e 0 root 777 1
with the following error message
semget(1869504878) failed: at
/usr/share/perl5/vendor_perl//Log/Log4perl/Util/Semaphore.pm line 64.
This is caused by line 64 of Log::Log4perl::Util::Semaphore.pm
63 print "Semaphore '$self->{key}' already exists\n" if INTERNAL_DEBUG;
64 $self->{id} = semget( $self->{ikey}, 1, 0 )
65 or die "semget(
semget returns ID 0 for the key 1869504878 and dies, though 0 should be
considered to be valid ID
According to http://perldoc.perl.org/functions/semget.html:
semget KEY,NSEMS,FLAGS
Calls the System V IPC function semget(2). Returns the semaphore id, or the
undefined value on error.
It seems that init method should call die only if semget returns undefined
value, not zero.
"
Thanks so much for pinpointing this, Martin, should be fixed now!
5e4b1b3
Dear Mike,
Thanks. I can confirm that this is fixed now