Commit 5f84433f authored by 's avatar
Browse files

SHM spinlock is now locked/unlocked only when SHM is used


git-svn-id: file:///home/svn/mapi/trunk@623 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent faaf4303
......@@ -18,6 +18,7 @@
#include "debug.h"
#include "printfstring.h"
#include "mapi_errors.h"
#include "../trackflib/trackflib.h"
//Stores information about flows in mapidlib
typedef struct mapidlibflow {
......@@ -1026,6 +1027,10 @@ void mapid_process_pkt(mapidlib_instance_t *i,
n = flist_head(i->flowlist);
#endif
// a color var to help trackers from continunsly searching application
// strings
color = 0;
while (n)
{
flow=flist_data(n);
......@@ -1045,7 +1050,9 @@ void mapid_process_pkt(mapidlib_instance_t *i,
if(funct->ref==1)
ret=funct->instance->ret;
else {
pthread_spin_lock(i->shm_spinlock);
if(funct->instance->def->restype == MAPIRES_SHM) {
pthread_spin_lock(i->shm_spinlock);
}
#ifdef WITH_MODIFY_PKTS
if(flow->modifies==1)
ret=funct->instance->def->process(funct->instance,dev_pkt,flow->mod_pkt,&flow->mod_pkt_head);
......@@ -1054,7 +1061,9 @@ void mapid_process_pkt(mapidlib_instance_t *i,
#else
ret=funct->instance->def->process(funct->instance,dev_pkt,link_pkt,pkt_head);
#endif
pthread_spin_unlock(i->shm_spinlock);
if(funct->instance->def->restype == MAPIRES_SHM) {
pthread_spin_unlock(i->shm_spinlock);
}
#ifdef WITH_FUNCT_STATS
funct->instance->pkts++;
if(ret)
......
......@@ -63,36 +63,11 @@ int isDc(mapidflib_function_instance_t *instance, unsigned char *pkt, unsigned i
char *dc_strings[STRING_NUM]={"$MyNick","$Lock EXTENDEDPROTOCOL" ,"$Sending", "$Direction Download ","$Direction Upload ","$Supports", "$GetNickList|",
"$ValidateNick", "$ConnectToMe","$HubName","$Hello","$MyINFO $ALL","$GetINFO","$Search Hub:","$OpList"};
/* Backup Strings
* "$Key",
* "$Get",
* "$Send|",
* "$ValidateDenide",
* "$GetPass",
* "$MyPass",
* "$LogedIn",
* "$BadPass",
* "$GetListLen",
* "$ListLen",
* "$MaxedOut",
* "$Error",
* "$FileLength",
* "$Canceled",
* "$SR",
* "$Ping",
* "$Version",
* "$NickList",
* "$MultiConnectToMe",
* "$RevConnectToMe",
* "$To:",
* "$Quit",
* "$OpForceMove $Who:",
* "$ForceMove",
* "$Kick",
* "$Search",
* "$Up",
* "$UpToo"
* };
* "$Key","$Get","$Send|","$ValidateDenide", "$GetPass", "$MyPass", "$LogedIn", "$BadPass", "$GetListLen", "$ListLen", "$MaxedOut", "$Error",
* "$FileLength", "$Canceled", "$SR","$Ping", "$Version", "$NickList", "$MultiConnectToMe", "$RevConnectToMe", "$To:", "$Quit","$OpForceMove $Who:",
* "$ForceMove","$Kick", "$Search", "$Up", "$UpToo"
*/
int dc_string_len[STRING_NUM] = {0};
//char *dc_strings[2]={"|$Lock EXTENDEDPROTOCOLABCABCABCABCABCABC Pk=DCPLUSPLUS", "|$Direction Download"};
......@@ -181,6 +156,9 @@ static int dc_process(mapidflib_function_instance_t *instance,
unsigned int hashval = 0;
int i = 0;
if(color != 0 && color != DC_COLOR) {
return 0;
}
p = pkt;
// lay the Ethernet header struct over the packet data
......
......@@ -296,6 +296,10 @@ static int edonkey_process(mapidflib_function_instance_t *instance,
unsigned int hashval = 0;
if(color != 0 && color != EDONKEY_COLOR) {
return 0;
}
p = pkt;
// lay the Ethernet header struct over the packet data
......
......@@ -142,7 +142,10 @@ static int gnutella_process(mapidflib_function_instance_t *instance,
unsigned int hashval = 0;
int i = 0;
if(color != 0 && color != GNUTELLA_COLOR) {
return 0;
}
p = pkt;
// lay the Ethernet header struct over the packet data
......
......@@ -154,7 +154,11 @@ static int torrent_process(mapidflib_function_instance_t *instance,
int i = 0;
int ether_len =0 , ip_len = 0, tcp_len = 0, udp_len = 0;
if(color != 0 && color != TORRENT_COLOR) {
return 0;
}
p = pkt;
// lay the Ethernet header struct over the packet data
......
......@@ -3,6 +3,15 @@
#define ETHERTYPE_8021Q 0x8100
#define EDONKEY_COLOR 1
#define TORRENT_COLOR 2
#define GNUTELLA_COLOR 3
#define DC_COLOR 4
#define FTP_COLOR 5
static int color;
struct vlan_802q_header {
u_int16_t priority_cfi_vid;
u_int16_t ether_type;
......
......@@ -110,7 +110,10 @@ static int trackftp_process(mapidflib_function_instance_t *instance,
uint16_t sp, dp;
unsigned int hashval = 0;
if(color != 0 && color != FTP_COLOR) {
return 0;
}
p = pkt;
// lay the Ethernet header struct over the packet data
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment