Changeset 31125

Show
Ignore:
Timestamp:
18.11.2016 13:32:02 (3 years ago)
Author:
ak19
Message:

Experimental fix for concurrent access issue when using document editor to modify metadata. Need to commit now in order to test on other win machine where the race condition manifests in the binary. That Win machine doesn't have Vis Studio for compiling, and compiling just the core (Java) is insufficient as the tomcat won't even start after that perhaps because other parts were no compiled up.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java

    r31124 r31125  
    318318        } 
    319319 
     320         
    320321        // wait until we can reserve the collection for processing 
    321322        waitUntilReady(request);     
    322323         
    323         // process 
     324        logger.error("@@@ RESERVED"); 
     325         
     326        // process 
    324327        Element response = runCommand(request, GS2PerlConstructor.MODIFY_METADATA_SERVER); 
     328         
     329        if (response.getElementsByTagName(GSXML.ERROR_ELEM).getLength() <= 0) // if no errors, wait for process to finish 
     330        { 
     331            logger.error("@@@ NO ERRORS"); 
     332             
     333            Element statusElem = (Element) response.getElementsByTagName(GSXML.STATUS_ELEM).item(0); 
     334            String id = statusElem.getAttribute("pid"); 
     335            logger.error("@@@ GOT PID: " + id); 
     336             
     337            GS2PerlListener currentListener = this.listeners.get(id); 
     338            int statusCode = currentListener.getStatus(); 
     339            while (!GSStatus.isCompleted(statusCode)) 
     340            { 
     341                // wait for the process, and keep checking the status code 
     342                // there is probably a better way to do this. 
     343                try 
     344                { 
     345                    logger.error("@@@ WAITING"); 
     346                    Thread.currentThread().sleep(100); 
     347                } 
     348                catch (Exception e) 
     349                { // ignore 
     350                } 
     351                statusCode = currentListener.getStatus(); 
     352            }        
     353        } 
     354         
     355        else { 
     356            logger.error("@@@ GOT ERROR");           
     357        } 
     358         
     359        logger.error("@@@ RELEASING HOLD"); 
    325360         
    326361        // release hold on collection 
    327362        signalReady(request); 
    328363        return response; 
     364         
    329365    } 
    330366