remove recvqueue.[ch]
- put pktlist in gamescanner - let gameparser use this instead of recvqueue
This commit is contained in:
parent
6cd4589640
commit
9e6e2a4d32
2
Makefile
2
Makefile
|
@ -6,7 +6,7 @@ LIBS := -lpthread
|
|||
|
||||
HLSWMASTER_SRC := config.o gameentry.o gamelist.o gameparser.o gamescanner.o \
|
||||
hlswmaster.o hlswserver.o logging.o modhelper.o modulelist.o \
|
||||
multisock.o netpkt.o recvqueue.o socket.o timerservice.o thread.o \
|
||||
multisock.o netpkt.o socket.o timerservice.o thread.o \
|
||||
mod_d3engine.o mod_gamespy1.o mod_gamespy2.o mod_halflife.o \
|
||||
mod_q3engine.o mod_quake2.o mod_ut.o
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "netpkt.h"
|
||||
#include "gameparser.h"
|
||||
|
||||
GameParser::GameParser(RecvQueue& rxQueue, ModuleList& modList, GameList& gameList)
|
||||
: rxQueue(rxQueue), modList(modList), gameList(gameList)
|
||||
GameParser::GameParser(GameScanner& scanner, ModuleList& modList, GameList& gameList)
|
||||
: scanner(scanner), modList(modList), gameList(gameList)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ int GameParser::execute(void* arg)
|
|||
int ret;
|
||||
|
||||
while (1) {
|
||||
pkt = rxQueue.getPkt();
|
||||
pkt = scanner.getPkt();
|
||||
ret = modList.parse(pkt, &gameList);
|
||||
|
||||
switch (ret) {
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include "thread.h"
|
||||
#include "config.h"
|
||||
#include "recvqueue.h"
|
||||
#include "gamescanner.h"
|
||||
#include "modulelist.h"
|
||||
#include "gamelist.h"
|
||||
|
||||
class GameParser : public Thread {
|
||||
public:
|
||||
GameParser(RecvQueue& rxQueue, ModuleList& modlist, GameList& gameList);
|
||||
GameParser(GameScanner& scanner, ModuleList& modlist, GameList& gameList);
|
||||
~GameParser() {};
|
||||
|
||||
int execute(void* arg);
|
||||
|
@ -19,7 +19,7 @@ protected:
|
|||
GameParser& operator=(const GameParser& rp);
|
||||
|
||||
private:
|
||||
RecvQueue& rxQueue;
|
||||
GameScanner& scanner;
|
||||
ModuleList& modList;
|
||||
GameList& gameList;
|
||||
};
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#define DEFAULT_SCAN_INTERVAL 30
|
||||
|
||||
GameScanner::GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue)
|
||||
: modList(modList), rxQueue(rxQueue)
|
||||
GameScanner::GameScanner(Config& conf, ModuleList& modList)
|
||||
: modList(modList)
|
||||
{
|
||||
msock = new MultiSock(conf);
|
||||
|
||||
|
@ -16,6 +16,9 @@ GameScanner::GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue)
|
|||
|
||||
GameScanner::~GameScanner()
|
||||
{
|
||||
while (!pktList.isEmpty())
|
||||
delete pktList.get();
|
||||
|
||||
delete msock;
|
||||
}
|
||||
|
||||
|
@ -23,8 +26,10 @@ int GameScanner::execute(void* arg)
|
|||
{
|
||||
while (1) {
|
||||
NetPkt* pkt = msock->recv();
|
||||
if (pkt)
|
||||
rxQueue.addPkt(pkt);
|
||||
if (pkt != NULL) {
|
||||
pktList.add(pkt);
|
||||
pktCount.post();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -33,3 +38,9 @@ void GameScanner::scan()
|
|||
{
|
||||
modList.scan(msock);
|
||||
}
|
||||
|
||||
NetPkt* GameScanner::getPkt()
|
||||
{
|
||||
pktCount.wait();
|
||||
return pktList.get();
|
||||
}
|
||||
|
|
|
@ -4,19 +4,22 @@
|
|||
#include "thread.h"
|
||||
#include "config.h"
|
||||
#include "modulelist.h"
|
||||
#include "recvqueue.h"
|
||||
|
||||
#include "timerservice.h"
|
||||
#include "multisock.h"
|
||||
#include "semaphore.h"
|
||||
#include "list.h"
|
||||
#include "netpkt.h"
|
||||
|
||||
class GameScanner : public Thread {
|
||||
public:
|
||||
GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue);
|
||||
GameScanner(Config& conf, ModuleList& modList);
|
||||
~GameScanner();
|
||||
|
||||
int execute(void* arg);
|
||||
void scan();
|
||||
|
||||
NetPkt* getPkt();
|
||||
|
||||
protected:
|
||||
GameScanner(const GameScanner& hs);
|
||||
GameScanner& operator=(const GameScanner& hs);
|
||||
|
@ -33,8 +36,10 @@ private:
|
|||
};
|
||||
|
||||
ModuleList& modList;
|
||||
RecvQueue& rxQueue;
|
||||
MultiSock* msock;
|
||||
|
||||
Semaphore pktCount;
|
||||
LockedList<NetPkt> pktList;
|
||||
};
|
||||
|
||||
#endif // _SCANNER_H_
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "logging.h"
|
||||
#include "config.h"
|
||||
#include "recvqueue.h"
|
||||
#include "modulelist.h"
|
||||
#include "gamelist.h"
|
||||
#include "gamescanner.h"
|
||||
|
@ -89,12 +88,11 @@ int main(int argc, char *argv[])
|
|||
LogSystem::log(LOG_EVERYTIME, "hlswmaster-ng %s startup (pid:%d)", VERSION, getpid());
|
||||
conf.show();
|
||||
|
||||
RecvQueue rxQueue;
|
||||
ModuleList modList(conf);
|
||||
GameList gameList(conf);
|
||||
|
||||
GameScanner scanner(conf, modList, rxQueue);
|
||||
GameParser parser(rxQueue, modList, gameList);
|
||||
GameScanner scanner(conf, modList);
|
||||
GameParser parser(scanner, modList, gameList);
|
||||
HlswServer server(conf, gameList);
|
||||
|
||||
modList.reg(new ModD3Engine());
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#include "recvqueue.h"
|
||||
|
||||
RecvQueue::~RecvQueue()
|
||||
{
|
||||
while (!pktList.isEmpty())
|
||||
delete pktList.get();
|
||||
}
|
||||
|
||||
void RecvQueue::addPkt(NetPkt* pkt)
|
||||
{
|
||||
if (pkt != NULL) {
|
||||
pktList.add(pkt);
|
||||
pktCount.post();
|
||||
}
|
||||
}
|
||||
|
||||
NetPkt* RecvQueue::getPkt()
|
||||
{
|
||||
pktCount.wait();
|
||||
return pktList.get();
|
||||
}
|
25
recvqueue.h
25
recvqueue.h
|
@ -1,25 +0,0 @@
|
|||
#ifndef _RECVQUEUE_H_
|
||||
#define _RECVQUEUE_H_
|
||||
|
||||
#include "netpkt.h"
|
||||
#include "semaphore.h"
|
||||
#include "list.h"
|
||||
|
||||
class RecvQueue {
|
||||
public:
|
||||
RecvQueue() {};
|
||||
~RecvQueue();
|
||||
|
||||
void addPkt(NetPkt* pkt);
|
||||
NetPkt* getPkt();
|
||||
|
||||
protected:
|
||||
RecvQueue(const RecvQueue& rq);
|
||||
RecvQueue& operator=(const RecvQueue& rq);
|
||||
|
||||
private:
|
||||
Semaphore pktCount;
|
||||
LockedList<NetPkt> pktList;
|
||||
};
|
||||
|
||||
#endif // _RECVQUEUE_H_
|
Loading…
Reference in New Issue