• R/O
  • HTTP
  • SSH
  • HTTPS

PeerCastIM: Commit


Commit MetaInfo

Revision62695e1a2c94c9dbf6be2fbfd60656b5726cac52 (tree)
Time2007-12-26 02:45:02
Authoreru <eru01@user...>
Commitereru

Log Message

生命キャスト対策コード(VPdiff20071223)マージ。

Change Summary

Incremental Difference

--- a/PeerCast.root/PeerCast/core/common/channel.cpp
+++ b/PeerCast.root/PeerCast/core/common/channel.cpp
@@ -537,6 +537,7 @@ int Channel::handshakeFetch()
537537 sock->writeLineF("GET /channel/%s HTTP/1.0",idStr);
538538 sock->writeLineF("%s %d",PCX_HS_POS,streamPos);
539539 sock->writeLineF("%s %d",PCX_HS_PCP,1);
540+ sock->writeLineF("%s %d",PCX_HS_PORT,servMgr->serverHost.port);
540541
541542 sock->writeLine("");
542543
@@ -1475,8 +1476,11 @@ bool ChannelStream::getStatus(Channel *ch,ChanPacket &pack)
14751476 // -----------------------------------
14761477 bool Channel::checkBump()
14771478 {
1479+ unsigned int maxIdleTime = 30;
1480+ if (isIndexTxt(this)) maxIdleTime = 60;
1481+
14781482 if (!isBroadcasting() && (!sourceHost.tracker))
1479- if (rawData.lastWriteTime && ((sys->getTime() - rawData.lastWriteTime) > 30))
1483+ if (rawData.lastWriteTime && ((sys->getTime() - rawData.lastWriteTime) > maxIdleTime))
14801484 {
14811485 LOG_ERROR("Channel Auto bumped");
14821486 bump = true;
@@ -1509,6 +1513,9 @@ int Channel::readStream(Stream &in,ChannelStream *source)
15091513
15101514 unsigned int receiveStartTime = 0;
15111515
1516+ unsigned int ptime = 0;
1517+ unsigned int upsize = 0;
1518+
15121519 try
15131520 {
15141521 while (thread.active && !peercastInst->isQuitting)
@@ -1573,7 +1580,14 @@ int Channel::readStream(Stream &in,ChannelStream *source)
15731580 }
15741581 }
15751582
1576- source->flush(in);
1583+ unsigned int t = sys->getTime();
1584+ if (t != ptime) {
1585+ ptime = t;
1586+ upsize = Servent::MAX_OUTWARD_SIZE;
1587+ }
1588+
1589+ unsigned int len = source->flushUb(in, upsize);
1590+ upsize -= len;
15771591
15781592 sys->sleepIdle();
15791593 }
@@ -1733,9 +1747,12 @@ void ChanPacket::init(ChanPacketv &p)
17331747 {
17341748 type = p.type;
17351749 len = p.len;
1750+ if (len > MAX_DATALEN)
1751+ throw StreamException("Packet data too large");
17361752 pos = p.pos;
17371753 sync = p.sync;
17381754 skip = p.skip;
1755+ priority = p.priority;
17391756 memcpy(data, p.data, len);
17401757 }
17411758 // -----------------------------------
@@ -1748,6 +1765,7 @@ void ChanPacket::init(TYPE t, const void *p, unsigned int l,unsigned int _pos)
17481765 memcpy(data,p,len);
17491766 pos = _pos;
17501767 skip = false;
1768+ priority = 0;
17511769 }
17521770 // -----------------------------------
17531771 void ChanPacket::writeRaw(Stream &out)
@@ -1970,10 +1988,34 @@ void ChanPacketBuffer::readPacket(ChanPacket &pack)
19701988 pack.init(packets[readPos%MAX_PACKETS]);
19711989 readPos++;
19721990 lock.off();
1991+}
19731992
1974- sys->sleepIdle();
1993+// -----------------------------------
1994+void ChanPacketBuffer::readPacketPri(ChanPacket &pack)
1995+{
1996+ unsigned int tim = sys->getTime();
1997+
1998+ if (readPos < firstPos)
1999+ throw StreamException("Read too far behind");
2000+
2001+ while (readPos >= writePos)
2002+ {
2003+ sys->sleepIdle();
2004+ if ((sys->getTime() - tim) > 30)
2005+ throw TimeoutException();
2006+ }
2007+ lock.on();
2008+ ChanPacketv *best = &packets[readPos % MAX_PACKETS];
2009+ for (unsigned int i = readPos + 1; i < writePos; i++) {
2010+ if (packets[i % MAX_PACKETS].priority > best->priority)
2011+ best = &packets[i % MAX_PACKETS];
2012+ }
2013+ pack.init(*best);
2014+ best->init(packets[readPos % MAX_PACKETS]);
2015+ readPos++;
2016+ lock.off();
2017+ }
19752018
1976-}
19772019 // -----------------------------------
19782020 bool ChanPacketBuffer::willSkip()
19792021 {
@@ -2898,6 +2940,35 @@ ChanHit *ChanMgr::addHit(ChanHit &h)
28982940 }
28992941
29002942 // -----------------------------------
2943+bool ChanMgr::findParentHit(ChanHit &p)
2944+{
2945+ ChanHitList *hl=NULL;
2946+
2947+ chanMgr->hitlistlock.on();
2948+
2949+ hl = findHitListByID(p.chanID);
2950+
2951+ if (hl)
2952+ {
2953+ ChanHit *ch = hl->hit;
2954+ while (ch)
2955+ {
2956+ if (!ch->dead && (ch->rhost[0].ip == p.uphost.ip)
2957+ && (ch->rhost[0].port == p.uphost.port))
2958+ {
2959+ chanMgr->hitlistlock.off();
2960+ return 1;
2961+ }
2962+ ch = ch->next;
2963+ }
2964+ }
2965+
2966+ chanMgr->hitlistlock.off();
2967+
2968+ return 0;
2969+}
2970+
2971+// -----------------------------------
29012972 class ChanFindInfo : public ThreadInfo
29022973 {
29032974 public:
@@ -3064,6 +3135,7 @@ void ChanHit::init()
30643135 version_ex_number = 0;
30653136
30663137 status = 0;
3138+ servent_id = 0;
30673139
30683140 sessionID.clear();
30693141 chanID.clear();
@@ -4503,6 +4575,22 @@ int ChanHitSearch::getRelayHost(Host host1, Host host2, GnuID exID, ChanHitList
45034575 riSequence &= 0xffffff;
45044576 seqLock.off();
45054577
4578+ Servent *s = servMgr->servents;
4579+ while (s) {
4580+ if (s->serventHit.rhost[0].port && s->type == Servent::T_RELAY
4581+ && s->chanID.isSame(chl->info.id)) {
4582+ int i = index % MAX_RESULTS;
4583+ if (index < MAX_RESULTS
4584+ || tmpHit[i].lastSendSeq > s->serventHit.lastSendSeq) {
4585+ s->serventHit.lastSendSeq = seq;
4586+ tmpHit[i] = s->serventHit;
4587+ tmpHit[i].host = s->serventHit.rhost[0];
4588+ index++;
4589+ }
4590+ }
4591+ s = s->next;
4592+ }
4593+
45064594 ChanHit *hit = chl->hit;
45074595
45084596 while(hit){
@@ -4534,6 +4622,7 @@ int ChanHitSearch::getRelayHost(Host host1, Host host2, GnuID exID, ChanHitList
45344622 //rnd = (float)rand() / (float)RAND_MAX;
45354623 rnd = rand() % base;
45364624 if (hit->numHops == 1){
4625+#if 0
45374626 if (tmpHit[index % MAX_RESULTS].numHops == 1){
45384627 if (rnd < prob){
45394628 tmpHit[index % MAX_RESULTS] = *hit;
@@ -4545,8 +4634,9 @@ int ChanHitSearch::getRelayHost(Host host1, Host host2, GnuID exID, ChanHitList
45454634 tmpHit[index % MAX_RESULTS].host = hit->rhost[0];
45464635 index++;
45474636 }
4637+#endif
45484638 } else {
4549- if ((tmpHit[index % MAX_RESULTS].numHops != 1) && (rnd < prob)){
4639+ if ((tmpHit[index % MAX_RESULTS].numHops != 1) && (rnd < prob) || rnd == 0){
45504640 tmpHit[index % MAX_RESULTS] = *hit;
45514641 tmpHit[index % MAX_RESULTS].host = hit->rhost[0];
45524642 index++;
--- a/PeerCast.root/PeerCast/core/common/channel.h
+++ b/PeerCast.root/PeerCast/core/common/channel.h
@@ -207,6 +207,8 @@ public:
207207
208208 char version_ex_prefix[2];
209209 unsigned int version_ex_number;
210+
211+ unsigned int lastSendSeq;
210212 };
211213 // ----------------------------------
212214 class ChanHitList
@@ -603,7 +605,7 @@ public:
603605
604606 int pickHits(ChanHitSearch &);
605607
606-
608+ bool findParentHit(ChanHit &p);
607609
608610 Channel *channel;
609611 ChanHitList *hitlist;
--- a/PeerCast.root/PeerCast/core/common/cstream.h
+++ b/PeerCast.root/PeerCast/core/common/cstream.h
@@ -58,6 +58,7 @@ public:
5858 pos = 0;
5959 sync = 0;
6060 skip = false;
61+ priority = 0;
6162 }
6263 void init(ChanPacketv &p);
6364 void init(TYPE t, const void *, unsigned int , unsigned int );
@@ -74,6 +75,7 @@ public:
7475 char data[MAX_DATALEN];
7576 bool skip;
7677
78+ int priority;
7779 };
7880 // ----------------------------------
7981 class ChanPacketv
@@ -111,6 +113,7 @@ public:
111113 skip = false;
112114 data = NULL;
113115 datasize = 0;
116+ priority = 0;
114117 }
115118 void init(ChanPacket &p)
116119 {
@@ -124,6 +127,7 @@ public:
124127 pos = p.pos;
125128 sync = p.sync;
126129 skip = p.skip;
130+ priority = p.priority;
127131 if (!data) {
128132 datasize = (len & ~(BSIZE - 1)) + BSIZE;
129133 data = new char[datasize];
@@ -149,6 +153,7 @@ public:
149153 unsigned int datasize;
150154 bool skip;
151155
156+ int priority;
152157 };
153158 // ----------------------------------
154159 class ChanPacketBuffer
@@ -176,6 +181,7 @@ public:
176181
177182 bool writePacket(ChanPacket &,bool = false);
178183 void readPacket(ChanPacket &);
184+ void readPacketPri(ChanPacket &);
179185
180186 bool willSkip();
181187
@@ -221,6 +227,7 @@ public:
221227 virtual void kill() {}
222228 virtual bool sendPacket(ChanPacket &,GnuID &) {return false;}
223229 virtual void flush(Stream &) {}
230+ virtual unsigned int flushUb(Stream &, unsigned int) { return 0; }
224231 virtual void readHeader(Stream &,Channel *)=0;
225232 virtual int readPacket(Stream &,Channel *)=0;
226233 virtual void readEnd(Stream &,Channel *)=0;
--- a/PeerCast.root/PeerCast/core/common/pcp.cpp
+++ b/PeerCast.root/PeerCast/core/common/pcp.cpp
@@ -84,6 +84,30 @@ void PCPStream::flush(Stream &in)
8484 pack.writeRaw(in);
8585 }
8686 }
87+
88+// ------------------------------------------
89+unsigned int PCPStream::flushUb(Stream &in, unsigned int size)
90+{
91+ ChanPacket pack;
92+ unsigned int len = 0, skip = 0;
93+
94+ while (outData.numPending())
95+ {
96+ outData.readPacketPri(pack);
97+
98+ if (size >= len + pack.len) {
99+ len += pack.len;
100+ pack.writeRaw(in);
101+ } else {
102+ skip++;
103+ }
104+ }
105+ if (skip > 0)
106+ LOG_DEBUG("PCPStream::flushUb: skip %d packets", skip);
107+
108+ return len;
109+}
110+
87111 // ------------------------------------------
88112 int PCPStream::readPacket(Stream &in,Channel *)
89113 {
@@ -433,9 +457,17 @@ void PCPStream::readHostAtoms(AtomStream &atom, int numc, BroadcastState &bcs, C
433457 ipNum = 1;
434458 }
435459 else if (id == PCP_HOST_NUML)
460+ {
436461 hit.numListeners = atom.readInt();
462+ if (hit.numListeners > 10)
463+ hit.numListeners = 10;
464+ }
437465 else if (id == PCP_HOST_NUMR)
466+ {
438467 hit.numRelays = atom.readInt();
468+ if (hit.numRelays > 100)
469+ hit.numRelays = 100;
470+ }
439471 else if (id == PCP_HOST_UPTIME)
440472 hit.upTime = atom.readInt();
441473 else if (id == PCP_HOST_OLDPOS)
@@ -500,9 +532,11 @@ void PCPStream::readHostAtoms(AtomStream &atom, int numc, BroadcastState &bcs, C
500532
501533 if (hit.numHops == 1){
502534 Servent *sv = servMgr->findServentByServentID(hit.servent_id);
503- if (sv){
535+ if (sv && sv->getHost().ip == hit.host.ip){
504536 // LOG_DEBUG("set servent's waitPort = %d", hit.host.port);
505537 sv->waitPort = hit.host.port;
538+ hit.lastSendSeq = sv->serventHit.lastSendSeq;
539+ sv->serventHit = hit;
506540 }
507541 }
508542 }
@@ -696,6 +730,7 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
696730 {
697731 ChanHit hit;
698732 readHostAtoms(atom,c,bcs,hit,false);
733+ Servent *sv = servMgr->findServentByServentID(bcs.servent_id);
699734 if (hit.uphost.ip == 0){
700735 // LOG_DEBUG("bcs servent_id = %d", bcs.servent_id);
701736 if (bcs.numHops == 1){
@@ -703,7 +738,7 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
703738 hit.uphost.port = servMgr->serverHost.port;
704739 hit.uphostHops = 1;
705740 } else {
706- Servent *sv = servMgr->findServentByServentID(bcs.servent_id);
741+ //Servent *sv = servMgr->findServentByServentID(bcs.servent_id);
707742 if (sv){
708743 hit.uphost.ip = sv->getHost().ip;
709744 hit.uphost.port = sv->waitPort;
@@ -711,10 +746,21 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
711746 }
712747 }
713748 }
714- int oldPos = pmem.pos;
715- hit.writeAtoms(patom, hit.chanID);
716- pmem.pos = oldPos;
717- r = readAtom(patom,bcs);
749+ if (sv &&
750+ ((hit.numHops == 1 && (hit.rhost[0].ip == sv->getHost().ip
751+ && hit.uphost.ip == servMgr->serverHost.ip && hit.uphost.port == servMgr->serverHost.port)
752+ || (hit.rhost[1].localIP() && hit.rhost[1].ip == sv->getHost().ip))
753+ || chanMgr->findParentHit(hit)))
754+ {
755+ int oldPos = pmem.pos;
756+ hit.writeAtoms(patom, hit.chanID);
757+ pmem.pos = oldPos;
758+ r = readAtom(patom,bcs);
759+ } else {
760+ LOG_DEBUG("### Invalid bcst: hops=%d, ver=%d(VP%04d), ttl=%d",
761+ bcs.numHops,ver,ver_vp,ttl);
762+ ttl = 0;
763+ }
718764 } else {
719765 // copy and process atoms
720766 int oldPos = pmem.pos;
@@ -761,6 +807,7 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
761807
762808 if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
763809 {
810+ pack.priority = 11 - bcs.numHops;
764811 chanMgr->broadcastPacketUp(pack,bcs.chanID,remoteID,destID);
765812 }
766813
--- a/PeerCast.root/PeerCast/core/common/pcp.h
+++ b/PeerCast.root/PeerCast/core/common/pcp.h
@@ -235,6 +235,7 @@ public:
235235
236236 virtual bool sendPacket(ChanPacket &,GnuID &);
237237 virtual void flush(Stream &);
238+ virtual unsigned int flushUb(Stream &, unsigned int);
238239 virtual void readHeader(Stream &,Channel *);
239240 virtual int readPacket(Stream &,Channel *);
240241 virtual void readEnd(Stream &,Channel *);
--- a/PeerCast.root/PeerCast/core/common/servent.cpp
+++ b/PeerCast.root/PeerCast/core/common/servent.cpp
@@ -240,6 +240,8 @@ void Servent::reset()
240240 type = T_NONE;
241241
242242 channel_id = 0;
243+
244+ serventHit.init();
243245 }
244246 // -----------------------------------
245247 bool Servent::sendPacket(ChanPacket &pack,GnuID &cid,GnuID &sid,GnuID &did,Servent::TYPE t)
@@ -807,6 +809,7 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
807809
808810 bool gotPCP=false;
809811 unsigned int reqPos=0;
812+ unsigned short listenPort = 0;
810813
811814 nsSwitchNum=0;
812815
@@ -820,6 +823,8 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
820823 gotPCP = atoi(arg)!=0;
821824 else if (http.isHeader(PCX_HS_POS))
822825 reqPos = atoi(arg);
826+ else if (http.isHeader(PCX_HS_PORT))
827+ listenPort = (unsigned short)atoi(arg);
823828 else if (http.isHeader("icy-metadata"))
824829 addMetadata = atoi(arg) > 0;
825830 else if (http.isHeader(HTTP_HS_AGENT))
@@ -873,22 +878,23 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
873878 }
874879
875880 chanID = chanInfo.id;
881+ serventHit.rhost[0].ip = getHost().ip;
882+ serventHit.rhost[0].port = listenPort;
883+ serventHit.host = serventHit.rhost[0];
884+ serventHit.chanID = chanID;
885+
876886 canStreamLock.on();
877887 chanReady = canStream(ch);
878- if (0 && !chanReady)
888+ if (/*0 && */!chanReady)
879889 {
880890 if (servMgr->numStreams(chanID, Servent::T_RELAY, false) == 0)
881891 {
882892 sourceHit = &ch->sourceHost; // send source host info
883893
884- if (ch->info.getUptime() > 60) // if stable
894+ if (listenPort && ch->info.getUptime() > 60) // if stable
885895 {
886896 // connect "this" host later
887- ChanHit nh;
888- nh.init();
889- nh.chanID = chanID;
890- nh.rhost[0] = getHost();
891- chanMgr->addHit(nh);
897+ chanMgr->addHit(serventHit);
892898 }
893899
894900 char tmp[50];
@@ -896,11 +902,11 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
896902 LOG_DEBUG("Bump channel, hand over sourceHost to %s", tmp);
897903 ch->bump = true;
898904 }
899- else if (servMgr->kickUnrelayableHost(chanID, this) != 0)
905+ else if (servMgr->kickUnrelayableHost(chanID, serventHit) != 0)
900906 {
901907 chanReady = canStream(ch);
902908 if (!chanReady)
903- LOG_DEBUG("Kicked unrelayable host, but still cannot stream");
909+ LOG_DEBUG("*** Kicked unrelayable host, but still cannot stream");
904910 }
905911 }
906912 if (!chanReady) type = T_INCOMING;
@@ -1114,8 +1120,8 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
11141120 if (sourceHit) {
11151121 char tmp[50];
11161122 sourceHit->writeAtoms(atom2, chanInfo.id);
1117- chs.best[i].host.toStr(tmp);
1118- LOG_DEBUG("relay info: %s hops = %d", tmp, chs.best[i].numHops);
1123+ sourceHit->host.toStr(tmp);
1124+ LOG_DEBUG("relay info(sourceHit): %s", tmp);
11191125 best.host.ip = sourceHit->host.ip;
11201126 }
11211127
@@ -2792,6 +2798,8 @@ void Servent::sendPeercastChannel()
27922798 void Servent::sendPCPChannel()
27932799 {
27942800 bool skipCheck = false;
2801+ unsigned int ptime = 0;
2802+ int npacket = 0, upsize = 0;
27952803
27962804 Channel *ch = chanMgr->findChannelByID(chanID);
27972805 if (!ch)
@@ -2929,11 +2937,23 @@ void Servent::sendPCPChannel()
29292937 BroadcastState bcs;
29302938 bcs.servent_id = servent_id;
29312939 // error = pcpStream->readPacket(*sock,bcs);
2932- do {
2940+
2941+ unsigned int t = sys->getTime();
2942+ if (t != ptime) {
2943+ ptime = t;
2944+ npacket = MAX_PROC_PACKETS;
2945+ upsize = MAX_OUTWARD_SIZE;
2946+ }
2947+
2948+ int len = pcpStream->flushUb(*sock, upsize);
2949+ upsize -= len;
2950+
2951+ while (npacket > 0 && sock->readReady()) {
2952+ npacket--;
29332953 error = pcpStream->readPacket(*sock,bcs);
29342954 if (error)
29352955 throw StreamException("PCP exception");
2936- } while (sock->readReady() || pcpStream->outData.numPending());
2956+ }
29372957
29382958 sys->sleepIdle();
29392959
--- a/PeerCast.root/PeerCast/core/common/servent.h
+++ b/PeerCast.root/PeerCast/core/common/servent.h
@@ -46,6 +46,12 @@ public:
4646 MAX_OUTPACKETS = 32 // max. output packets per queue (normal/priority)
4747 };
4848
49+ enum
50+ {
51+ MAX_PROC_PACKETS = 300,
52+ MAX_OUTWARD_SIZE = 1024 * 10
53+ };
54+
4955 enum TYPE
5056 {
5157 T_NONE, // Not allocated
@@ -288,6 +294,8 @@ public:
288294 unsigned int lastSkipCount;
289295 unsigned int waitPort;
290296
297+ ChanHit serventHit;
298+
291299 int channel_id;
292300 };
293301
--- a/PeerCast.root/PeerCast/core/common/servmgr.cpp
+++ b/PeerCast.root/PeerCast/core/common/servmgr.cpp
@@ -2623,6 +2623,7 @@ void ServMgr::banFirewalledHost()
26232623 }
26242624
26252625 // --------------------------------------------------
2626+#if 0
26262627 static ChanHit *findServentHit(Servent *s)
26272628 {
26282629 ChanHitList *chl = chanMgr->findHitListByID(s->chanID);
@@ -2640,8 +2641,9 @@ static ChanHit *findServentHit(Servent *s)
26402641 }
26412642 return NULL;
26422643 }
2644+#endif
26432645 // --------------------------------------------------
2644-int ServMgr::kickUnrelayableHost(GnuID &chid, Servent *ns)
2646+int ServMgr::kickUnrelayableHost(GnuID &chid, ChanHit &sendhit)
26452647 {
26462648 Servent *ks = NULL;
26472649 Servent *s = servMgr->servents;
@@ -2652,9 +2654,8 @@ int ServMgr::kickUnrelayableHost(GnuID &chid, Servent *ns)
26522654 {
26532655 Host h = s->getHost();
26542656
2655- chanMgr->hitlistlock.on();
2656- ChanHit *hit = findServentHit(s);
2657- if (hit && !hit->relay && hit->numRelays == 0)
2657+ ChanHit hit = s->serventHit;
2658+ if (!hit.relay && hit.numRelays == 0)
26582659 {
26592660 char hostName[256];
26602661 h.toStr(hostName);
@@ -2663,25 +2664,18 @@ int ServMgr::kickUnrelayableHost(GnuID &chid, Servent *ns)
26632664 if (!ks || s->lastConnect < ks->lastConnect) // elder servent
26642665 ks = s;
26652666 }
2666- chanMgr->hitlistlock.off();
26672667 }
26682668 s = s->next;
26692669 }
26702670
26712671 if (ks)
26722672 {
2673- if (ns)
2673+ if (sendhit.rhost[0].port)
26742674 {
2675- Host h = ns->getHost();
2676- ChanHit nh;
2677- nh.init();
2678- nh.chanID = chid;
2679- nh.rhost[0] = h;
2680-
26812675 ChanPacket pack;
26822676 MemoryStream mem(pack.data,sizeof(pack.data));
26832677 AtomStream atom(mem);
2684- nh.writeAtoms(atom, chid);
2678+ sendhit.writeAtoms(atom, chid);
26852679 pack.len = mem.pos;
26862680 pack.type = ChanPacket::T_PCP;
26872681 GnuID noID;
--- a/PeerCast.root/PeerCast/core/common/servmgr.h
+++ b/PeerCast.root/PeerCast/core/common/servmgr.h
@@ -402,7 +402,7 @@ public:
402402 unsigned int kickPushTime;
403403 bool isCheckPushStream(); //JP-EX
404404 void banFirewalledHost(); //JP-EX
405- int kickUnrelayableHost(GnuID &, Servent * = NULL);
405+ int kickUnrelayableHost(GnuID &, ChanHit &);
406406
407407 bool getModulePath; //JP-EX
408408 bool clearPLS; //JP-EX
--- a/PeerCast.root/PeerCast/core/common/version2.h
+++ b/PeerCast.root/PeerCast/core/common/version2.h
@@ -29,22 +29,22 @@ static bool PCP_FORCE_YP = false;
2929 #endif
3030 // ------------------------------------------------
3131 static const int PCP_CLIENT_VERSION = 1218;
32-static const int PCP_CLIENT_VERSION_VP = 25;
32+static const int PCP_CLIENT_VERSION_VP = 26;
3333 static const int PCP_ROOT_VERSION = 1218;
3434
3535 static const int PCP_CLIENT_MINVERSION = 1200;
3636
3737 static const char *PCX_AGENT = "PeerCast/0.1218";
3838 static const char *PCX_AGENTJP = "PeerCast/0.1218-J";
39-static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0025-1)";
40-static const char *PCX_VERSTRING = "v0.1218(VP0025-1)";
39+static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0026)";
40+static const char *PCX_VERSTRING = "v0.1218(VP0026)";
4141
4242 #if 1 /* for VP extend version */
4343 #define VERSION_EX 1
4444 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
45-static const int PCP_CLIENT_VERSION_EX_NUMBER = 7650;
46-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM-VP25-1)";
47-static const char *PCX_VERSTRING_EX = "v0.1218(IM765-VP25-1)";
45+static const int PCP_CLIENT_VERSION_EX_NUMBER = 26;
46+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0026-patch071223)";
47+static const char *PCX_VERSTRING_EX = "v0.1218(IM0026)";
4848 #endif
4949
5050 // ------------------------------------------------
--- a/c:/Git/PeerCast.root/PeerCast/core/common/channel.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/channel.cpp
@@ -537,6 +537,7 @@ int Channel::handshakeFetch()
537537 sock->writeLineF("GET /channel/%s HTTP/1.0",idStr);
538538 sock->writeLineF("%s %d",PCX_HS_POS,streamPos);
539539 sock->writeLineF("%s %d",PCX_HS_PCP,1);
540+ sock->writeLineF("%s %d",PCX_HS_PORT,servMgr->serverHost.port);
540541
541542 sock->writeLine("");
542543
@@ -1475,8 +1476,11 @@ bool ChannelStream::getStatus(Channel *ch,ChanPacket &pack)
14751476 // -----------------------------------
14761477 bool Channel::checkBump()
14771478 {
1479+ unsigned int maxIdleTime = 30;
1480+ if (isIndexTxt(this)) maxIdleTime = 60;
1481+
14781482 if (!isBroadcasting() && (!sourceHost.tracker))
1479- if (rawData.lastWriteTime && ((sys->getTime() - rawData.lastWriteTime) > 30))
1483+ if (rawData.lastWriteTime && ((sys->getTime() - rawData.lastWriteTime) > maxIdleTime))
14801484 {
14811485 LOG_ERROR("Channel Auto bumped");
14821486 bump = true;
@@ -1509,6 +1513,9 @@ int Channel::readStream(Stream &in,ChannelStream *source)
15091513
15101514 unsigned int receiveStartTime = 0;
15111515
1516+ unsigned int ptime = 0;
1517+ unsigned int upsize = 0;
1518+
15121519 try
15131520 {
15141521 while (thread.active && !peercastInst->isQuitting)
@@ -1573,7 +1580,14 @@ int Channel::readStream(Stream &in,ChannelStream *source)
15731580 }
15741581 }
15751582
1576- source->flush(in);
1583+ unsigned int t = sys->getTime();
1584+ if (t != ptime) {
1585+ ptime = t;
1586+ upsize = Servent::MAX_OUTWARD_SIZE;
1587+ }
1588+
1589+ unsigned int len = source->flushUb(in, upsize);
1590+ upsize -= len;
15771591
15781592 sys->sleepIdle();
15791593 }
@@ -1733,9 +1747,12 @@ void ChanPacket::init(ChanPacketv &p)
17331747 {
17341748 type = p.type;
17351749 len = p.len;
1750+ if (len > MAX_DATALEN)
1751+ throw StreamException("Packet data too large");
17361752 pos = p.pos;
17371753 sync = p.sync;
17381754 skip = p.skip;
1755+ priority = p.priority;
17391756 memcpy(data, p.data, len);
17401757 }
17411758 // -----------------------------------
@@ -1748,6 +1765,7 @@ void ChanPacket::init(TYPE t, const void *p, unsigned int l,unsigned int _pos)
17481765 memcpy(data,p,len);
17491766 pos = _pos;
17501767 skip = false;
1768+ priority = 0;
17511769 }
17521770 // -----------------------------------
17531771 void ChanPacket::writeRaw(Stream &out)
@@ -1970,10 +1988,34 @@ void ChanPacketBuffer::readPacket(ChanPacket &pack)
19701988 pack.init(packets[readPos%MAX_PACKETS]);
19711989 readPos++;
19721990 lock.off();
1991+}
19731992
1974- sys->sleepIdle();
1993+// -----------------------------------
1994+void ChanPacketBuffer::readPacketPri(ChanPacket &pack)
1995+{
1996+ unsigned int tim = sys->getTime();
1997+
1998+ if (readPos < firstPos)
1999+ throw StreamException("Read too far behind");
2000+
2001+ while (readPos >= writePos)
2002+ {
2003+ sys->sleepIdle();
2004+ if ((sys->getTime() - tim) > 30)
2005+ throw TimeoutException();
2006+ }
2007+ lock.on();
2008+ ChanPacketv *best = &packets[readPos % MAX_PACKETS];
2009+ for (unsigned int i = readPos + 1; i < writePos; i++) {
2010+ if (packets[i % MAX_PACKETS].priority > best->priority)
2011+ best = &packets[i % MAX_PACKETS];
2012+ }
2013+ pack.init(*best);
2014+ best->init(packets[readPos % MAX_PACKETS]);
2015+ readPos++;
2016+ lock.off();
2017+ }
19752018
1976-}
19772019 // -----------------------------------
19782020 bool ChanPacketBuffer::willSkip()
19792021 {
@@ -2898,6 +2940,35 @@ ChanHit *ChanMgr::addHit(ChanHit &h)
28982940 }
28992941
29002942 // -----------------------------------
2943+bool ChanMgr::findParentHit(ChanHit &p)
2944+{
2945+ ChanHitList *hl=NULL;
2946+
2947+ chanMgr->hitlistlock.on();
2948+
2949+ hl = findHitListByID(p.chanID);
2950+
2951+ if (hl)
2952+ {
2953+ ChanHit *ch = hl->hit;
2954+ while (ch)
2955+ {
2956+ if (!ch->dead && (ch->rhost[0].ip == p.uphost.ip)
2957+ && (ch->rhost[0].port == p.uphost.port))
2958+ {
2959+ chanMgr->hitlistlock.off();
2960+ return 1;
2961+ }
2962+ ch = ch->next;
2963+ }
2964+ }
2965+
2966+ chanMgr->hitlistlock.off();
2967+
2968+ return 0;
2969+}
2970+
2971+// -----------------------------------
29012972 class ChanFindInfo : public ThreadInfo
29022973 {
29032974 public:
@@ -3064,6 +3135,7 @@ void ChanHit::init()
30643135 version_ex_number = 0;
30653136
30663137 status = 0;
3138+ servent_id = 0;
30673139
30683140 sessionID.clear();
30693141 chanID.clear();
@@ -4503,6 +4575,22 @@ int ChanHitSearch::getRelayHost(Host host1, Host host2, GnuID exID, ChanHitList
45034575 riSequence &= 0xffffff;
45044576 seqLock.off();
45054577
4578+ Servent *s = servMgr->servents;
4579+ while (s) {
4580+ if (s->serventHit.rhost[0].port && s->type == Servent::T_RELAY
4581+ && s->chanID.isSame(chl->info.id)) {
4582+ int i = index % MAX_RESULTS;
4583+ if (index < MAX_RESULTS
4584+ || tmpHit[i].lastSendSeq > s->serventHit.lastSendSeq) {
4585+ s->serventHit.lastSendSeq = seq;
4586+ tmpHit[i] = s->serventHit;
4587+ tmpHit[i].host = s->serventHit.rhost[0];
4588+ index++;
4589+ }
4590+ }
4591+ s = s->next;
4592+ }
4593+
45064594 ChanHit *hit = chl->hit;
45074595
45084596 while(hit){
@@ -4534,6 +4622,7 @@ int ChanHitSearch::getRelayHost(Host host1, Host host2, GnuID exID, ChanHitList
45344622 //rnd = (float)rand() / (float)RAND_MAX;
45354623 rnd = rand() % base;
45364624 if (hit->numHops == 1){
4625+#if 0
45374626 if (tmpHit[index % MAX_RESULTS].numHops == 1){
45384627 if (rnd < prob){
45394628 tmpHit[index % MAX_RESULTS] = *hit;
@@ -4545,8 +4634,9 @@ int ChanHitSearch::getRelayHost(Host host1, Host host2, GnuID exID, ChanHitList
45454634 tmpHit[index % MAX_RESULTS].host = hit->rhost[0];
45464635 index++;
45474636 }
4637+#endif
45484638 } else {
4549- if ((tmpHit[index % MAX_RESULTS].numHops != 1) && (rnd < prob)){
4639+ if ((tmpHit[index % MAX_RESULTS].numHops != 1) && (rnd < prob) || rnd == 0){
45504640 tmpHit[index % MAX_RESULTS] = *hit;
45514641 tmpHit[index % MAX_RESULTS].host = hit->rhost[0];
45524642 index++;
--- a/c:/Git/PeerCast.root/PeerCast/core/common/channel.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/channel.h
@@ -207,6 +207,8 @@ public:
207207
208208 char version_ex_prefix[2];
209209 unsigned int version_ex_number;
210+
211+ unsigned int lastSendSeq;
210212 };
211213 // ----------------------------------
212214 class ChanHitList
@@ -603,7 +605,7 @@ public:
603605
604606 int pickHits(ChanHitSearch &);
605607
606-
608+ bool findParentHit(ChanHit &p);
607609
608610 Channel *channel;
609611 ChanHitList *hitlist;
--- a/c:/Git/PeerCast.root/PeerCast/core/common/cstream.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/cstream.h
@@ -58,6 +58,7 @@ public:
5858 pos = 0;
5959 sync = 0;
6060 skip = false;
61+ priority = 0;
6162 }
6263 void init(ChanPacketv &p);
6364 void init(TYPE t, const void *, unsigned int , unsigned int );
@@ -74,6 +75,7 @@ public:
7475 char data[MAX_DATALEN];
7576 bool skip;
7677
78+ int priority;
7779 };
7880 // ----------------------------------
7981 class ChanPacketv
@@ -111,6 +113,7 @@ public:
111113 skip = false;
112114 data = NULL;
113115 datasize = 0;
116+ priority = 0;
114117 }
115118 void init(ChanPacket &p)
116119 {
@@ -124,6 +127,7 @@ public:
124127 pos = p.pos;
125128 sync = p.sync;
126129 skip = p.skip;
130+ priority = p.priority;
127131 if (!data) {
128132 datasize = (len & ~(BSIZE - 1)) + BSIZE;
129133 data = new char[datasize];
@@ -149,6 +153,7 @@ public:
149153 unsigned int datasize;
150154 bool skip;
151155
156+ int priority;
152157 };
153158 // ----------------------------------
154159 class ChanPacketBuffer
@@ -176,6 +181,7 @@ public:
176181
177182 bool writePacket(ChanPacket &,bool = false);
178183 void readPacket(ChanPacket &);
184+ void readPacketPri(ChanPacket &);
179185
180186 bool willSkip();
181187
@@ -221,6 +227,7 @@ public:
221227 virtual void kill() {}
222228 virtual bool sendPacket(ChanPacket &,GnuID &) {return false;}
223229 virtual void flush(Stream &) {}
230+ virtual unsigned int flushUb(Stream &, unsigned int) { return 0; }
224231 virtual void readHeader(Stream &,Channel *)=0;
225232 virtual int readPacket(Stream &,Channel *)=0;
226233 virtual void readEnd(Stream &,Channel *)=0;
--- a/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/pcp.cpp
@@ -84,6 +84,30 @@ void PCPStream::flush(Stream &in)
8484 pack.writeRaw(in);
8585 }
8686 }
87+
88+// ------------------------------------------
89+unsigned int PCPStream::flushUb(Stream &in, unsigned int size)
90+{
91+ ChanPacket pack;
92+ unsigned int len = 0, skip = 0;
93+
94+ while (outData.numPending())
95+ {
96+ outData.readPacketPri(pack);
97+
98+ if (size >= len + pack.len) {
99+ len += pack.len;
100+ pack.writeRaw(in);
101+ } else {
102+ skip++;
103+ }
104+ }
105+ if (skip > 0)
106+ LOG_DEBUG("PCPStream::flushUb: skip %d packets", skip);
107+
108+ return len;
109+}
110+
87111 // ------------------------------------------
88112 int PCPStream::readPacket(Stream &in,Channel *)
89113 {
@@ -433,9 +457,17 @@ void PCPStream::readHostAtoms(AtomStream &atom, int numc, BroadcastState &bcs, C
433457 ipNum = 1;
434458 }
435459 else if (id == PCP_HOST_NUML)
460+ {
436461 hit.numListeners = atom.readInt();
462+ if (hit.numListeners > 10)
463+ hit.numListeners = 10;
464+ }
437465 else if (id == PCP_HOST_NUMR)
466+ {
438467 hit.numRelays = atom.readInt();
468+ if (hit.numRelays > 100)
469+ hit.numRelays = 100;
470+ }
439471 else if (id == PCP_HOST_UPTIME)
440472 hit.upTime = atom.readInt();
441473 else if (id == PCP_HOST_OLDPOS)
@@ -500,9 +532,11 @@ void PCPStream::readHostAtoms(AtomStream &atom, int numc, BroadcastState &bcs, C
500532
501533 if (hit.numHops == 1){
502534 Servent *sv = servMgr->findServentByServentID(hit.servent_id);
503- if (sv){
535+ if (sv && sv->getHost().ip == hit.host.ip){
504536 // LOG_DEBUG("set servent's waitPort = %d", hit.host.port);
505537 sv->waitPort = hit.host.port;
538+ hit.lastSendSeq = sv->serventHit.lastSendSeq;
539+ sv->serventHit = hit;
506540 }
507541 }
508542 }
@@ -696,6 +730,7 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
696730 {
697731 ChanHit hit;
698732 readHostAtoms(atom,c,bcs,hit,false);
733+ Servent *sv = servMgr->findServentByServentID(bcs.servent_id);
699734 if (hit.uphost.ip == 0){
700735 // LOG_DEBUG("bcs servent_id = %d", bcs.servent_id);
701736 if (bcs.numHops == 1){
@@ -703,7 +738,7 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
703738 hit.uphost.port = servMgr->serverHost.port;
704739 hit.uphostHops = 1;
705740 } else {
706- Servent *sv = servMgr->findServentByServentID(bcs.servent_id);
741+ //Servent *sv = servMgr->findServentByServentID(bcs.servent_id);
707742 if (sv){
708743 hit.uphost.ip = sv->getHost().ip;
709744 hit.uphost.port = sv->waitPort;
@@ -711,10 +746,21 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
711746 }
712747 }
713748 }
714- int oldPos = pmem.pos;
715- hit.writeAtoms(patom, hit.chanID);
716- pmem.pos = oldPos;
717- r = readAtom(patom,bcs);
749+ if (sv &&
750+ ((hit.numHops == 1 && (hit.rhost[0].ip == sv->getHost().ip
751+ && hit.uphost.ip == servMgr->serverHost.ip && hit.uphost.port == servMgr->serverHost.port)
752+ || (hit.rhost[1].localIP() && hit.rhost[1].ip == sv->getHost().ip))
753+ || chanMgr->findParentHit(hit)))
754+ {
755+ int oldPos = pmem.pos;
756+ hit.writeAtoms(patom, hit.chanID);
757+ pmem.pos = oldPos;
758+ r = readAtom(patom,bcs);
759+ } else {
760+ LOG_DEBUG("### Invalid bcst: hops=%d, ver=%d(VP%04d), ttl=%d",
761+ bcs.numHops,ver,ver_vp,ttl);
762+ ttl = 0;
763+ }
718764 } else {
719765 // copy and process atoms
720766 int oldPos = pmem.pos;
@@ -761,6 +807,7 @@ int PCPStream::readBroadcastAtoms(AtomStream &atom,int numc,BroadcastState &bcs)
761807
762808 if (bcs.group & (/*PCP_BCST_GROUP_ROOT|*/PCP_BCST_GROUP_TRACKERS|PCP_BCST_GROUP_RELAYS))
763809 {
810+ pack.priority = 11 - bcs.numHops;
764811 chanMgr->broadcastPacketUp(pack,bcs.chanID,remoteID,destID);
765812 }
766813
--- a/c:/Git/PeerCast.root/PeerCast/core/common/pcp.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/pcp.h
@@ -235,6 +235,7 @@ public:
235235
236236 virtual bool sendPacket(ChanPacket &,GnuID &);
237237 virtual void flush(Stream &);
238+ virtual unsigned int flushUb(Stream &, unsigned int);
238239 virtual void readHeader(Stream &,Channel *);
239240 virtual int readPacket(Stream &,Channel *);
240241 virtual void readEnd(Stream &,Channel *);
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servent.cpp
@@ -240,6 +240,8 @@ void Servent::reset()
240240 type = T_NONE;
241241
242242 channel_id = 0;
243+
244+ serventHit.init();
243245 }
244246 // -----------------------------------
245247 bool Servent::sendPacket(ChanPacket &pack,GnuID &cid,GnuID &sid,GnuID &did,Servent::TYPE t)
@@ -807,6 +809,7 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
807809
808810 bool gotPCP=false;
809811 unsigned int reqPos=0;
812+ unsigned short listenPort = 0;
810813
811814 nsSwitchNum=0;
812815
@@ -820,6 +823,8 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
820823 gotPCP = atoi(arg)!=0;
821824 else if (http.isHeader(PCX_HS_POS))
822825 reqPos = atoi(arg);
826+ else if (http.isHeader(PCX_HS_PORT))
827+ listenPort = (unsigned short)atoi(arg);
823828 else if (http.isHeader("icy-metadata"))
824829 addMetadata = atoi(arg) > 0;
825830 else if (http.isHeader(HTTP_HS_AGENT))
@@ -873,22 +878,23 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
873878 }
874879
875880 chanID = chanInfo.id;
881+ serventHit.rhost[0].ip = getHost().ip;
882+ serventHit.rhost[0].port = listenPort;
883+ serventHit.host = serventHit.rhost[0];
884+ serventHit.chanID = chanID;
885+
876886 canStreamLock.on();
877887 chanReady = canStream(ch);
878- if (0 && !chanReady)
888+ if (/*0 && */!chanReady)
879889 {
880890 if (servMgr->numStreams(chanID, Servent::T_RELAY, false) == 0)
881891 {
882892 sourceHit = &ch->sourceHost; // send source host info
883893
884- if (ch->info.getUptime() > 60) // if stable
894+ if (listenPort && ch->info.getUptime() > 60) // if stable
885895 {
886896 // connect "this" host later
887- ChanHit nh;
888- nh.init();
889- nh.chanID = chanID;
890- nh.rhost[0] = getHost();
891- chanMgr->addHit(nh);
897+ chanMgr->addHit(serventHit);
892898 }
893899
894900 char tmp[50];
@@ -896,11 +902,11 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
896902 LOG_DEBUG("Bump channel, hand over sourceHost to %s", tmp);
897903 ch->bump = true;
898904 }
899- else if (servMgr->kickUnrelayableHost(chanID, this) != 0)
905+ else if (servMgr->kickUnrelayableHost(chanID, serventHit) != 0)
900906 {
901907 chanReady = canStream(ch);
902908 if (!chanReady)
903- LOG_DEBUG("Kicked unrelayable host, but still cannot stream");
909+ LOG_DEBUG("*** Kicked unrelayable host, but still cannot stream");
904910 }
905911 }
906912 if (!chanReady) type = T_INCOMING;
@@ -1114,8 +1120,8 @@ bool Servent::handshakeStream(ChanInfo &chanInfo)
11141120 if (sourceHit) {
11151121 char tmp[50];
11161122 sourceHit->writeAtoms(atom2, chanInfo.id);
1117- chs.best[i].host.toStr(tmp);
1118- LOG_DEBUG("relay info: %s hops = %d", tmp, chs.best[i].numHops);
1123+ sourceHit->host.toStr(tmp);
1124+ LOG_DEBUG("relay info(sourceHit): %s", tmp);
11191125 best.host.ip = sourceHit->host.ip;
11201126 }
11211127
@@ -2792,6 +2798,8 @@ void Servent::sendPeercastChannel()
27922798 void Servent::sendPCPChannel()
27932799 {
27942800 bool skipCheck = false;
2801+ unsigned int ptime = 0;
2802+ int npacket = 0, upsize = 0;
27952803
27962804 Channel *ch = chanMgr->findChannelByID(chanID);
27972805 if (!ch)
@@ -2929,11 +2937,23 @@ void Servent::sendPCPChannel()
29292937 BroadcastState bcs;
29302938 bcs.servent_id = servent_id;
29312939 // error = pcpStream->readPacket(*sock,bcs);
2932- do {
2940+
2941+ unsigned int t = sys->getTime();
2942+ if (t != ptime) {
2943+ ptime = t;
2944+ npacket = MAX_PROC_PACKETS;
2945+ upsize = MAX_OUTWARD_SIZE;
2946+ }
2947+
2948+ int len = pcpStream->flushUb(*sock, upsize);
2949+ upsize -= len;
2950+
2951+ while (npacket > 0 && sock->readReady()) {
2952+ npacket--;
29332953 error = pcpStream->readPacket(*sock,bcs);
29342954 if (error)
29352955 throw StreamException("PCP exception");
2936- } while (sock->readReady() || pcpStream->outData.numPending());
2956+ }
29372957
29382958 sys->sleepIdle();
29392959
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servent.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servent.h
@@ -46,6 +46,12 @@ public:
4646 MAX_OUTPACKETS = 32 // max. output packets per queue (normal/priority)
4747 };
4848
49+ enum
50+ {
51+ MAX_PROC_PACKETS = 300,
52+ MAX_OUTWARD_SIZE = 1024 * 10
53+ };
54+
4955 enum TYPE
5056 {
5157 T_NONE, // Not allocated
@@ -288,6 +294,8 @@ public:
288294 unsigned int lastSkipCount;
289295 unsigned int waitPort;
290296
297+ ChanHit serventHit;
298+
291299 int channel_id;
292300 };
293301
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp
@@ -2623,6 +2623,7 @@ void ServMgr::banFirewalledHost()
26232623 }
26242624
26252625 // --------------------------------------------------
2626+#if 0
26262627 static ChanHit *findServentHit(Servent *s)
26272628 {
26282629 ChanHitList *chl = chanMgr->findHitListByID(s->chanID);
@@ -2640,8 +2641,9 @@ static ChanHit *findServentHit(Servent *s)
26402641 }
26412642 return NULL;
26422643 }
2644+#endif
26432645 // --------------------------------------------------
2644-int ServMgr::kickUnrelayableHost(GnuID &chid, Servent *ns)
2646+int ServMgr::kickUnrelayableHost(GnuID &chid, ChanHit &sendhit)
26452647 {
26462648 Servent *ks = NULL;
26472649 Servent *s = servMgr->servents;
@@ -2652,9 +2654,8 @@ int ServMgr::kickUnrelayableHost(GnuID &chid, Servent *ns)
26522654 {
26532655 Host h = s->getHost();
26542656
2655- chanMgr->hitlistlock.on();
2656- ChanHit *hit = findServentHit(s);
2657- if (hit && !hit->relay && hit->numRelays == 0)
2657+ ChanHit hit = s->serventHit;
2658+ if (!hit.relay && hit.numRelays == 0)
26582659 {
26592660 char hostName[256];
26602661 h.toStr(hostName);
@@ -2663,25 +2664,18 @@ int ServMgr::kickUnrelayableHost(GnuID &chid, Servent *ns)
26632664 if (!ks || s->lastConnect < ks->lastConnect) // elder servent
26642665 ks = s;
26652666 }
2666- chanMgr->hitlistlock.off();
26672667 }
26682668 s = s->next;
26692669 }
26702670
26712671 if (ks)
26722672 {
2673- if (ns)
2673+ if (sendhit.rhost[0].port)
26742674 {
2675- Host h = ns->getHost();
2676- ChanHit nh;
2677- nh.init();
2678- nh.chanID = chid;
2679- nh.rhost[0] = h;
2680-
26812675 ChanPacket pack;
26822676 MemoryStream mem(pack.data,sizeof(pack.data));
26832677 AtomStream atom(mem);
2684- nh.writeAtoms(atom, chid);
2678+ sendhit.writeAtoms(atom, chid);
26852679 pack.len = mem.pos;
26862680 pack.type = ChanPacket::T_PCP;
26872681 GnuID noID;
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.h
@@ -402,7 +402,7 @@ public:
402402 unsigned int kickPushTime;
403403 bool isCheckPushStream(); //JP-EX
404404 void banFirewalledHost(); //JP-EX
405- int kickUnrelayableHost(GnuID &, Servent * = NULL);
405+ int kickUnrelayableHost(GnuID &, ChanHit &);
406406
407407 bool getModulePath; //JP-EX
408408 bool clearPLS; //JP-EX
--- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
@@ -29,22 +29,22 @@ static bool PCP_FORCE_YP = false;
2929 #endif
3030 // ------------------------------------------------
3131 static const int PCP_CLIENT_VERSION = 1218;
32-static const int PCP_CLIENT_VERSION_VP = 25;
32+static const int PCP_CLIENT_VERSION_VP = 26;
3333 static const int PCP_ROOT_VERSION = 1218;
3434
3535 static const int PCP_CLIENT_MINVERSION = 1200;
3636
3737 static const char *PCX_AGENT = "PeerCast/0.1218";
3838 static const char *PCX_AGENTJP = "PeerCast/0.1218-J";
39-static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0025-1)";
40-static const char *PCX_VERSTRING = "v0.1218(VP0025-1)";
39+static const char *PCX_AGENTVP = "PeerCast/0.1218(VP0026)";
40+static const char *PCX_VERSTRING = "v0.1218(VP0026)";
4141
4242 #if 1 /* for VP extend version */
4343 #define VERSION_EX 1
4444 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
45-static const int PCP_CLIENT_VERSION_EX_NUMBER = 7650;
46-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM-VP25-1)";
47-static const char *PCX_VERSTRING_EX = "v0.1218(IM765-VP25-1)";
45+static const int PCP_CLIENT_VERSION_EX_NUMBER = 26;
46+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0026-patch071223)";
47+static const char *PCX_VERSTRING_EX = "v0.1218(IM0026)";
4848 #endif
4949
5050 // ------------------------------------------------
Show on old repository browser