Revision: 33548 http://brlcad.svn.sourceforge.net/brlcad/?rev=33548&view=rev Author: bob1961 Date: 2009-01-14 16:43:04 +0000 (Wed, 14 Jan 2009)
Log Message: ----------- Add code to prevent interrupts during database writes. Modified Paths: -------------- brlcad/trunk/src/libged/inside.c brlcad/trunk/src/libged/typein.c Modified: brlcad/trunk/src/libged/inside.c =================================================================== --- brlcad/trunk/src/libged/inside.c 2009-01-14 16:27:58 UTC (rev 33547) +++ brlcad/trunk/src/libged/inside.c 2009-01-14 16:43:04 UTC (rev 33548) @@ -27,6 +27,7 @@ #include "bio.h" #include <stdlib.h> +#include <signal.h> #include <ctype.h> #include <math.h> #include <string.h> @@ -917,6 +918,7 @@ char *newname; int arg = 1; static const char *usage = "out_prim in_prim th(s)"; + void (*cur_sigint)(); GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); GED_CHECK_READ_ONLY(gedp, BRLCAD_ERROR); @@ -1171,16 +1173,28 @@ return BRLCAD_ERROR; } + /* don't allow interrupts while we update the database! */ + cur_sigint = signal(SIGINT, SIG_IGN); + /* Add to in-core directory */ if ( (dp = db_diradd( gedp->ged_wdbp->dbip, newname, -1, 0, DIR_SOLID, (genptr_t)&intern.idb_type )) == DIR_NULL ) { + /* restore the handler before returning */ + (void)signal(SIGINT, cur_sigint); + bu_vls_printf(&gedp->ged_result_str, "%s: Database alloc error, aborting\n", argv[0]); return BRLCAD_ERROR; } if ( rt_db_put_internal( dp, gedp->ged_wdbp->dbip, &intern, &rt_uniresource ) < 0 ) { + /* restore the handler before returning */ + (void)signal(SIGINT, cur_sigint); + bu_vls_printf(&gedp->ged_result_str, "%s: Database write error, aborting\n", argv[0]); return BRLCAD_ERROR; } + /* restore the handler before returning */ + (void)signal(SIGINT, cur_sigint); + return BRLCAD_OK; } Modified: brlcad/trunk/src/libged/typein.c =================================================================== --- brlcad/trunk/src/libged/typein.c 2009-01-14 16:27:58 UTC (rev 33547) +++ brlcad/trunk/src/libged/typein.c 2009-01-14 16:43:04 UTC (rev 33548) @@ -28,6 +28,7 @@ #include "bio.h" #include <stdlib.h> +#include <signal.h> #include <ctype.h> #include <string.h> @@ -2694,6 +2695,7 @@ struct rt_db_internal internal; char **menu; int nvals, (*fn_in)(); + void (*cur_sigint)(); GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); GED_CHECK_READ_ONLY(gedp, BRLCAD_ERROR); @@ -2987,17 +2989,29 @@ do_new_update: /* The function may have already written via LIBWDB */ if ( internal.idb_ptr != NULL ) { + /* don't allow interrupts while we update the database! */ + cur_sigint = signal(SIGINT, SIG_IGN); + if ( (dp=db_diradd( gedp->ged_wdbp->dbip, name, -1L, 0, DIR_SOLID, (genptr_t)&internal.idb_type)) == DIR_NULL ) { + /* restore the handler before returning */ + (void)signal(SIGINT, cur_sigint); + rt_db_free_internal( &internal, &rt_uniresource ); bu_vls_printf(&gedp->ged_result_str, "%s: Cannot add '%s' to directory\n", argv[0], name); return BRLCAD_ERROR; } if ( rt_db_put_internal( dp, gedp->ged_wdbp->dbip, &internal, &rt_uniresource ) < 0 ) { + /* restore the handler before returning */ + (void)signal(SIGINT, cur_sigint); + rt_db_free_internal( &internal, &rt_uniresource ); bu_vls_printf(&gedp->ged_result_str, "%s: Database write error, aborting\n", argv[0]); return BRLCAD_ERROR; } + + /* restore the handler before returning */ + (void)signal(SIGINT, cur_sigint); } return BRLCAD_OK; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits