Ignore:
Timestamp:
2018-11-08T17:22:04+13:00 (5 years ago)
Author:
ak19
Message:
  1. Some tidying up of the code. 2. Removing unnecessary calls to force_disconnect_from_db (now made 'private') after die() since on die() perl calls object destructor which will ensure disconnection anyway.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugouts/GreenstoneSQLPlugout.pm

    r32582 r32583  
    3939
    4040
    41 # This entire class is called only during import.pl
    42 
    43 # TODO: SIGTERM rollback and disconnect?
    44 # TODO Q: what about verbosity for debugging, instead of current situation of printing out upon debug set at the expense of writing to db
     41# + TODO: SIGTERM rollback and disconnect?
     42# + TODO Q: what about verbosity for debugging, instead of current situation of printing out upon debug set at the expense of writing to db
    4543# TODO Q: introduced site_name param to plugins and plugouts. Did I do it right? And should they have hiddengli = "yes"
    4644# Did I do the pass by ref in docprint's escape and unescape textref functions correctly, and how they're called here?
     
    121119        'args'     => $arguments };
    122120
     121##### This entire class is called only during import.pl #####
     122
     123##### Overridden methods #####
     124
    123125sub new {
    124126    my ($class) = shift (@_);
     
    205207    # This is fatal for the plugout, let's terminate here after disconnecting again
    206208    # PrintError would already have displayed the warning message on load fail
    207     $gs_sql->force_disconnect_from_db(); # disconnect_from_db() will issue a warning on error
     209    # And on die() perl will call gssql destroy which will ensure a disconnect() from db
     210    #$gs_sql->force_disconnect_from_db(); # disconnect_from_db() will issue a warning on error
    208211    die("Could not use db $db_name and/or prepare its tables. Can't proceed.\n");
    209212    }
     
    227230    # do the superclass stuff first, as any sql db failures should not prevent superclass cleanup
    228231    $self->SUPER::end(@_);   
    229    
    230     $self->{'gs_sql'}->finished(); # will disconnect from db if last instance
     232
     233    # Important to call finished():
     234    # it will disconnect from db if this is the last gssql instance,
     235    # and it will commit to db before disconnecting if rollbback_on_cancel turned on
     236    $self->{'gs_sql'}->finished();
    231237    delete $self->{'gs_sql'}; # key gs_sql no longer exists, not just the value being undef
    232238}
     
    295301
    296302   
    297     # 3. post save out
    298     #$self->SUPER::post_saveas(@_);
     303    # 3. post save out
    299304    $self->SUPER::post_saveas($doc_obj, $doc_dir, $docxml_outhandler, $output_file);
    300305   
     
    304309}
    305310
     311##### New methods, not inherited  #####
    306312
    307313# write meta and/or text PER DOC out to DB
Note: See TracChangeset for help on using the changeset viewer.