Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flock with dual processor fails #674

Closed
p5pRT opened this issue Oct 4, 1999 · 2 comments
Closed

flock with dual processor fails #674

p5pRT opened this issue Oct 4, 1999 · 2 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 4, 1999

Migrated from rt.perl.org#1563 (status was 'resolved')

Searchable as RT1563$

@p5pRT
Copy link
Author

p5pRT commented Oct 4, 1999

From noah@sun00710.dn.net

Hi,

I just came across an interesting but. Neither myself, anyone I know, or
the perl clinic can figure this one out.

We have multiple copies of the same program that lock and read the input
from a named pipe (FIFO). This works GREAT with a single processor. When
we try with more than one processor then more than one program can flock
the pipe at the same time creating a real mess. It looks as if perl
internally is using one form of file locking that is not absolute.

below is a summary of the logic used.

use Fcntl '​:flock';
flock(PIPE, LOCK_EX);
while(sysread(PIPE, $ch, 1) != 0 && $ch ne "\n") {
  $line .= $ch;
}
flock(PIPE, LOCK_UN);

Thanks,

-Noah Silverman

Perl Info


Site configuration information for perl 5.00502:

Configured by joshg at Wed May  5 10:45:20 EDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos meow.dn.net 5.6 generic_105181-11 sun4m sparc sunw,sparcstation-20 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=2.8.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00502:
    /usr/local/lib/perl5/5.00502/sun4-solaris
    /usr/local/lib/perl5/5.00502
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00502:
    HOME=/code
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/code/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/etc:/usr/etc:/usr/X/bin:/usr/dt/bin:/usr/ccs/bin:/usr/ucb:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Oct 4, 1999

From [Unknown Contact. See original ticket]

Created by noah@webclipping.com

Hi,

I just came across an interesting but. Neither myself, anyone I know, or
the perl clinic can figure this one out.

We have multiple copies of the same program that lock and read the input
from a named pipe (FIFO). This works GREAT with a single processor. When
we try with more than one processor then more than one program can flock
the pipe at the same time creating a real mess. It looks as if perl
internally is using one form of file locking that is not absolute.

below is a summary of the logic used.

use Fcntl '​:flock';
flock(PIPE, LOCK_EX);
while(sysread(PIPE, $ch, 1) != 0 && $ch ne "\n") {
  $line .= $ch;
}
flock(PIPE, LOCK_UN);

Thanks,

-Noah Silverman

Perl Info


Site configuration information for perl 5.00502:

Configured by joshg at Wed May  5 10:45:20 EDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos meow.dn.net 5.6 generic_105181-11 sun4m sparc sunw,sparcstation-20 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=2.8.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00502:
    /usr/local/lib/perl5/5.00502/sun4-solaris
    /usr/local/lib/perl5/5.00502
    /usr/local/lib/perl5/site_perl/5.005/sun4-solaris
    /usr/local/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00502:
    HOME=/code
    LANG (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/code/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/etc:/usr/etc:/usr/X/bin:/usr/dt/bin:/usr/ccs/bin:/usr/ucb:/usr/local/mysql/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/tcsh


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant