summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorDennis Friis <peavey@inspircd.org>2009-07-07 00:52:08 +0200
committerDennis Friis <peavey@inspircd.org>2009-07-07 00:55:31 +0200
commit4673fd3ca06010e74f8223486b0f34e58c7b0a7e (patch)
treecfcc97752fd770eb1befa295e16f7aa4a2607ca9 /src/map/clif.c
parent03b5e644857f80a23bd8b856b78a10cf0a564a66 (diff)
downloadtmwa-4673fd3ca06010e74f8223486b0f34e58c7b0a7e.tar.gz
tmwa-4673fd3ca06010e74f8223486b0f34e58c7b0a7e.tar.bz2
tmwa-4673fd3ca06010e74f8223486b0f34e58c7b0a7e.tar.xz
tmwa-4673fd3ca06010e74f8223486b0f34e58c7b0a7e.zip
Fixes to socket system to make it cope better with fd depletion.
Also added timeout for fullconnect, secured map server from stateless connections.
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 1f88ed8..9357084 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8339,9 +8339,18 @@ static void (*clif_parse_func_table[0x220])() = {
static int clif_parse(int fd) {
int packet_len = 0, cmd=0;
struct map_session_data *sd=NULL;
-
+
sd = session[fd]->session_data;
+ if (!sd || (sd && !sd->state.auth)) {
+ if (RFIFOREST(fd) < 2) { // too small a packet disconnect
+ session[fd]->eof = 1;
+ }
+ if (RFIFOW(fd,0) != 0x72) { // first packet not auth, disconnect
+ session[fd]->eof = 1;
+ }
+ }
+
// �ڑ����؂��Ă��̂Ō��n��
if (!chrif_isconnect() || session[fd]->eof) { // char�I�Ɍq����ĂȂ��Ԃ͐ڑ��֎~ (!chrif_isconnect())
if (sd && sd->state.auth) {
@@ -8433,7 +8442,7 @@ static int clif_parse(int fd) {
} else if (sd) // not authentified! (refused by char-server or disconnect before to be authentified)
printf("\nAccount ID %d.\n", sd->bl.id);
- if ((fp = fopen(packet_txt, "a")) == NULL) {
+ if ((fp = fopen_(packet_txt, "a")) == NULL) {
printf("clif.c: cant write [%s] !!! data is lost !!!\n", packet_txt);
return 1;
} else {
@@ -8454,7 +8463,7 @@ static int clif_parse(int fd) {
fprintf(fp, "%02X ", RFIFOB(fd,i));
}
fprintf(fp, "\n\n");
- fclose(fp);
+ fclose_(fp);
}
}
#endif