[pkg-ggz-commits] r264 - in ggz-server/trunk/debian: . patches

josef-guest at alioth.debian.org josef-guest at alioth.debian.org
Thu Nov 15 21:37:20 UTC 2007


Author: josef-guest
Date: 2007-11-15 21:37:20 +0000 (Thu, 15 Nov 2007)
New Revision: 264

Added:
   ggz-server/trunk/debian/patches/ggzd-timetype.diff
   ggz-server/trunk/debian/patches/misc.diff
Modified:
   ggz-server/trunk/debian/changelog
Log:
- merge more upstream 0.0.14-branch patches into the package



Modified: ggz-server/trunk/debian/changelog
===================================================================
--- ggz-server/trunk/debian/changelog	2007-11-15 20:11:42 UTC (rev 263)
+++ ggz-server/trunk/debian/changelog	2007-11-15 21:37:20 UTC (rev 264)
@@ -1,3 +1,14 @@
+ggz-server (0.0.14-3) UNRELEASED; urgency=low
+
+  * Included 0.0.14-branch patch: ggzd-timetype.diff
+    - Fixes the logging interval and uptime reports
+  * Included 0.0.14-branch patch: misc.diff
+    - Fixes card shuffling in ggzcards
+    - Fixes debugging to not use open network sockets
+    - Terminates password in ggzduedit correctly
+
+ -- Josef Spillner <josef at ggzgamingzone.org>  Thu, 15 Nov 2007 22:30:57 +0100
+
 ggz-server (0.0.14-2) unstable; urgency=low
 
   [ Josef Spillner ]

