Просмотр исходного кода

* Fixed memory corruption when amount of players online approached FD_SETSIZE (topic:262388, bugreport:4856, since r11897).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14781 54d463be-8e91-2dee-dedb-b68131a5f0ec
ai4rei 14 лет назад
Родитель
Сommit
953ddef5bb
2 измененных файлов с 2 добавлено и 4 удалено
  1. 1 0
      Changelog-Trunk.txt
  2. 1 4
      src/common/socket.c

+ 1 - 0
Changelog-Trunk.txt

@@ -1,6 +1,7 @@
 Date	Added
 
 2011/04/08
+	* Fixed memory corruption when amount of players online approached FD_SETSIZE (topic:262388, bugreport:4856, since 11897). [Ai4rei]
 	* Fixed a compile error when socket send shortlists are disabled (s->eof instead of s->flag.eof) (follow up to r11930). [Ai4rei]
 2011/04/07
 	* Fixed monster skill associated emotions were always ignored when having less than three digits ( = all ) (bugreport:4842). [Ai4rei]

+ 1 - 4
src/common/socket.c

@@ -1351,9 +1351,6 @@ void send_shortlist_do_sends()
 {
 	int i = 0;
 
-	// Assume all or most of the fd's don't remain in the shortlist
-	memset(send_shortlist_set, 0, sizeof(send_shortlist_set));
-
 	while( i < send_shortlist_count )
 	{
 		int fd = send_shortlist_array[i];
@@ -1375,7 +1372,6 @@ void send_shortlist_do_sends()
 			// be sent from it we'll keep it in the shortlist.
 			if( session[fd] && !session[fd]->flag.eof && session[fd]->wdata_size )
 			{
-				send_shortlist_set[fd/32] |= 1<<(fd%32);
 				++i;
 				continue;
 			}
@@ -1383,6 +1379,7 @@ void send_shortlist_do_sends()
 
 		// Remove fd from shortlist, move the last fd to the current position
 		send_shortlist_array[i] = send_shortlist_array[--send_shortlist_count];
+		send_shortlist_set[fd/32]&=~(1<<(fd%32));
 	}
 }
 #endif