Author: cazfi Date: Tue Jan 6 21:38:31 2015 New Revision: 27562 URL: http://svn.gna.org/viewcvs/freeciv?rev=27562&view=rev Log: Do not queue messages for threaded AI player thread when it's not running.
See bug #23146 Modified: branches/S2_6/ai/threaded/taimsg.c branches/S2_6/ai/threaded/taiplayer.c branches/S2_6/ai/threaded/taiplayer.h Modified: branches/S2_6/ai/threaded/taimsg.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/threaded/taimsg.c?rev=27562&r1=27561&r2=27562&view=diff ============================================================================== --- branches/S2_6/ai/threaded/taimsg.c (original) +++ branches/S2_6/ai/threaded/taimsg.c Tue Jan 6 21:38:31 2015 @@ -26,7 +26,14 @@ void tai_send_msg(enum taimsgtype type, struct player *pplayer, void *data) { - struct tai_msg *msg = fc_malloc(sizeof(*msg)); + struct tai_msg *msg; + + if (!tai_thread_running()) { + /* No player thread to send messages to */ + return; + } + + msg = fc_malloc(sizeof(*msg)); msg->type = type; msg->plr = pplayer; Modified: branches/S2_6/ai/threaded/taiplayer.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/threaded/taiplayer.c?rev=27562&r1=27561&r2=27562&view=diff ============================================================================== --- branches/S2_6/ai/threaded/taiplayer.c (original) +++ branches/S2_6/ai/threaded/taiplayer.c Tue Jan 6 21:38:31 2015 @@ -262,7 +262,8 @@ } /************************************************************************** - Send message to thread. + Send message to thread. Be sure that thread is running so that messages + are not just piling up to the list without anybody reading them. **************************************************************************/ void tai_msg_to_thr(struct tai_msg *msg) { @@ -281,3 +282,11 @@ taireq_list_append(thrai.reqs_from.reqlist, req); taireq_list_release_mutex(thrai.reqs_from.reqlist); } + +/************************************************************************** + Return whether player thread is running +**************************************************************************/ +bool tai_thread_running(void) +{ + return thrai.thread_running; +} Modified: branches/S2_6/ai/threaded/taiplayer.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/threaded/taiplayer.h?rev=27562&r1=27561&r2=27562&view=diff ============================================================================== --- branches/S2_6/ai/threaded/taiplayer.h (original) +++ branches/S2_6/ai/threaded/taiplayer.h Tue Jan 6 21:38:31 2015 @@ -46,6 +46,8 @@ void tai_init_threading(void); +bool tai_thread_running(void); + void tai_player_alloc(struct ai_type *ait, struct player *pplayer); void tai_player_free(struct ai_type *ait, struct player *pplayer); void tai_control_gained(struct ai_type *ait,struct player *pplayer); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits