[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] A nuisance in Vend::Util.pm?
****** message to minivend-users from Mike Heins <mikeh@minivend.com> ******
Quoting Sergio Polini (s.polini@mclink.it):
>
> Perhaps I'm missing something, since I'm new to Minivend.
> My problem was that I could not stop it; both -stop and -kill gave me the same
> message about a file that could not be locked. I've found a workaround, but it
> is very dirty :-)
>
> I've installed Minivend 4.04 on my Linux (RedHat 6.2) as sp:users and always run
> it as sp:users (I'm just studying for now...). My Linux is "localized" as
> italian: here is the problem, as far as I can guess.
>
> The message I was getting was:
>
> Could not lock file: Risorsa temporaneamente non disponibile
>
> i.e., "Resourse temporarily unavailable" in italian...
>
> In Vend::Util.pm, subroutine flock_lock, I read:
>
> if (! flock($fh, $flag | $flock_LOCK_NB)) {
> if ($! =~ m/^Try again/
> or $! =~ m/^Resource temporarily unavailable/
> or $! =~ m/^Operation would block/) {
> return 0;
> }
> else {
> die "Could not lock file: $! ($errno)\n";
> }
> }
>
> The error code is checked againt its english description!
> I tried:
>
> else {
> my $errno = $! + 1000;
> die "Could not lock file: $! ($errno)\n";
> }
>
> so I was able to patch the if branch:
>
> if ($! =~ m/^Try again/
> or $! =~ m/^Resource temporarily unavailable/
> or $! == 11 # :-(
> or $! =~ m/^Operation would block/) {
> return 0;
> }
>
> Stop and kill work well now, but I'm not proud for my hack :-)
>
> Any better ideas?
>
You can just use stop with signals:
kill `cat /usr/local/minivend/etc/minivend.pid`
I should look at internationalizing more of these types of error
messages. I have been pretty religious about using the errmsg()
routine when appropriate, but there is probably quite a bit still
in the low level stuff that has not been done. I think the methodology
is like you described, by error number, but that isn't too portable.
I think there are constants like EAGAIN defined in POSIX; yup,
use POSIX qw(:errno_h); will do it. Then the code would
simply become:
if ($! == EAGAIN) {
return 0;
}
--
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>
I have a cop friend who thinks he ought be able to give a new ticket;
"too dumb for conditions".
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list