test script for rotating IL files
authorAleš Křenek <ljocha@ics.muni.cz>
Tue, 7 Apr 2009 15:30:50 +0000 (15:30 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Tue, 7 Apr 2009 15:30:50 +0000 (15:30 +0000)
org.glite.lb.client/examples/test_notif_rotate.pl [new file with mode: 0755]

diff --git a/org.glite.lb.client/examples/test_notif_rotate.pl b/org.glite.lb.client/examples/test_notif_rotate.pl
new file mode 100755 (executable)
index 0000000..8514c7c
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+use Socket;
+use Fcntl;
+
+$notif = $ENV{NOTIFY_CMD} ? $ENV{NOTIFY_CMD} : './notify';
+
+$notifid = shift or die "usage: $0 notifid\n";
+
+socket SOCK,PF_INET,SOCK_STREAM,getprotobyname('tcp')  || die "socket: $!\n";
+bind SOCK,sockaddr_in(0,INADDR_ANY)                    || die "bind: $!\n";
+listen SOCK,10;
+
+$fd = fileno SOCK;
+
+$flags = fcntl SOCK,F_GETFD,0;
+fcntl SOCK,F_SETFD,$flags & ~FD_CLOEXEC;
+
+
+$cmd = "$notif bind -s $fd $notifid"; 
+
+system $cmd;
+
+die "failed $cmd\n" if $? == 1;
+$ret = $? >> 8;
+die "$cmd: $ret\n" if $ret;
+
+print "Bind ok. Press Enter ... "; <>;
+
+$fdin = '';
+vec($fdin,$fd,1) = 1;
+
+while (1) {
+       select($fdin,undef,undef,undef);
+       print "got connection\n";
+
+       $cmd = "$notif receive -s $fd -i 3";
+       system $cmd;
+       die "failed $cmd\n" if $? == 1;
+       $ret = $? >> 8;
+       die "$cmd: $ret\n" if $ret;
+
+#      print "Receive OK. Press Enter ..."; <>;
+}
+
+