Discussion:
Filechanges overflow
(too old to reply)
Allan Brehm Clausen
2005-10-28 13:11:49 UTC
Permalink
Maybe this should go in the VFS forum, maybe not.

I'm reading the FileEvents.xlm to check for filechanges. This works
very well, except for one instance.
I'm reading the file events like this (some spaces was removed due to
newsreader problems :-):

$xml=WriteCommand(NSSFILE,"<nssRequest><fileEventList><listFileEvents
epochNumber=\"$epochNumber\"></listFileEvents></fileEventList></nssRequest>");

I'm checking every 1 second, but if more than 4 file changes has
ocurred within that second, then the $XML variable overfloews, and
number 5 gets truncated. How do I split this up to get more
filechanges per read?

Regards
Allan Brehm Clausen


The WriteCommand function looks like this:

sub WriteCommand(*$)
{
my $fh = $_[0];
my $command = $_[1];
my $result;
my $reply;
my $error;

seek $fh, 0, 0;
if (!syswrite($fh, $command, length($command)))
{
$result .= "Unable to send command to virtual file. ";
seek $fh, 0 ,0;
if (sysread($fh, $error, 1000))
{
$result .= $error;
}
$result .= "\n";
}
else
{
seek $fh, 0 ,0;
sysread($fh, $reply, 1000);
$result .= $reply;
}
return $result;
}
David Mair
2005-10-28 14:29:02 UTC
Permalink
It does sound like we should be talking Perl here so I'd saty off the
VFS forum for now. However, I'm not able to answer the question but have
one of my own. Do you have a good reason for polling the event file list
ever second. I'm confident it was never intended for or designed for
that level of activity.
Post by Allan Brehm Clausen
Maybe this should go in the VFS forum, maybe not.
I'm reading the FileEvents.xlm to check for filechanges. This works
very well, except for one instance.
I'm reading the file events like this (some spaces was removed due to
$xml=WriteCommand(NSSFILE,"<nssRequest><fileEventList><listFileEvents
epochNumber=\"$epochNumber\"></listFileEvents></fileEventList></nssRequest>");
I'm checking every 1 second, but if more than 4 file changes has
ocurred within that second, then the $XML variable overfloews, and
number 5 gets truncated. How do I split this up to get more
filechanges per read?
Regards
Allan Brehm Clausen
sub WriteCommand(*$)
{
my $fh = $_[0];
my $command = $_[1];
my $result;
my $reply;
my $error;
seek $fh, 0, 0;
if (!syswrite($fh, $command, length($command)))
{
$result .= "Unable to send command to virtual file. ";
seek $fh, 0 ,0;
if (sysread($fh, $error, 1000))
{
$result .= $error;
}
$result .= "\n";
}
else
{
seek $fh, 0 ,0;
sysread($fh, $reply, 1000);
$result .= $reply;
}
return $result;
}
Allan Brehm Clausen
2005-10-28 19:59:40 UTC
Permalink
Well, I need to know all the files, that have been changed on the
specific volume. If someone moves 100 files over to the volume, over
20 seconds, I have a problem. Not that I need to take action on all
the files (probably 1 or 2).
It seems the result is valid enough, I simply don't have a variable
large enough to contain the result.

Regards
Allan
Post by David Mair
It does sound like we should be talking Perl here so I'd saty off the
VFS forum for now. However, I'm not able to answer the question but have
one of my own. Do you have a good reason for polling the event file list
ever second. I'm confident it was never intended for or designed for
that level of activity.
Post by Allan Brehm Clausen
Maybe this should go in the VFS forum, maybe not.
I'm reading the FileEvents.xlm to check for filechanges. This works
very well, except for one instance.
I'm reading the file events like this (some spaces was removed due to
$xml=WriteCommand(NSSFILE,"<nssRequest><fileEventList><listFileEvents
epochNumber=\"$epochNumber\"></listFileEvents></fileEventList></nssRequest>");
I'm checking every 1 second, but if more than 4 file changes has
ocurred within that second, then the $XML variable overfloews, and
number 5 gets truncated. How do I split this up to get more
filechanges per read?
Regards
Allan Brehm Clausen
sub WriteCommand(*$)
{
my $fh = $_[0];
my $command = $_[1];
my $result;
my $reply;
my $error;
seek $fh, 0, 0;
if (!syswrite($fh, $command, length($command)))
{
$result .= "Unable to send command to virtual file. ";
seek $fh, 0 ,0;
if (sysread($fh, $error, 1000))
{
$result .= $error;
}
$result .= "\n";
}
else
{
seek $fh, 0 ,0;
sysread($fh, $reply, 1000);
$result .= $reply;
}
return $result;
}
Guenter Knauf, DevNet SysOp 32
2005-10-28 20:16:44 UTC
Permalink
Hi Allan,
have you tried to increase the bytes returned?
- sysread($fh, $reply, 1000);
+ sysread($fh, $reply, 10000);

