From: Adam Dickmeiss Date: Wed, 17 May 1995 10:51:32 +0000 (+0000) Subject: Added a few more error checks to the show command. X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=6cbe4e189c7fd43512081a6766ab0cb0bf1ed551;p=egate.git Added a few more error checks to the show command. --- diff --git a/kernel/default.res b/kernel/default.res index 956d143..f69b903 100644 --- a/kernel/default.res +++ b/kernel/default.res @@ -1,5 +1,5 @@ # Email gateway - general kernel resources -# $Id: default.res,v 1.21 1995/05/16 09:40:41 adam Exp $ +# $Id: default.res,v 1.22 1995/05/17 10:51:32 adam Exp $ # # Important directories, programs, etc. gw.reply.mta: /usr/lib/sendmail @@ -7,10 +7,10 @@ gw.reply.tmp.prefix: gwr gw.reply.tmp.dir: /tmp #gw.path: /home/adam/egate/kernel gw.marc.log: marc.log -gw.timeout: 20 +gw.timeout: 5 gw.resultset: 1 gw.persist: 1 -gw.max.process: 2 +gw.max.process: 3 # Retrieval settings gw.ignore.which: 1 diff --git a/kernel/lang.uk.res b/kernel/lang.uk.res index be120c6..bf31304 100644 --- a/kernel/lang.uk.res +++ b/kernel/lang.uk.res @@ -1,5 +1,5 @@ # Email gateway - resources for english conversation -# $Id: lang.uk.res,v 1.7 1995/05/04 10:40:07 adam Exp $ +# $Id: lang.uk.res,v 1.8 1995/05/17 10:51:32 adam Exp $ # # Messages gw.msg.subject: Your Z39.50 Query @@ -12,6 +12,8 @@ gw.msg.database: Selected databases gw.msg.records: %d records found in set %s # Error messages +gw.err.bad.show: Syntax error in show. Integer expected +gw.err.pos.show: Start position greater than end position gw.err.search.fail: Search fail. Connection closed gw.err.no.database: You must choose database before issuing a find-query gw.err.no.target: No connection established - command ignored diff --git a/kernel/monitor.c b/kernel/monitor.c index 43249b0..e385ec2 100644 --- a/kernel/monitor.c +++ b/kernel/monitor.c @@ -45,7 +45,10 @@ * Europagate, 1995 * * $Log: monitor.c,v $ - * Revision 1.8 1995/05/16 09:40:42 adam + * Revision 1.9 1995/05/17 10:51:32 adam + * Added a few more error checks to the show command. + * + * Revision 1.8 1995/05/16 09:40:42 adam * LICENSE. Setting of CCL token names (and/or/not/set) in read_kernel_res. * * Revision 1.7 1995/05/03 12:18:46 adam @@ -189,7 +192,7 @@ static void catch_child (int num) for (ki = ke_info_list; ki; ki = ki->next) if (ki->pid == pid) ki->pid = -1; - --no_process; +/* --no_process;*/ } signal (SIGCHLD, catch_child); } @@ -365,7 +368,7 @@ static int deliver (int argc, char **argv, int id, struct str_queue *queue, static void monitor_events (int argc, char **argv) { GIP gip_m; - int r, gip_m_fd; + int r, gip_m_fd, too_many; char line_buf[1024]; fd_set set_r; char command[128], *cp; @@ -403,6 +406,7 @@ static void monitor_events (int argc, char **argv) exit (0); } /* deliver any unsent messages to Email kernels */ + too_many = 0; for (ki = ke_info_list; ki; ki = ki->next) { if (!ki->queue) @@ -414,7 +418,35 @@ static void monitor_events (int argc, char **argv) ++no_process; if (r == 1 || r == 2) /* transfer at all? */ str_queue_rm (&ki->queue); + if (r == 0) /* too many pending? */ + too_many++; + } +#if 0 + if (too_many) + { + gw_log (GW_LOG_DEBUG, module, "%d too many pending", + too_many); + for (ki = ke_info_list; ki; ki = ki->next) + { + if (!ki->queue && ki->pid != -1) + { + if (!(ki->queue = str_queue_mk ())) + { + gw_log (GW_LOG_FATAL|GW_LOG_ERRNO, module, + "str_queue_mk"); + exit (1); + } + str_queue_enq (ki->queue, "stop\n"); + str_queue_enq (ki->queue, "\001"); + gw_log (GW_LOG_DEBUG, module, "Stopping %d", ki->id); + deliver (argc, argv, ki->id, ki->queue, &ki->gip, + &ki->pid, 1); + str_queue_rm (&ki->queue); + break; + } + } } +#endif FD_ZERO (&set_r); FD_SET (gip_m_fd, &set_r); gw_log (GW_LOG_DEBUG, module, "set gip_m_fd %d", gip_m_fd); @@ -431,6 +463,7 @@ static void monitor_events (int argc, char **argv) gipc_close (ki->gip); gipc_destroy (ki->gip); ki->gip = NULL; + --no_process; } else if ((fd = gip_infileno (ki->gip)) != -1) { /* read select on child FIFO */ @@ -475,6 +508,7 @@ static void monitor_events (int argc, char **argv) gipc_close (ki->gip); gipc_destroy (ki->gip); ki->gip = NULL; + --no_process; } } } @@ -555,7 +589,7 @@ int main (int argc, char **argv) signal (SIGHUP, catch_hup); signal (SIGTERM, catch_term); signal (SIGINT, catch_int); -#if 0 +#if 1 gw_log_file (GW_LOG_ALL, "monitor.log"); #endif monitor_events (argc, argv); diff --git a/kernel/urp.c b/kernel/urp.c index 5b73f46..4a23bb8 100644 --- a/kernel/urp.c +++ b/kernel/urp.c @@ -45,7 +45,10 @@ * Europagate, 1995 * * $Log: urp.c,v $ - * Revision 1.35 1995/05/16 09:40:43 adam + * Revision 1.36 1995/05/17 10:51:33 adam + * Added a few more error checks to the show command. + * + * Revision 1.35 1995/05/16 09:40:43 adam * LICENSE. Setting of CCL token names (and/or/not/set) in read_kernel_res. * * Revision 1.34 1995/05/04 10:40:08 adam @@ -695,7 +698,19 @@ static int exec_show (struct ccl_token *list) li = li->next; } else + { + int len = li->len; + memcpy (tmp_str, li->name, len); + tmp_str[len] = '\0'; + if (atoi(tmp_str) <= 0) + { + fprintf (reply_fd, "%s\n", + gw_res_get (info.kernel_res, "gw.err.bad.show", + "Integer expected")); + return -3; + } li = li->next; + } } if (set_token) gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Got set=%.*s", set_token->len, @@ -731,6 +746,15 @@ static int exec_show (struct ccl_token *list) memcpy (tmp_str, li->name, len); tmp_str [len] = '\0'; number = atoi (tmp_str) - offset + 1; + if (number <= 0) + { + fprintf (reply_fd, "%s\n", + gw_res_get (info.kernel_res, + "gw.err.pos.show", + "Starting position " + "greater than ending position")); + return -3; + } } else { @@ -743,7 +767,7 @@ static int exec_show (struct ccl_token *list) } li = li->next; } - else + else if (li->kind == CCL_TOK_TERM) { len = li->len; memcpy (tmp_str, li->name, len); @@ -1103,13 +1127,14 @@ void urp_end (void) mta = gw_res_get (info.kernel_res, "gw.reply.mta", "/usr/lib/sendmail"); sprintf (cmd, "%s %s < %s", mta, info.from_str, info.reply_fname); - +#if 1 mta_code = system (cmd); if (mta_code) gw_log (GW_LOG_FATAL, KERNEL_LOG, "Reply '%s' got exit code %d", cmd, mta_code); else unlink (info.reply_fname); +#endif gw_log (GW_LOG_ACCT, KERNEL_LOG, "User end %s", info.from_str); } }