packets/packet_cache.c File Reference

#include "packet_cache.h"
#include "packet.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

Go to the source code of this file.

Defines

#define DEBUGLOCKS

Functions

int InitCache ()
unsigned short HashKey (char *Key, int KeyLen)
void FreeSaved (int SaveID)
void FreeSaveQuery (SaveQuery *q)
void TimeoutSavedPackets (long CurTime)
int GetFreeSaved ()
int SavePacket (int PacketSlot, char *Key, int KeyLen, int Timeout)
SaveQueryGetAndLockSavedPackets (char *Key, int KeyLen)
void UnlockSavedQuery (SaveQuery *q)

Variables

pthread_mutex_t SavedMutex
int SaveLockID
SaveRec Saves [MAX_SAVES]
SaveBin SBins [65536]
int SaveTimeHead
int SaveTimeTail
GlobalVars Globals


Define Documentation

#define DEBUGLOCKS

Definition at line 17 of file packet_cache.c.


Function Documentation

void FreeSaved ( int  SaveID  ) 

Definition at line 65 of file packet_cache.c.

References FALSE, Globals, HashKey(), hlbr_mutex_unlock(), save_rec::InUse, save_rec::Key, save_rec::KeyLen, packet_rec::Mutex, save_rec::NextTime, NULL, save_bin::NumInBin, global_vars::Packets, save_rec::PacketSlot, save_rec::PrevTime, ReturnEmptyPacket(), packet_rec::SaveCount, global_vars::SavedCount, Saves, SaveTimeHead, SaveTimeTail, and SBins.

Referenced by FreeSaveQuery(), and TimeoutSavedPackets().

void FreeSaveQuery ( SaveQuery q  ) 

Definition at line 123 of file packet_cache.c.

References FREE_SAVED_1, FreeSaved(), hlbr_mutex_lock(), hlbr_mutex_unlock(), save_query::NumResults, SavedMutex, SaveLockID, and save_query::Saves.

SaveQuery* GetAndLockSavedPackets ( char *  Key,
int  KeyLen 
)

Definition at line 260 of file packet_cache.c.

References DEBUG, GET_SAVED_1, GET_SAVED_2, GET_SAVED_3, Globals, HashKey(), hlbr_mutex_lock(), hlbr_mutex_unlock(), save_bin::Items, save_rec::Key, save_rec::KeyLen, save_rec::LockID, packet_rec::LockID, MAX_QUERY_RESULTS, save_rec::Mutex, packet_rec::Mutex, save_bin::NumInBin, save_query::NumResults, global_vars::Packets, save_query::Packets, save_rec::PacketSlot, SavedMutex, SaveLockID, Saves, save_query::Saves, and SBins.

int GetFreeSaved (  ) 

Definition at line 183 of file packet_cache.c.

References MAX_SAVES, and Saves.

Referenced by SavePacket().

unsigned short HashKey ( char *  Key,
int  KeyLen 
)

Definition at line 39 of file packet_cache.c.

Referenced by FreeSaved(), GetAndLockSavedPackets(), and SavePacket().

int InitCache (  ) 

Definition at line 24 of file packet_cache.c.

References MAX_SAVES, Saves, SBins, and TRUE.

int SavePacket ( int  PacketSlot,
char *  Key,
int  KeyLen,
int  Timeout 
)

Definition at line 198 of file packet_cache.c.

References FALSE, GetFreeSaved(), Globals, HashKey(), hlbr_mutex_lock(), hlbr_mutex_unlock(), save_rec::InUse, save_bin::Items, save_rec::Key, save_rec::KeyLen, packet_rec::LockID, MAX_SAVES_PER_BIN, packet_rec::Mutex, save_rec::NextTime, save_bin::NumInBin, global_vars::Packets, save_rec::PacketSlot, SAVE_PACKET_1, SAVE_PACKET_2, packet_rec::SaveCount, SavedMutex, SaveLockID, Saves, SaveTimeHead, SaveTimeTail, SBins, save_rec::Timeout, TimeoutSavedPackets(), TRUE, and packet_rec::tv.

void TimeoutSavedPackets ( long  CurTime  ) 

Definition at line 148 of file packet_cache.c.

References FreeSaved(), Globals, hlbr_mutex_lock(), hlbr_mutex_unlock(), global_vars::SavedCount, Saves, SaveTimeHead, and TIMEOUT_SAVED_1.

Referenced by SavePacket().

void UnlockSavedQuery ( SaveQuery q  ) 

Definition at line 314 of file packet_cache.c.

References Globals, hlbr_mutex_lock(), hlbr_mutex_unlock(), packet_rec::Mutex, save_rec::Mutex, save_query::NumResults, global_vars::Packets, save_rec::PacketSlot, SavedMutex, SaveLockID, Saves, save_query::Saves, and UNLOCK_SAVED_1.


Variable Documentation

GlobalVars Globals

Definition at line 41 of file hlbr.c.

pthread_mutex_t SavedMutex

Definition at line 8 of file packet_cache.c.

Referenced by FreeSaveQuery(), GetAndLockSavedPackets(), SavePacket(), and UnlockSavedQuery().

int SaveLockID

Definition at line 9 of file packet_cache.c.

Referenced by FreeSaveQuery(), GetAndLockSavedPackets(), SavePacket(), and UnlockSavedQuery().

SaveRec Saves[MAX_SAVES]

Definition at line 10 of file packet_cache.c.

Referenced by FreeSaved(), GetAndLockSavedPackets(), GetFreeSaved(), InitCache(), SavePacket(), TimeoutSavedPackets(), and UnlockSavedQuery().

int SaveTimeHead

Definition at line 13 of file packet_cache.c.

Referenced by FreeSaved(), SavePacket(), and TimeoutSavedPackets().

int SaveTimeTail

Definition at line 14 of file packet_cache.c.

Referenced by FreeSaved(), and SavePacket().

SaveBin SBins[65536]

Definition at line 11 of file packet_cache.c.

Referenced by FreeSaved(), GetAndLockSavedPackets(), InitCache(), and SavePacket().


Generated on Sat Jul 7 23:33:11 2007 for HLBR by  doxygen 1.5.2