Guenter.
Post by Allan Brehm Clausen
Well, I need to know all the files, that have been changed on the
specific volume. If someone moves 100 files over to the volume, over
20 seconds, I have a problem. Not that I need to take action on all
the files (probably 1 or 2).
It seems the result is valid enough, I simply don't have a variable
large enough to contain the result.
Regards
Allan
Post by David Mair
It does sound like we should be talking Perl here so I'd saty off the
VFS forum for now. However, I'm not able to answer the question but have
one of my own. Do you have a good reason for polling the event file list
ever second. I'm confident it was never intended for or designed for
that level of activity.
Post by Allan Brehm Clausen
Maybe this should go in the VFS forum, maybe not.
I'm reading the FileEvents.xlm to check for filechanges. This works
very well, except for one instance.
I'm reading the file events like this (some spaces was removed due to
$xml=WriteCommand(NSSFILE,"<nssRequest><fileEventList><listFileEvents
epochNumber=\"$epochNumber\"></listFileEvents></fileEventList></nssRequ
est>");
I'm checking every 1 second, but if more than 4 file changes has
ocurred within that second, then the $XML variable overfloews, and
number 5 gets truncated. How do I split this up to get more
filechanges per read?
Regards
Allan Brehm Clausen
sub WriteCommand(*$)
{
my $fh = $_[0];
my $command = $_[1];
my $result;
my $reply;
my $error;
seek $fh, 0, 0;
if (!syswrite($fh, $command, length($command)))
{
$result .= "Unable to send command to virtual file. ";
seek $fh, 0 ,0;
if (sysread($fh, $error, 1000))
{
$result .= $error;
}
$result .= "\n";
}
else
{
seek $fh, 0 ,0;
sysread($fh, $reply, 1000);
$result .= $reply;
}
return $result;
}
Allan Brehm Clausen
2005-10-31 15:07:04 UTC
Permalink
You are absolutely right! There are no limit to the size of Perl
variables (all but RAM, that is), but there is a limit to how blindly
you can copy code off of the VFS manual ;-)

I would point out that the "1000 byte read" as stated in the manual
must be an error - you can't know how many bytes of XML characters
will be returned. The same goes for the error handling routines.

I just read in 10000 bytes at a time, if sysread returns 0, I'm
finished, and my XML variable, will be truncated accordingly.

It actually worked pretty well with a large number of files.

Thanks Guenter.


Regards
Allan Brehm Clausen


On Fri, 28 Oct 2005 20:16:44 GMT, "Guenter Knauf, DevNet SysOp 32"
Post by Guenter Knauf, DevNet SysOp 32
Hi Allan,
have you tried to increase the bytes returned?
- sysread($fh, $reply, 1000);
+ sysread($fh, $reply, 10000);
Guenter.
Post by Allan Brehm Clausen
Well, I need to know all the files, that have been changed on the
specific volume. If someone moves 100 files over to the volume, over
20 seconds, I have a problem. Not that I need to take action on all
the files (probably 1 or 2).
It seems the result is valid enough, I simply don't have a variable
large enough to contain the result.
Regards
Allan
Post by David Mair
It does sound like we should be talking Perl here so I'd saty off the
VFS forum for now. However, I'm not able to answer the question but have
one of my own. Do you have a good reason for polling the event file list
ever second. I'm confident it was never intended for or designed for
that level of activity.
Post by Allan Brehm Clausen
Maybe this should go in the VFS forum, maybe not.
I'm reading the FileEvents.xlm to check for filechanges. This works
very well, except for one instance.
I'm reading the file events like this (some spaces was removed due to
$xml=WriteCommand(NSSFILE,"<nssRequest><fileEventList><listFileEvents
epochNumber=\"$epochNumber\"></listFileEvents></fileEventList></nssRequ
est>");
I'm checking every 1 second, but if more than 4 file changes has
ocurred within that second, then the $XML variable overfloews, and
number 5 gets truncated. How do I split this up to get more
filechanges per read?
Regards
Allan Brehm Clausen
sub WriteCommand(*$)
{
my $fh = $_[0];
my $command = $_[1];
my $result;
my $reply;
my $error;
seek $fh, 0, 0;
if (!syswrite($fh, $command, length($command)))
{
$result .= "Unable to send command to virtual file. ";
seek $fh, 0 ,0;
if (sysread($fh, $error, 1000))
{
$result .= $error;
}
$result .= "\n";
}
else
{
seek $fh, 0 ,0;
sysread($fh, $reply, 1000);
$result .= $reply;
}
return $result;
}
Loading...