create symlinks based on _dispatch to dumped requsts
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 28 Oct 2007 19:45:19 +0000 (19:45 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 28 Oct 2007 19:45:19 +0000 (19:45 +0000)
git-svn-id: https://perl-cwmp.googlecode.com/svn/trunk@176 836a5e1a-633d-0410-964b-294494ad4392

lib/CWMP/Session.pm

index fd50a53..f30dc59 100644 (file)
@@ -107,8 +107,10 @@ sub process_request {
 
        warn "<<<< ", $sock->peerhost, " [" . localtime() . "] ", $r->method, " ", $r->uri, " $size bytes\n";
 
+       $dump_nr++;
+       my $file = sprintf("dump/%04d-%s.request", $dump_nr, $sock->peerhost);
+
        if ( $self->debug > 2 ) {
-               my $file = sprintf("dump/%04d-%s.request", $dump_nr++, $sock->peerhost);
                write_file( $file, $r->as_string );
                warn "### request dumped to file: $file\n";
        }
@@ -123,6 +125,11 @@ sub process_request {
 
                $state = CWMP::Request->parse( $xml );
 
+               if ( defined( $state->{_dispatch} ) && $self->debug > 2 ) {
+                       my $type = sprintf("dump/%04d-%s-%s", $dump_nr, $sock->peerhost, $state->{_dispatch});
+                       symlink $file, $type || warn "can't symlink $file -> $type: $!";
+               }
+
                warn "## acquired state = ", dump( $state ), "\n";
 
                $self->state( $state );