error reporting from FIFO commands introduced
authorJiri Kuthan <jiri@iptel.org>
Tue, 3 Sep 2002 02:10:39 +0000 (02:10 +0000)
committerJiri Kuthan <jiri@iptel.org>
Tue, 3 Sep 2002 02:10:39 +0000 (02:10 +0000)
fifo_server.c
fifo_server.h
modules/tm/timer.c
modules/tm/uac.c

index ab95b5d..4b712ea 100644 (file)
@@ -255,6 +255,24 @@ static char *trim_filename( char * file )
        return new_fn;
 }
 
+/* tell FIFO client what happened via reply pipe */
+void fifo_reply( char *reply_fifo, char *reply_txt)
+{
+       FILE *file_handle;
+
+       file_handle=open_reply_pipe(reply_fifo);
+       if (file_handle==0) {
+               LOG(L_ERR, "ERROR: fifo_reply: no reply pipe %s\n",
+                       fifo);
+               return;
+       }
+       if (fprintf(file_handle, "%s", reply_txt)<=0) {
+               LOG(L_ERR, "ERROR: fifo_error: write error (%s): %s\n",
+                       fifo, strerror(errno));
+       }
+       fclose(file_handle);
+}
+
 FILE *open_reply_pipe( char *pipe_name )
 {
        FILE *file_handle;
@@ -346,6 +364,7 @@ static void fifo_server(FILE *fifo_stream)
                if (f->f(fifo_stream, file)<0) {
                        LOG(L_ERR, "ERROR: fifo_server: command (%s) "
                                "processing failed\n", command );
+#ifdef _OBSOLETED
                        file_handle=open_reply_pipe(file);
                        if (file_handle==0) {
                                LOG(L_ERR, "ERROR: fifo_server: no reply pipe\n");
@@ -356,6 +375,7 @@ static void fifo_server(FILE *fifo_stream)
                                strerror(errno));
                        }
                        fclose(file_handle);
+#endif
                        goto consume;
                }
 
@@ -431,9 +451,9 @@ int open_fifo_server()
 
 static int print_version_cmd( FILE *stream, char *response_file )
 {
-       int file;
-
        if (response_file) {
+               fifo_reply(response_file, SERVER_HDR CRLF );
+#ifdef _OBSOLETED
                file=open( response_file, O_WRONLY );
                if (file<0) {
                        LOG(L_ERR, "ERROR: print_version_cmd: open error (%s): %s\n",
@@ -447,6 +467,7 @@ static int print_version_cmd( FILE *stream, char *response_file )
                        return -1;
                }
                close(file);
+#endif
        } else {
                LOG(L_ERR, "ERROR: no file for print_version_cmd\n");
        }
@@ -459,15 +480,24 @@ static int print_fifo_cmd( FILE *stream, char *response_file )
 {
        char text[MAX_PRINT_TEXT];
        int text_len;
-       int file;
        
        /* expect one line which will be printed out */
+       if (response_file==0 || *response_file==0 ) { 
+               LOG(L_ERR, "ERROR: print_fifo_cmd: null file\n");
+               return -1;
+       }
        if (!read_line(text, MAX_PRINT_TEXT, stream, &text_len)) {
+#ifdef _OBSOLETED
                LOG(L_ERR, "ERROR: print_fifo_cmd: too big text\n");
+#endif
+               fifo_reply(response_file, 
+                       "ERROR: print_fifo_cmd: too big text");
                return -1;
        }
        /* now the work begins */
        if (response_file) {
+               fifo_reply(response_file, text );
+#ifdef _OBSOLETED
                file=open( response_file , O_WRONLY);
                if (file<0) {
                        LOG(L_ERR, "ERROR: print_fifo_cmd: open error (%s): %s\n",
@@ -478,9 +508,10 @@ static int print_fifo_cmd( FILE *stream, char *response_file )
                        LOG(L_ERR, "ERROR: print_fifo_cmd: write error: %s\n",
                                 strerror(errno));
                        close(file);
-                       return -1;
+                       return 1;
                }
                close(file);
+#endif
        } else {
                LOG(L_INFO, "INFO: print_fifo_cmd: %.*s\n", 
                        text_len, text );
index aa03e9f..43b5a49 100644 (file)
@@ -42,4 +42,8 @@ int register_core_fifo();
 
 FILE *open_reply_pipe( char *pipe_name );
 
+/* tell FIFO client an error occured via reply pipe */
+void fifo_reply( char *reply_fifo, char *reply_txt);
+
+
 #endif
index ad92688..4ce1812 100644 (file)
@@ -194,7 +194,7 @@ static void delete_cell( struct cell *p_cell, int unlock )
 
 
 
-inline void retransmission_handler( void *attr)
+inline static void retransmission_handler( void *attr)
 {
        struct retr_buf* r_buf ;
        enum lists id;
@@ -234,7 +234,7 @@ inline void retransmission_handler( void *attr)
 
 
 
-inline void final_response_handler( void *attr)
+inline static void final_response_handler( void *attr)
 {
        int silent;
        struct retr_buf* r_buf;
@@ -358,7 +358,7 @@ void cleanup_localcancel_timers( struct cell *t )
 }
 
 
-inline void wait_handler( void *attr)
+inline static void wait_handler( void *attr)
 {
        struct cell *p_cell = (struct cell*)attr;
 
@@ -391,7 +391,7 @@ inline void wait_handler( void *attr)
 
 
 
-inline void delete_handler( void *attr)
+inline static void delete_handler( void *attr)
 {
        struct cell *p_cell = (struct cell*)attr;
 
index 9ec1284..0a40952 100644 (file)
@@ -258,22 +258,30 @@ int fifo_uac( FILE *stream, char *response_file )
                           and proceed to a new request
                        */
                        LOG(L_ERR, "ERROR: fifo_uac: method expected\n");
+                       fifo_reply(response_file, 
+                               "ERROR: fifo_uac: method expected");
                        return -1;
                }
                DBG("DEBUG: fifo_uac: method: %.*s\n", sm.len, method );
                if (!read_line(dst, MAX_DST, stream, &sd.len)||sd.len==0) {
+                       fifo_reply(response_file, 
+                               "ERROR: fifo_uac: destination expected\n");
                        LOG(L_ERR, "ERROR: fifo_uac: destination expected\n");
                        return -1;
                }
                DBG("DEBUG: fifo_uac:  dst: %.*s\n", sd.len, dst );
                /* now read header fields line by line */
                if (!read_line_set(header, MAX_HEADER, stream, &sh.len)) {
+                       fifo_reply(response_file, 
+                               "ERROR: fifo_uac: HFs expected\n");
                        LOG(L_ERR, "ERROR: fifo_uac: header fields expected\n");
                        return -1;
                }
                DBG("DEBUG: fifo_uac: header: %.*s\n", sh.len, header );
                /* and eventually body */
                if (!read_body(body, MAX_BODY, stream, &sb.len)) {
+                       fifo_reply(response_file, 
+                               "ERROR: fifo_uac: body expected\n");
                        LOG(L_ERR, "ERROR: fifo_uac: body expected\n");
                        return -1;
                }