Browse Source

- Added a missing map_quit in clif_parse which was the real reason for the crashes.
- Therefore, removed the session valid checks from intif.c
- Thanks for Flavio for figuring out how to reproduce the crash. And unthanks to me for introducing it on the first place D:
- Note: Every connection before being closed and free'd will set eof to 1 and invoke the parse function (clif_parse for players), and since this is the last invocation, it is clif_parse's job to do any cleanup necessary. The missing map_quit what did was to leave the player pointer reference in different db's, which lead to a dangling pointer! Which obviously leads to no good. The map server's code should always ensure that session[sd->fd]->session_data == sd ALL the time (except when sd->fd is 0).
- Finally, not writing any of this on the txt changelog file so Flavio can have the glory of the bugfix :B


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9368 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 18 years ago
parent
commit
7f67461a49
2 changed files with 7 additions and 11 deletions
  1. 2 1
      src/map/clif.c
  2. 5 10
      src/map/intif.c

+ 2 - 1
src/map/clif.c

@@ -11826,13 +11826,14 @@ int clif_parse(int fd) {
 					(pc_isGM(sd))?"GM ":"",sd->status.name);
 			} else
 			if (sd->state.auth) {
-				clif_quitsave(fd, sd); // the function doesn't send to inter-server/char-server if it is not connected [Yor]
 				 // Player logout display [Valaris]
 				ShowInfo("%sCharacter '"CL_WHITE"%s"CL_RESET"' logged off.\n",
 					(pc_isGM(sd))?"GM ":"",sd->status.name);
+				clif_quitsave(fd, sd);
 			} else {
 				ShowInfo("Player AID:%d/CID:%d (not authenticated) logged off.\n",
 					sd->bl.id, sd->char_id);
+				map_quit(sd);
 			}
 		} else {
 			unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;

+ 5 - 10
src/map/intif.c

@@ -934,8 +934,7 @@ int intif_parse_Registers(int fd) {
 	int *qty;
 	RFIFOHEAD(fd);
 
-	if( (sd=map_id2sd(RFIFOL(fd,4)))==NULL ||
-			!session_isValid(sd->fd)) // Invalid session
+	if( (sd=map_id2sd(RFIFOL(fd,4)))==NULL)
 		return 1;
 
 	if (RFIFOB(fd,12) == 3 && sd->status.char_id != RFIFOL(fd,8))
@@ -992,9 +991,8 @@ int intif_parse_LoadStorage(int fd) {
 		return 1;
 	}
 
-	if (sd->state.finalsave || //Player is already scheduled to leave the server.
-			!session_isValid(sd->fd)) // Invalid session
-		return 1;
+	if (sd->state.finalsave)
+		return 1; //Player is already scheduled to leave the server.
 
 	stor = account2storage( RFIFOL(fd,4));
 
@@ -1049,9 +1047,7 @@ int intif_parse_LoadGuildStorage(int fd)
 		if(battle_config.error_log)
 			ShowError("intif_parse_LoadGuildStorage: user not found %d\n",RFIFOL(fd,4));
 		return 1;
-	} else if(!session_isValid(sd->fd))
-		return 1; // Invalid session
-	
+	}
 	gstor=guild2storage(guild_id);
 	if(!gstor) {
 		if(battle_config.error_log)
@@ -1424,8 +1420,7 @@ int intif_parse_RenamePetOk(int fd)
 	struct map_session_data *sd = NULL;
 	RFIFOHEAD(fd);
 	if((sd=map_id2sd(RFIFOL(fd,2)))==NULL ||
-		sd->status.char_id != RFIFOL(fd,6) ||
-		!session_isValid(sd->fd)) // Invalid session
+		sd->status.char_id != RFIFOL(fd,6))
 		return 0;
 	if (RFIFOB(fd,10) == 0) {
 		clif_displaymessage(sd->fd, msg_txt(280)); // You cannot use this name for your pet.