added list of current searches to avoid receiving duplicate results
git-svn-id: svn://anubis/gvsu@58 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
5ced7328ae
commit
0e63ffa48b
@ -9,11 +9,13 @@ public class KaZaServer implements Runnable
|
|||||||
private ServerSocket m_serverSocket;
|
private ServerSocket m_serverSocket;
|
||||||
private HashMap<String, ClientInfo> m_clientData;
|
private HashMap<String, ClientInfo> m_clientData;
|
||||||
private Vector<Socket> m_peerGroupLeaders;
|
private Vector<Socket> m_peerGroupLeaders;
|
||||||
|
private HashMap<String, Integer> m_currentSearches;
|
||||||
|
|
||||||
public KaZaServer()
|
public KaZaServer()
|
||||||
{
|
{
|
||||||
m_clientData = new HashMap<String, ClientInfo>();
|
m_clientData = new HashMap<String, ClientInfo>();
|
||||||
m_peerGroupLeaders = new Vector<Socket>();
|
m_peerGroupLeaders = new Vector<Socket>();
|
||||||
|
m_currentSearches = new HashMap<String, Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
@ -195,6 +197,14 @@ public class KaZaServer implements Runnable
|
|||||||
{
|
{
|
||||||
String results = "";
|
String results = "";
|
||||||
String querylc = query.toLowerCase();
|
String querylc = query.toLowerCase();
|
||||||
|
|
||||||
|
synchronized (m_currentSearches)
|
||||||
|
{
|
||||||
|
if (m_currentSearches.containsKey(querylc))
|
||||||
|
return results;
|
||||||
|
m_currentSearches.put(querylc, 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (depth > 0)
|
if (depth > 0)
|
||||||
{
|
{
|
||||||
synchronized (m_peerGroupLeaders)
|
synchronized (m_peerGroupLeaders)
|
||||||
@ -241,6 +251,12 @@ public class KaZaServer implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized (m_currentSearches)
|
||||||
|
{
|
||||||
|
m_currentSearches.remove(querylc);
|
||||||
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user