Added: ggz-server/trunk/debian/patches/ggzd-timetype.diff
===================================================================
--- ggz-server/trunk/debian/patches/ggzd-timetype.diff	                        (rev 0)
+++ ggz-server/trunk/debian/patches/ggzd-timetype.diff	2007-11-15 21:37:20 UTC (rev 264)
@@ -0,0 +1,143 @@
+Index: ggzd/ggzd/err_func.c
+===================================================================
+--- ggzd/ggzd/err_func.c	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/ggzd/err_func.c	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -68,8 +68,8 @@
+ static struct {
+ 	pthread_mutex_t mut;
+ 	int update_interval;
+-	time_t start_time;
+-	time_t next_update;
++	ggztime_t start_time;
++	ggztime_t next_update;
+ 	int anon_users;
+ 	int regd_users;
+ 	int num_logins;
+@@ -261,8 +261,8 @@
+ 	}
+ 
+ 	pthread_mutex_init(&update_info.mut, NULL);
+-	update_info.next_update = time(NULL) + update_info.update_interval;
+-	update_info.start_time = time(NULL);
++	update_info.next_update = get_current_time();
++	update_info.start_time = get_current_time();
+ 	update_info.anon_users = 0;
+ 	update_info.regd_users = 0;
+ 	update_info.num_logins = 0;
+@@ -324,27 +324,35 @@
+ 
+ 
+ /* Return number of seconds until next update log entry */
+-int log_next_update_sec(void)
++ggztime_t log_next_update_sec(void)
+ {
+-	int max_select_wait;
++	ggztime_t max_select_wait;
+ 
+-	if((max_select_wait = update_info.next_update - time(NULL)) < 1)
+-		max_select_wait = 0;
++	if (update_info.update_interval <= 0) {
++		return 10000.0;
++	}
+ 
+-	return max_select_wait;
++	max_select_wait = update_info.next_update - get_current_time();
++
++	return MAX(max_select_wait, 0.0);
+ }
+ 
+ 
+ /* Generate an update log entry */
+ void log_generate_update(void)
+ {
+-	int uptime;
++	ggztime_t uptime;
+ 	int anon, regd, login, logout;
+ 	int tables, tables_created, tables_closed;
+ 
++	if (update_info.update_interval <= 0
++	    || update_info.next_update > get_current_time()) {
++		return;
++	}
++
+ 	/* Not in critical section (only our thread uses these) */
+-	uptime = time(NULL) - update_info.start_time;
+-	update_info.next_update = time(NULL) + update_info.update_interval;
++	uptime = get_current_time() - update_info.start_time;
++	update_info.next_update = get_current_time() + update_info.update_interval;
+ 
+ 	pthread_mutex_lock(&update_info.mut);
+ 
+@@ -371,7 +379,7 @@
+ 
+ #ifdef DEBUG
+ 	if(log_info.verbose_updates) {
+-		log_msg(GGZ_LOG_UPDATE, "UPDATE Uptime=%d sec", uptime);
++		log_msg(GGZ_LOG_UPDATE, "UPDATE Uptime=%d sec", (int)uptime);
+ 		log_msg(GGZ_LOG_UPDATE, "UPDATE There are %d anonymous users and %d registered users online", anon, regd);
+ 		log_msg(GGZ_LOG_UPDATE, "UPDATE Since the last update, %d users have logged in, %d logged out", login, logout);
+ 		log_msg(GGZ_LOG_UPDATE, "UPDATE There are %d tables open", tables);
+@@ -380,7 +388,7 @@
+ 	} else
+ #endif
+ 		log_msg(GGZ_LOG_UPDATE, "UPDATE %d %d %d %d %d %d %d %d",
+-			uptime, anon, regd, login, logout, tables, tables_created, tables_closed);
++			(int)uptime, anon, regd, login, logout, tables, tables_created, tables_closed);
+ }
+ 
+ 
+Index: ggzd/ggzd/err_func.h
+===================================================================
+--- ggzd/ggzd/err_func.h	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/ggzd/err_func.h	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -99,10 +99,11 @@
+ void logfile_initialize(void);
+ 
+ /* Log a normal message */
+-void log_msg(const unsigned, const char *, ...);
++void log_msg(const unsigned, const char *, ...)
++             ggz__attribute((format(printf, 2, 3)));
+ 
+ /* Update log handlers */
+-int log_next_update_sec(void);
++ggztime_t log_next_update_sec(void);
+ void log_generate_update(void);
+ void log_login_anon(void);
+ void log_login_regd(void);
+Index: ggzd/ggzd/control.c
+===================================================================
+--- ggzd/ggzd/control.c	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/ggzd/control.c	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -559,7 +559,6 @@
+ 	struct sockaddr_in addr;
+ 	fd_set active_fd_set, read_fd_set;
+ 	struct timeval tv, *tvp;
+-	int seconds;
+ 
+ 	logfile_preinitialize();
+ 
+@@ -671,17 +670,13 @@
+ 		}
+ 
+ 		read_fd_set = active_fd_set;
+-		seconds = log_next_update_sec();
+-		if(seconds == 0)
+-		{
+-			tvp = NULL;
+-		}
+-		else
+-		{
+-			tv.tv_sec = seconds;
+-			tv.tv_usec = 0;
+-			tvp = &tv;
+-		}
++
++		/* May be 0 seconds if the update interval has passed -
++		   in this case the select will likely terminate immediately
++		   and the update will be done. */
++		tv = ggztime_to_timeval(log_next_update_sec());
++		tvp = &tv;
++
+ 		status = select((select_max + 1), &read_fd_set, NULL, NULL, tvp);
+ 
+ 		if (status < 0) {

Added: ggz-server/trunk/debian/patches/misc.diff
===================================================================
--- ggz-server/trunk/debian/patches/misc.diff	                        (rev 0)
+++ ggz-server/trunk/debian/patches/misc.diff	2007-11-15 21:37:20 UTC (rev 264)
@@ -0,0 +1,108 @@
+Index: ggzd/game_servers/ggzcards/deck.c
+===================================================================
+--- ggzd/game_servers/ggzcards/deck.c	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/game_servers/ggzcards/deck.c	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -155,6 +155,21 @@
+ 	return deck->size;
+ }
+ 
++/* Returns a random number in the range 0..size-1. */
++static unsigned int myrand(unsigned int size)
++{
++	const unsigned int divisor = RAND_MAX / size;
++	const unsigned int max = size * divisor - 1;
++	unsigned int new_rand;
++
++	/* Avoid bias. */
++	do {
++		new_rand = random();
++	} while (new_rand > max);
++
++	return new_rand / divisor;
++}
++
+ /* shuffle the deck */
+ void shuffle_deck(deck_t * deck)
+ {
+@@ -163,12 +178,11 @@
+ 
+ 	ggz_debug(DBG_MISC, "Shuffling deck.");
+ 
+-	/* Now we can randomize the deck order */
+-	/* Go through the deck, card by card */
++	/* "Knuth shuffle" */
+ 	for (i = 0; i < deck->size; i++) {
+ 		/* Pick any position */
+-		j = random() % deck->size;
+-		
++		j = i + myrand(deck->size - i);
++
+ 		/* And swap positions */
+ 		temp = deck->cards[i];
+ 		deck->cards[i] = deck->cards[j];
+Index: ggzd/game_servers/ggzcards/net.c
+===================================================================
+--- ggzd/game_servers/ggzcards/net.c	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/game_servers/ggzcards/net.c	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -536,8 +536,9 @@
+ static void net_send_newhand(player_t p)
+ {
+ 	GGZDataIO *dio = get_player_dio(p);
+-	seat_t dlr =
+-	    game.dealer >= 0 ? game.players[game.dealer].seat : -1;
++	seat_t dlr = (game.dealer >= 0
++		      ? CONVERT_SEAT(game.players[game.dealer].seat, p)
++		      : -1);
+ 
+ 	ggz_dio_packet_start(dio);
+ 	write_opcode(dio, MSG_NEWHAND);
+Index: ggzd/ggzd/err_func.c
+===================================================================
+--- ggzd/ggzd/err_func.c	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/ggzd/err_func.c	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -309,9 +309,9 @@
+ 	char pidname[strlen(fname) + 9];
+ 
+ 	if(!strcmp("stderr", fname)) {
+-			return stderr;
++		return opt.foreground ? stderr : NULL;
+ 	} else if(!strcmp("stdout", fname)) {
+-			return stdout;
++		return opt.foreground ? stdout : NULL;
+ 	}
+ 
+ 	if(log_info.options & GGZ_LOGOPT_THREAD_LOGS) {
+Index: ggzd/ggzd/net.c
+===================================================================
+--- ggzd/ggzd/net.c	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/ggzd/net.c	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -236,7 +236,7 @@
+ 	}
+ 	
+ 	if (strcmp(filename, "stderr") == 0)
+-		net->dump_file = STDERR_FILENO;
++		net->dump_file = opt.foreground ? STDERR_FILENO : -1;
+ 	else
+ 		net->dump_file = open(filename,
+ 				      O_WRONLY|O_CREAT|O_TRUNC, S_IRWXU);
+@@ -1062,7 +1062,7 @@
+ 			return GGZ_REQ_OK;
+ 		}
+ 
+-		dbg_msg(GGZ_DBG_CONNECTION, "Network error reading data");
++		dbg_msg(GGZ_DBG_CONNECTION, "Network error reading data (%d)", errno);
+ 		return GGZ_REQ_DISCONNECT;
+ 	}
+ 
+Index: ggzd/ggzd/ggzduedit.c
+===================================================================
+--- ggzd/ggzd/ggzduedit.c	(.../tags/ggz-0-0-14/ggzd)	(revision 9355)
++++ ggzd/ggzd/ggzduedit.c	(.../branches/ggz-0-0-14/ggzd)	(revision 9355)
+@@ -471,6 +471,7 @@
+ 					fgets(password, sizeof(password), stdin);
+ 					echomode(1);
+ 					printf("\n");
++					password[strlen(password) - 1] = '\0';
+ 					optarg = password;
+ 				}
+ 				conn.password = optarg;




More information about the pkg-ggz-commits mailing list