• R/O
  • HTTP
  • SSH
  • HTTPS

PeerCastIM: Commit


Commit MetaInfo

Revisão839c86e734dfad34410c5ca28a1d8c3dba0f68cd (tree)
Hora2008-09-07 15:25:32
Autoreru <eru01@user...>
Commitereru

Mensagem de Log

GUIのリモホ逆引き不能バグを修正

Mudança Sumário

Diff

--- a/PeerCast.root/PeerCast/core/common/version2.h
+++ b/PeerCast.root/PeerCast/core/common/version2.h
@@ -45,8 +45,8 @@ extern int version_ex; // PP
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
4747 static const int PCP_CLIENT_VERSION_EX_NUMBER = 28;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0028-2)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0028-2)";
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0028-3)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0028-3)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/PeerCast.root/PeerCast/ui/win32/simple/gui.cpp
+++ b/PeerCast.root/PeerCast/ui/win32/simple/gui.cpp
@@ -22,6 +22,9 @@
2222
2323 #define _WIN32_WINNT 0x0500
2424
25+#include "ws2tcpip.h" // getnameinfo
26+#include "wspiapi.h" // compatibility for Win2k and earlier
27+
2528 #include <windows.h>
2629 #include "stdio.h"
2730 #include "string.h"
@@ -111,29 +114,88 @@ bool gbAllOpen = false;
111114 THREAD_PROC GetHostName(ThreadInfo *thread){
112115 IdData *id = (IdData*)(thread->data);
113116
114- HOSTENT *he;
115- unsigned int ip;
117+ //HOSTENT *he;
118+ u_long ip;
119+ struct sockaddr_in sa;
120+ char host[256];
121+ char *tmp;
116122 bool flg = TRUE;
123+ bool findFlg;
124+ int error;
117125
118126 ip = htonl(id->getIpAddr());
119127
120- for (int i=0; i<5 && flg; i++){
121- he = gethostbyaddr((char *)&ip,sizeof(ip),AF_INET);
128+ memset(&sa, 0, sizeof(sa));
129+ sa.sin_addr.S_un.S_addr = ip;
130+ sa.sin_family = AF_INET;
131+
132+ for (int i=0; i<10 && flg; i++){
133+ error = getnameinfo(reinterpret_cast<sockaddr*>(&sa), sizeof(sa), host, sizeof(host)/sizeof(host[0]), NULL, 0, NI_NAMEREQD);
134+ switch (error)
135+ {
136+ case 0:
137+ // success
138+ flg = FALSE;
139+ break;
140+
141+ case WSAHOST_NOT_FOUND:
142+ LOG_ERROR("cannot resolve host for %s",
143+ ((tmp = inet_ntoa(sa.sin_addr)) ? tmp : ""));
144+ flg = TRUE;
145+ break;
146+
147+ default:
148+ LOG_ERROR("an error occurred while resolving hostname of %s (%ld)",
149+ ((tmp = inet_ntoa(sa.sin_addr)) ? tmp : ""), error);
150+ }
151+ }
152+
153+ if (error)
154+ return 0;
122155
156+ for (flg=TRUE, findFlg=FALSE; flg; )
157+ {
123158 ChannelDataLock.on();
124159 ChannelData* cd = channelDataTop;
125- if (he)
126- {
127- while(cd){
128- if (cd->setName(id->getServentId(), he->h_name)){
160+
161+ while(cd){
162+ if (cd->getChannelId() == id->getChannelId())
163+ {
164+ findFlg = TRUE;
165+
166+ if (cd->findServentData(id->getServentId()))
167+ {
168+ if (cd->setName(id->getServentId(), host))
169+ {
170+ LOG_DEBUG("successfully resolved(%d)", id->getServentId());
171+ flg = FALSE;
172+ break;
173+ } else
174+ {
175+ LOG_ERROR("cannot update servent data with resolved information");
176+ flg = FALSE;
177+ break;
178+ }
179+ } else
180+ {
181+ LOG_DEBUG("servent data has been removed");
129182 flg = FALSE;
130183 break;
131184 }
132- cd = cd->getNextData();
133185 }
186+
187+ cd = cd->getNextData();
134188 }
189+
135190 // ::delete id;
136191 ChannelDataLock.off();
192+
193+ if (!findFlg)
194+ {
195+ LOG_DEBUG("servent data has been removed(channel)");
196+ flg = FALSE;
197+ }
198+
137199 sys->sleep(1000);
138200 }
139201
@@ -925,10 +987,12 @@ THREAD_PROC GUIDataUpdate(ThreadInfo *thread){
925987 cd->addServentData(sv);
926988 // ホスト名を取得する
927989 IdData *id = ::new IdData(cd->getChannelId(), sv->getServentId(), sv->getHost().ip);
928- ThreadInfo t;
929- t.func = GetHostName;
930- t.data = (void*)id;
931- sys->startThread(&t);
990+ ThreadInfo *t;
991+ t = ::new ThreadInfo();
992+ t->func = GetHostName;
993+ t->data = (void*)id;
994+ sys->startThread(t);
995+ LOG_DEBUG("resolving thread was started(%d)", id->getServentId());
932996 // ループ終了
933997 break;
934998 }
--- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
@@ -45,8 +45,8 @@ extern int version_ex; // PP
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
4747 static const int PCP_CLIENT_VERSION_EX_NUMBER = 28;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0028-2)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0028-2)";
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0028-3)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0028-3)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/gui.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/gui.cpp
@@ -22,6 +22,9 @@
2222
2323 #define _WIN32_WINNT 0x0500
2424
25+#include "ws2tcpip.h" // getnameinfo
26+#include "wspiapi.h" // compatibility for Win2k and earlier
27+
2528 #include <windows.h>
2629 #include "stdio.h"
2730 #include "string.h"
@@ -111,29 +114,88 @@ bool gbAllOpen = false;
111114 THREAD_PROC GetHostName(ThreadInfo *thread){
112115 IdData *id = (IdData*)(thread->data);
113116
114- HOSTENT *he;
115- unsigned int ip;
117+ //HOSTENT *he;
118+ u_long ip;
119+ struct sockaddr_in sa;
120+ char host[256];
121+ char *tmp;
116122 bool flg = TRUE;
123+ bool findFlg;
124+ int error;
117125
118126 ip = htonl(id->getIpAddr());
119127
120- for (int i=0; i<5 && flg; i++){
121- he = gethostbyaddr((char *)&ip,sizeof(ip),AF_INET);
128+ memset(&sa, 0, sizeof(sa));
129+ sa.sin_addr.S_un.S_addr = ip;
130+ sa.sin_family = AF_INET;
131+
132+ for (int i=0; i<10 && flg; i++){
133+ error = getnameinfo(reinterpret_cast<sockaddr*>(&sa), sizeof(sa), host, sizeof(host)/sizeof(host[0]), NULL, 0, NI_NAMEREQD);
134+ switch (error)
135+ {
136+ case 0:
137+ // success
138+ flg = FALSE;
139+ break;
140+
141+ case WSAHOST_NOT_FOUND:
142+ LOG_ERROR("cannot resolve host for %s",
143+ ((tmp = inet_ntoa(sa.sin_addr)) ? tmp : ""));
144+ flg = TRUE;
145+ break;
146+
147+ default:
148+ LOG_ERROR("an error occurred while resolving hostname of %s (%ld)",
149+ ((tmp = inet_ntoa(sa.sin_addr)) ? tmp : ""), error);
150+ }
151+ }
152+
153+ if (error)
154+ return 0;
122155
156+ for (flg=TRUE, findFlg=FALSE; flg; )
157+ {
123158 ChannelDataLock.on();
124159 ChannelData* cd = channelDataTop;
125- if (he)
126- {
127- while(cd){
128- if (cd->setName(id->getServentId(), he->h_name)){
160+
161+ while(cd){
162+ if (cd->getChannelId() == id->getChannelId())
163+ {
164+ findFlg = TRUE;
165+
166+ if (cd->findServentData(id->getServentId()))
167+ {
168+ if (cd->setName(id->getServentId(), host))
169+ {
170+ LOG_DEBUG("successfully resolved(%d)", id->getServentId());
171+ flg = FALSE;
172+ break;
173+ } else
174+ {
175+ LOG_ERROR("cannot update servent data with resolved information");
176+ flg = FALSE;
177+ break;
178+ }
179+ } else
180+ {
181+ LOG_DEBUG("servent data has been removed");
129182 flg = FALSE;
130183 break;
131184 }
132- cd = cd->getNextData();
133185 }
186+
187+ cd = cd->getNextData();
134188 }
189+
135190 // ::delete id;
136191 ChannelDataLock.off();
192+
193+ if (!findFlg)
194+ {
195+ LOG_DEBUG("servent data has been removed(channel)");
196+ flg = FALSE;
197+ }
198+
137199 sys->sleep(1000);
138200 }
139201
@@ -925,10 +987,12 @@ THREAD_PROC GUIDataUpdate(ThreadInfo *thread){
925987 cd->addServentData(sv);
926988 // ホスト名を取得する
927989 IdData *id = ::new IdData(cd->getChannelId(), sv->getServentId(), sv->getHost().ip);
928- ThreadInfo t;
929- t.func = GetHostName;
930- t.data = (void*)id;
931- sys->startThread(&t);
990+ ThreadInfo *t;
991+ t = ::new ThreadInfo();
992+ t->func = GetHostName;
993+ t->data = (void*)id;
994+ sys->startThread(t);
995+ LOG_DEBUG("resolving thread was started(%d)", id->getServentId());
932996 // ループ終了
933997 break;
934998 }
Show on old repository browser