Index: trunk/pstamp/scripts/pstamp_queue_requests.pl
===================================================================
--- trunk/pstamp/scripts/pstamp_queue_requests.pl	(revision 18623)
+++ trunk/pstamp/scripts/pstamp_queue_requests.pl	(revision 19265)
@@ -22,5 +22,5 @@
     'verbose'       =>  \$verbose,
     'dbname=s'      =>  \$dbname,
-    'limit=s'       =>  \$limit,
+    'limit=i'       =>  \$limit,
 );
 
@@ -119,6 +119,4 @@
         my $out_buf = join("", @$stdout_buf);
         # split raw output into lines
-        # XXX: why do I think that i need the map?
-        #my @lines = map {split "\n"} $raw_output;
         @lines = split /^/, $out_buf;
     }
@@ -127,11 +125,15 @@
     # each line contains a fileset
     #
-    # XXX: we probably should set a limit on the number of these we process
-    # otherwise this could take a long time and the task could time out
+
+    # number that we've processed
+    my $numFilesets = 0;
     foreach my $line (@lines) {
         # parse the line into fields split by whitespace
         my ($uri, $fs_name, $date, $type) = split " ", $line;
 
+        # skip comment lines
         next if ( $uri =~ /^#.*/);
+
+        $numFilesets++;
 
         my @files;
@@ -163,18 +165,21 @@
                 my $command = "$pstamptool -addreq -uri $req_uri -ds_id $ds_id";
                 $command .= " -dbname $dbname" if $dbname;
+
                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
                         run(command => $command, verbose => $verbose);
-                    unless ($success) {
-                        # XXX: what do we do now?
-                        die("Unable to perform $command: $error_code");
-                    }
+
+                unless ($success) {
+                    die("Unable to perform $command: $error_code");
+                }
             }
-            $lastFileset = $fs_name;
         }
+        $lastFileset = $fs_name;
+        last if ($numFilesets >= $limit);
     }
 
     ## now update the last_fileset column in pstampDataStore
-    ## XXX: we should probably do this before we process the fileset. Otherwise 
-    ## if we get an error from pstamptool we'll get stuck processing it over and over.
+    ## XXX: we should perhaps do this while processing each fileset so that if a later
+    ## one has an error we don't get repeats.
+
     if ($lastFileset) {
         # print "last fileset: $lastFileset\n";
