Operating System - HP-UX
1820390 Members
3565 Online
109623 Solutions
New Discussion юеВ

flock() failing in 2+0 environment

 
Harikrishna Parlapalli_2
Occasional Contributor

flock() failing in 2+0 environment

I'm using flock() in one of my perl scripts. It is working fine in the HP-UX 1+0 environment. But hanging in the 2+0 environment. I'm creating the lock on a file where the directory is mounted on both the systems. If I create the file in the local directory (eg: /tmp) and use the script that is working fine. We are suspecting this as some NFS problem. When we restarted the cluster, then the flock is working fine in 2+0. Can anybody suggest what could be the problem and what to do in case of the hanging situation instead of cluster restart.
2 REPLIES 2
Mark Grant
Honored Contributor

Re: flock() failing in 2+0 environment

In the perl manual, I think it says something like "flock is unlikely to work on a network filesystem".

NFS is not really easy to lock files on. I think you are going to have to implement locking yourself.
Never preceed any demonstration with anything more predictive than "watch this"
vasundhara
Frequent Advisor

Re: flock() failing in 2+0 environment

Hi,

NFS may cause the problem. Restarting nfs will solve your problem.

Instead of restarting entire cluster, you can stop and start only NFS.

Followin commands may help.
/sbin/init.d/nfs.client stop
/sbin/init.d/nfs.client start

Regards
VJ.