Files
privacore-open-source-searc…/Msge1.h

90 lines
2.4 KiB
C
Raw Normal View History

2013-08-02 13:12:24 -07:00
// Gigablast Inc., copyright November 2007
2016-03-08 22:14:30 +01:00
#ifndef GB_MSGE1_H
#define GB_MSGE1_H
2013-08-02 13:12:24 -07:00
2016-03-08 22:14:30 +01:00
#define MAX_OUTSTANDING_MSGE1 20
2013-08-02 13:12:24 -07:00
#include "MsgC.h"
#include "Linkdb.h"
#include "GbMutex.h"
2013-08-02 13:12:24 -07:00
class Msge1 {
public:
Msge1();
~Msge1();
void reset();
// . this gets the ip from "firstip" tag in "grv" array of TagRecs
// if it is there. otherwise, it will do an ip lookup.
// . this will also consult the stored files on disk if this is the
// "test" collection to avoid any dns lookups whatsoever, unless
// that file is not present
// . the purpose of this is to just get "firstips" for XmlDoc
// to set the SpiderRequest::m_firstIp member which is used to
// determine which hostId is exclusively responsible for
// doling/throttling these urls/requests out to other hosts to
// spider them. see Spider.h/.cpp for more info
bool getFirstIps ( class TagRec **grv ,
2017-03-14 17:25:07 +01:00
const char **urlPtrs,
const linkflags_t *urlFlags,
2014-11-10 14:45:11 -08:00
int32_t numUrls ,
int32_t niceness ,
2013-08-02 13:12:24 -07:00
void *state ,
void (*callback)(void *state) ,
2017-03-14 18:27:17 +01:00
int32_t nowGlobal);
2013-08-02 13:12:24 -07:00
2016-11-17 12:21:13 +01:00
int32_t getErrno() const { return m_errno; }
2016-11-17 12:17:58 +01:00
int32_t **getIpBufPtr() { return &m_ipBuf; } //xdmlDoc needs this ptr-ptr
private:
static void gotMsgCWrapper(void *state, int32_t ip);
2017-03-14 18:07:49 +01:00
bool launchRequests(int32_t starti);
bool sendMsgC(int32_t slotIndex, const char *host, int32_t hlen);
2017-03-14 18:19:36 +01:00
void doneSending(int32_t slotIndex);
void doneSending_unlocked(int32_t slotIndex);
2017-03-14 18:07:49 +01:00
bool addTag(int32_t slotIndex);
bool doneAddingTag(int32_t slotIndex);
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_niceness ;
2013-08-02 13:12:24 -07:00
2017-03-14 17:25:07 +01:00
const char **m_urlPtrs;
const linkflags_t *m_urlFlags;
2014-11-10 14:45:11 -08:00
int32_t m_numUrls;
2013-08-02 13:12:24 -07:00
bool m_addTags;
// buffer to hold all the data we accumulate for all the urls in urlBuf
char *m_buf;
2014-11-10 14:45:11 -08:00
int32_t m_bufSize;
2013-08-02 13:12:24 -07:00
// sub-buffers of the great "m_buf", where we store the data for eacu
// url that we get in urlBuf
2014-11-10 14:45:11 -08:00
int32_t *m_ipBuf;
int32_t *m_ipErrors;
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_numRequests;
int32_t m_numReplies;
int32_t m_n;
GbMutex m_mtx;
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_ns [ MAX_OUTSTANDING_MSGE1 ];
bool m_used [ MAX_OUTSTANDING_MSGE1 ];
2013-08-02 13:12:24 -07:00
MsgC m_msgCs [ MAX_OUTSTANDING_MSGE1 ]; // ips
// vector of TagRec ptrs
TagRec **m_grv;
void *m_state;
void (*m_callback)(void *state);
2014-11-10 14:45:11 -08:00
int32_t m_nowGlobal;
2013-08-02 13:12:24 -07:00
// for errors
2014-11-10 14:45:11 -08:00
int32_t m_errno;
2013-08-02 13:12:24 -07:00
};
2016-03-08 22:14:30 +01:00
#endif // GB_MSGE1_H