Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Not being a C hacker, I'm not sure what the template for pack() in my fcntl() call should look like, since I don't see anything in the pod about off_t or pid_t. I've just been assuming that that off_t could be a long and pid_t an int, like so:struct flock { ... short l_type; /* Type of lock: F_RDLCK, F_WRLCK, F_UNLCK */ short l_whence; /* How to interpret l_start: SEEK_SET, SEEK_CUR, SEEK_END */ off_t l_start; /* Starting offset for lock */ off_t l_len; /* Number of bytes to lock */ pid_t l_pid; /* PID of process blocking our lock (F_GETLK only) */ ... };
A co-worker suggested I also try:fcntl(FILEHANDLE, F_SETLKW, pack("sslli", F_WRLCK, SEEK_SET, 0, 0, 0)) +;
I'm not even sure what the bangs do exactly, but this didn't seem to help any. Am I creating the packed buffer correctly? If so, is there anything that can be done to help the performance? 18 seconds is way, way too slow.fcntl(FILEHANDLE, F_SETLKW, pack("s!s!l!l!i!", F_WRLCK, SEEK_SET, 0, 0 +, 0));
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pack and off_t for fcntl()?
by doowah2004 (Monk) on Sep 20, 2004 at 13:37 UTC | |
|
Re: Pack and off_t for fcntl()?
by waswas-fng (Curate) on Sep 20, 2004 at 14:59 UTC | |
by Anonymous Monk on Sep 20, 2004 at 17:31 UTC |