--- deliantra/server/socket/loop.C 2006/12/16 03:08:26 1.20 +++ deliantra/server/socket/loop.C 2006/12/16 03:21:08 1.21 @@ -49,9 +49,17 @@ #include #define MAX_QUEUE_DEPTH 500 //TODO +#define MAX_QUEUE_BACKLOG 2 //TODO -//TODO: cannot use this, as it might ignore vital commands such as fire_stop -#define MAX_QUEUE_BACKLOG 1e99 //TODO +void +client::reset_state () +{ + if (!pl) + return; + + pl->run_on = 0; + pl->fire_on = 0; +} void client::queue_command (packet_type *handler, char *data, int datalen) @@ -59,11 +67,16 @@ tstamp stamp = now (); if (cmd_queue.size () >= MAX_QUEUE_DEPTH) - //TODO: just disconnect here? - send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); + { + //TODO: just disconnect here? + reset_state (); + send_packet_printf ("drawinfo %d command queue overflow, ignoring.", NDI_RED); + } else if (!cmd_queue.empty () && cmd_queue.front ().stamp + MAX_QUEUE_BACKLOG < stamp) - //TODO: do fire_stop and other things that might be necessary - send_packet_printf ("drawinfo %d too many commands in queue, ignoring.", NDI_RED); + { + reset_state (); + send_packet_printf ("drawinfo %d too many commands in queue, ignoring.", NDI_RED); + } else cmd_queue.push_back (command ( stamp, handler, (char *)salloc (datalen, data), datalen @@ -82,8 +95,10 @@ command &cmd = cmd_queue.front (); if (cmd.stamp + MAX_QUEUE_BACKLOG < now ()) - //TODO: do fire_stop and other things that might be necessary - send_packet_printf ("drawinfo %d ignoring delayed command.", NDI_RED); + { + reset_state (); + send_packet_printf ("drawinfo %d ignoring delayed command.", NDI_RED); + } else execute (cmd.handler, cmd.data, cmd.datalen);