Changeset 376

Show
Ignore:
Timestamp:
08/27/08 15:40:36 (10 years ago)
Author:
cseifert
Message:

remove deadlock

Location:
capture-hpc/trunk/capture-server/capture
Files:
3 modified

Legend:

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

    r369 r376  
    163163            if (visitingUrlGroup != null) { 
    164164                if (!visitingUrlGroup.isMalicious()) { 
    165                     visitingUrlGroup.setMalicious("dac",false,null); //sets underlying url malicious, which will cause error to be written clientSocketOutput down the line. 
     165                    visitingUrlGroup.setMalicious("dac", false, null); //sets underlying url malicious, which will cause error to be written clientSocketOutput down the line. 
    166166                } 
    167167                visitingUrlGroup.setMajorErrorCode(ERROR_CODES.CAPTURE_CLIENT_CONNECTION_RESET.errorCode); 
     
    201201                    System.out.println(virtualMachine.getLogHeader() + " - WARNING: Couldnt parse state change."); 
    202202                } 
    203            } else if (algorithm.equals("dac") && visitingUrlGroup.size() > 1) { 
    204                 visitingUrlGroup.setMalicious("dac",true,null); 
     203            } else if (algorithm.equals("dac") && visitingUrlGroup.size() > 1) { 
     204                visitingUrlGroup.setMalicious("dac", true, null); 
    205205                //if we are visiting a group, we can reset right now, 
    206206                // because we will revisit URLs later to get more detail info about state changes 
     
    208208 
    209209                visitingUrlGroup.writeEventToLog("\"" + type + "\",\"" + time + 
    210                     "\",\"" + process + "\",\"" + action + "\",\"" + object1 + "\",\"" + 
    211                     object2 + "\""); 
     210                        "\",\"" + process + "\",\"" + action + "\",\"" + object1 + "\",\"" + 
     211                        object2 + "\""); 
    212212                visitingUrlGroup.setVisitFinishTime(element.attributes.get("time")); 
    213213 
     
    222222                this.setClientState(CLIENT_STATE.DISCONNECTED); 
    223223            } else { //must be seq or group size of 1 
    224                 visitingUrlGroup.setMalicious(algorithm,true,null); 
     224                visitingUrlGroup.setMalicious(algorithm, true, null); 
    225225                System.out.println(this.getVirtualMachine().getLogHeader() + " Visited group " + visitingUrlGroup.getIdentifier() + " MALICIOUS"); 
    226226                visitingUrlGroup.writeEventToLog("\"" + type + "\",\"" + time + 
    227                     "\",\"" + process + "\",\"" + action + "\",\"" + object1 + "\",\"" + 
    228                     object2 + "\""); 
     227                        "\",\"" + process + "\",\"" + action + "\",\"" + object1 + "\",\"" + 
     228                        object2 + "\""); 
    229229            } 
    230230 
     
    289289            if (visitingUrlGroup.isMalicious() || malicious.equals("1")) { 
    290290                System.out.println(this.getVirtualMachine().getLogHeader() + " Visited group " + visitingUrlGroup.getIdentifier() + " MALICIOUS"); 
    291                 if(visitingUrlGroup.size()>1 && algorithm.equals("bulk")) { 
    292                     if(!stateChangeHandler.getRemainderStateChangesCSV(processIds).equals("")) { 
     291                if (visitingUrlGroup.size() > 1 && algorithm.equals("bulk")) { 
     292                    if (!stateChangeHandler.getRemainderStateChangesCSV(processIds).equals("")) { 
    293293                        System.out.println(this.getVirtualMachine().getLogHeader() + " Visited group " + visitingUrlGroup.getIdentifier() + " WARNING: No state changes were logged to url log file."); 
    294294                    } 
     
    296296                } 
    297297 
    298                 visitingUrlGroup.setMalicious(algorithm,true,urlStateChangesMap); 
     298                visitingUrlGroup.setMalicious(algorithm, true, urlStateChangesMap); 
    299299                visitingUrlGroup.setUrlGroupState(URL_GROUP_STATE.VISITED);  //will set underlying url state 
    300300                visitingUrlGroup = null; 
     
    302302            } else { 
    303303                System.out.println(this.getVirtualMachine().getLogHeader() + " Visited group " + visitingUrlGroup.getIdentifier() + " BENIGN"); 
    304                 visitingUrlGroup.setMalicious(algorithm,false,urlStateChangesMap); 
     304                visitingUrlGroup.setMalicious(algorithm, false, urlStateChangesMap); 
    305305                visitingUrlGroup.setUrlGroupState(URL_GROUP_STATE.VISITED);  //will set underlying url state 
    306306                visitingUrlGroup = null; 
     
    339339                String malicious = element.attributes.get("malicious"); 
    340340                if (malicious.equals("1")) { 
    341                     if(visitingUrlGroup.size()>1 && algorithm.equals("bulk")) { 
    342                         if(!stateChangeHandler.getRemainderStateChangesCSV(processIds).equals("")) { 
     341                    if (visitingUrlGroup.size() > 1 && algorithm.equals("bulk")) { 
     342                        if (!stateChangeHandler.getRemainderStateChangesCSV(processIds).equals("")) { 
    343343                            System.out.println(this.getVirtualMachine().getLogHeader() + " Visited group " + visitingUrlGroup.getIdentifier() + " WARNING: No state changes were logged to url log file."); 
    344344                        } 
     
    346346                    } 
    347347 
    348                     visitingUrlGroup.setMalicious(algorithm,true,urlStateChangesMap); 
     348                    visitingUrlGroup.setMalicious(algorithm, true, urlStateChangesMap); 
    349349                } else { 
    350                     visitingUrlGroup.setMalicious(algorithm,false,urlStateChangesMap); 
     350                    visitingUrlGroup.setMalicious(algorithm, false, urlStateChangesMap); 
    351351                } 
    352352                visitingUrlGroup.setMajorErrorCode(Long.parseLong(major)); 
     
    360360                if (malicious.equals("1")) { 
    361361                    flushStateChangeHandler(urlStateChangesMap); 
    362                     visitingUrlGroup.setMalicious(algorithm,true,urlStateChangesMap); 
     362                    visitingUrlGroup.setMalicious(algorithm, true, urlStateChangesMap); 
    363363                    visitingUrlGroup.setUrlGroupState(URL_GROUP_STATE.VISITED);   //will set underlying url state 
    364364                    System.out.println(this.getVirtualMachine().getLogHeader() + " MALICIOUS " + visitingUrlGroup.getIdentifier()); 
     
    366366                    this.setClientState(CLIENT_STATE.DISCONNECTED); 
    367367                } else { 
    368                     visitingUrlGroup.setMalicious(algorithm,false,urlStateChangesMap); 
     368                    visitingUrlGroup.setMalicious(algorithm, false, urlStateChangesMap); 
    369369                    visitingUrlGroup.setUrlGroupState(URL_GROUP_STATE.VISITED);   //will set underlying url state and not cause reset vm 
    370370                    System.out.println(this.getVirtualMachine().getLogHeader() + " BENIGN " + visitingUrlGroup.getIdentifier()); 
     
    399399        if (clientState == CLIENT_STATE.WAITING) { 
    400400            virtualMachine.setState(VM_STATE.RUNNING); 
    401             synchronized (urlRetriever) { 
    402                 urlRetriever.notifyAll(); 
    403             } 
     401            urlRetriever.notifyAll(); 
    404402        } else if (clientState == CLIENT_STATE.DISCONNECTED) { 
    405403            this.disconnect(); 
    406             synchronized (urlRetriever) { 
    407                 urlRetriever.notifyAll(); //in order to let urlRetriever thread stop 
    408             } 
     404            urlRetriever.notifyAll(); //in order to let urlRetriever thread stop 
    409405        } else if (clientState == CLIENT_STATE.CONNECTED) { 
    410406            send("<option name=\"capture-network-packets-malicious\" value=\"" + 
     
    458454 
    459455    public void run() { 
    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                 } 
     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); 
    470464            } 
    471465        } 
  • capture-hpc/trunk/capture-server/capture/ClientsController.java

    r340 r376  
    1717                exclusionLists = new HashMap<String, ExclusionList>(); 
    1818                EventsController.getInstance().addEventObserver("exclusion-list", this); 
    19                 Timer clientsPingerTask = new Timer(true); 
     19                Timer clientsPingerTask = new Timer("ClientsPinger",true); 
    2020                clientsPingerTask.schedule(clientsPinger, 0, 10000); 
    2121                Thread t = new Thread(this, "ClientController"); 
  • capture-hpc/trunk/capture-server/capture/VirtualMachineServerController.java

    r320 r376  
    1616                vmServerFactory = new VirtualMachineServerFactory(); 
    1717                virtualMachinesStateChecker = new VirtualMachinesStateChecker(virtualMachineServers); 
    18                 Timer vmStateChecker = new Timer(); 
     18        Timer vmStateChecker = new Timer("vmStateChecker"); 
    1919                vmStateChecker.scheduleAtFixedRate(virtualMachinesStateChecker,0,1000); 
    2020                EventsController.getInstance().addEventObserver("virtual-machine-server", this);