time_to_wait-=System.currentTimeMillis() - start_time;
time_to_wait=timeout - (System.currentTimeMillis() - start_time);
    public void down(Event evt) {        Message msg, copy;        PingHeader hdr;        long time_to_wait, start_time;        Vector tmp_mbrs;        Address mbr_addr;        switch(evt.getType()) {        case Event.FIND_INITIAL_MBRS:   // sent by GMS layer, pass up a GET_MBRS_OK event            initial_members.removeAllElements();            if(group_addr == null) {                if(log.isErrorEnabled()) log.error("[FIND_INITIAL_MBRS]: group_addr is null, cannot get mbrship");                passUp(new Event(Event.FIND_INITIAL_MBRS_OK, initial_members));                break;            }            if(log.isTraceEnabled()) log.trace("fetching members from GossipServer(s)");            tmp_mbrs=gossip_client.getMembers(group_addr);            if(tmp_mbrs == null || tmp_mbrs.size() == 0) {                if(log.isErrorEnabled()) log.error("[FIND_INITIAL_MBRS]: gossip client found no members");                passUp(new Event(Event.FIND_INITIAL_MBRS_OK, initial_members));            }            if(log.isTraceEnabled()) log.trace("consolidated mbrs from GossipServer(s) are " + tmp_mbrs);            // 1. 'Mcast' GET_MBRS_REQ message            hdr=new PingHeader(PingHeader.GET_MBRS_REQ, null);            msg=new Message(null, null, null);            msg.putHeader(getName(), hdr);            for(int i=0; i < tmp_mbrs.size(); i++) {                mbr_addr=(IpAddress)tmp_mbrs.elementAt(i);                copy=msg.copy();                copy.setDest(mbr_addr);                if(log.isTraceEnabled()) log.trace("[FIND_INITIAL_MBRS] sending PING request to " + copy.getDest());                passDown(new Event(Event.MSG, copy));            }            // 2. Wait 'timeout' ms or until 'num_initial_members' have been retrieved            synchronized(initial_members) {                start_time=System.currentTimeMillis();                time_to_wait=timeout;                while(initial_members.size() < num_initial_members && time_to_wait > 0) {                    try {                        initial_members.wait(time_to_wait);                    }                    catch(Exception e) {                    }                    time_to_wait-=System.currentTimeMillis() - start_time;                }            }            if(log.isTraceEnabled()) log.trace("[FIND_INITIAL_MBRS] initial members are " + initial_members);            // 3. Send response            passUp(new Event(Event.FIND_INITIAL_MBRS_OK, initial_members));            break;        case Event.TMP_VIEW:        case Event.VIEW_CHANGE:            Vector tmp;            if((tmp=((View)evt.getArg()).getMembers()) != null) {                synchronized(members) {                    members.removeAllElements();                    for(int i=0; i < tmp.size(); i++)                        members.addElement(tmp.elementAt(i));                }            }            passDown(evt);            break;        case Event.BECOME_SERVER: // called after client has joined and is fully working group member            passDown(evt);            is_server=true;            break;        case Event.CONNECT:            group_addr=(String)evt.getArg();            passDown(evt);            break;        case Event.DISCONNECT:            passDown(evt);            break;        default:            passDown(evt);          // Pass on to the layer below us            break;        }    }