Changeset 378

Show
Ignore:
Timestamp:
08/27/08 15:55:44 (9 years ago)
Author:
cseifert
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • capture-hpc/trunk/capture-server/capture/Client.java

    r376 r378  
    399399        if (clientState == CLIENT_STATE.WAITING) { 
    400400            virtualMachine.setState(VM_STATE.RUNNING); 
    401             urlRetriever.notifyAll(); 
     401            synchronized (urlRetriever) { 
     402                urlRetriever.notifyAll(); 
     403            } 
    402404        } else if (clientState == CLIENT_STATE.DISCONNECTED) { 
    403405            this.disconnect(); 
    404             urlRetriever.notifyAll(); //in order to let urlRetriever thread stop 
     406            synchronized (urlRetriever) { 
     407                urlRetriever.notifyAll(); //in order to let urlRetriever thread stop 
     408            } 
    405409        } else if (clientState == CLIENT_STATE.CONNECTED) { 
    406410            send("<option name=\"capture-network-packets-malicious\" value=\"" + 
     
    445449            this.visitingUrlGroup.setUrlGroupState(URL_GROUP_STATE.ERROR); 
    446450        } else { 
    447             setClientState(CLIENT_STATE.AWAITING_VISITING); 
     451            clientState = CLIENT_STATE.AWAITING_VISITING; //dont change to set function call - could cause deadlock 
    448452        } 
    449453    } 
     
    454458 
    455459    public void run() { 
    456         while (clientState != CLIENT_STATE.DISCONNECTED) { 
    457             try { 
    458                 if (clientState == CLIENT_STATE.WAITING) { 
    459                     this.setVisitingUrlGroup(UrlGroupsController.getInstance().takeUrlGroup()); 
    460                 } 
    461                 urlRetriever.wait(); 
    462             } catch (InterruptedException e) { 
    463                 e.printStackTrace(System.out); 
     460        synchronized (urlRetriever) { 
     461            while (clientState != CLIENT_STATE.DISCONNECTED) { 
     462                try { 
     463                    if (clientState == CLIENT_STATE.WAITING) { 
     464                        this.setVisitingUrlGroup(UrlGroupsController.getInstance().takeUrlGroup()); 
     465                    } 
     466                    urlRetriever.wait(); 
     467                } catch (InterruptedException e) { 
     468                    e.printStackTrace(System.out); 
     469                } 
    464470            } 
    465471        }