00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef alarm_handler_h
00027 #define alarm_handler_h
00028
00029 #include <stdio.h>
00030
00031 #include <string>
00032
00033 #include "EventHandler.h"
00034
00042 class AlarmHandler : public EventHandler
00043 {
00044 private:
00045 FILE *d_file;
00046 ostream &d_stream;
00047 string d_version;
00048
00049
00050 AlarmHandler() : d_file( 0 ), d_stream( cout )
00051 {}
00052
00053 public:
00056 AlarmHandler(FILE *s) : d_file(s), d_stream( cout )
00057 {}
00058
00059 AlarmHandler(ostream &out) : d_file(0), d_stream( out )
00060 {}
00061
00062 virtual ~AlarmHandler()
00063 {
00064 if( d_file )
00065 fclose( d_file ) ;
00066 }
00067
00080 virtual void handle_signal(int signum)
00081 {
00082 if (signum != SIGALRM)
00083 fprintf(stderr, "SIGALRM handler caught another signal!\n");
00084 #if 0
00085
00086 if( d_file )
00087 fprintf(d_file, "\n\n\n\n");
00088 else
00089 d_stream << "\n\n\n\n";
00090
00091 Error e("The server has timed out. This happens when a request\n\
00092 takes longer to process than the server's preset time-out value.\n\
00093 Try making a request for a smaller amount of data. You can also contact\n\
00094 the server's administrator and request that the time-out value be increased.");
00095
00096 if( d_file )
00097 e.print(d_file);
00098 else
00099 e.print(d_stream);
00100 #endif
00101 exit(1);
00102 }
00103
00104 };
00105
00106 #endif