Separate login_grace_time from max_idle
max_idle applies in state PS_PLAYING, login_grace_time before (login, state PS_INIT) and after (logout, state PS_SHUTDOWN). Cut login_grace_time to two minutes, from max_idle's 15. Two minutes is plenty to complete login and logout. Makes swamping the server with connections slightly harder, as they get dropped faster. While that makes sense all by itself, the real aim is making increasing max_idle safe. The next commit will complete that job.
This commit is contained in:
parent
fb9595fe6a
commit
1a97cc3cfd
7 changed files with 23 additions and 19 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Marc Olzheim, 2004
|
* Marc Olzheim, 2004
|
||||||
* Markus Armbruster, 2004-2011
|
* Markus Armbruster, 2004-2012
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -200,6 +200,8 @@ EMPCFBOTH("max_btus", max_btus, int, NSC_INT, 0,
|
||||||
"Maximum number of BTUs a country can have")
|
"Maximum number of BTUs a country can have")
|
||||||
EMPCFBOTH("max_idle", max_idle, int, NSC_INT, 0,
|
EMPCFBOTH("max_idle", max_idle, int, NSC_INT, 0,
|
||||||
"Maximum number of minutes a player can sit idle while logged in")
|
"Maximum number of minutes a player can sit idle while logged in")
|
||||||
|
EMPCFBOTH("login_grace_time", login_grace_time, int, NSC_INT, 0,
|
||||||
|
"Grace time for clients to complete login and logout (seconds)")
|
||||||
EMPCFBOTH("players_at_00", players_at_00, int, NSC_INT, 0,
|
EMPCFBOTH("players_at_00", players_at_00, int, NSC_INT, 0,
|
||||||
"Players have their coordinate system at deity 0,0 (0 - no, 1 - yes)")
|
"Players have their coordinate system at deity 0,0 (0 - no, 1 - yes)")
|
||||||
EMPCFBOTH("at_least_one_100", at_least_one_100, int, NSC_INT, KM_INTERNAL,
|
EMPCFBOTH("at_least_one_100", at_least_one_100, int, NSC_INT, KM_INTERNAL,
|
||||||
|
|
|
@ -338,6 +338,7 @@ extern struct player *player_next(struct player *);
|
||||||
extern struct player *player_prev(struct player *);
|
extern struct player *player_prev(struct player *);
|
||||||
extern struct player *getplayer(natid);
|
extern struct player *getplayer(natid);
|
||||||
extern void player_accept(void *);
|
extern void player_accept(void *);
|
||||||
|
extern time_t player_io_deadline(struct player *, int);
|
||||||
/* dispatch.c */
|
/* dispatch.c */
|
||||||
extern int dispatch(char *, char *);
|
extern int dispatch(char *, char *);
|
||||||
/* empdis.c */
|
/* empdis.c */
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Ken Stevens, 1995
|
* Ken Stevens, 1995
|
||||||
* Steve McClure, 1996
|
* Steve McClure, 1996
|
||||||
* Markus Armbruster, 2004-2011
|
* Markus Armbruster, 2004-2012
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -65,6 +65,7 @@ char *game_days = ""; /* days game is running */
|
||||||
char *game_hours = ""; /* hours game is running */
|
char *game_hours = ""; /* hours game is running */
|
||||||
char *pre_update_hook = "";
|
char *pre_update_hook = "";
|
||||||
int max_idle = 15; /* session dies after max_idle minutes idle */
|
int max_idle = 15; /* session dies after max_idle minutes idle */
|
||||||
|
int login_grace_time = 120; /* Grace time for completing login (sec) */
|
||||||
|
|
||||||
int sect_mob_max = 127; /* sector mobility limits */
|
int sect_mob_max = 127; /* sector mobility limits */
|
||||||
float sect_mob_scale = 1.0; /* accumulation multiplier */
|
float sect_mob_scale = 1.0; /* accumulation multiplier */
|
||||||
|
|
|
@ -99,7 +99,7 @@ player_delete(struct player *lp)
|
||||||
|
|
||||||
if (lp->iop) {
|
if (lp->iop) {
|
||||||
/* it's a real player */
|
/* it's a real player */
|
||||||
io_close(lp->iop, player->curup + minutes(max_idle));
|
io_close(lp->iop, player->curup + login_grace_time);
|
||||||
lp->iop = NULL;
|
lp->iop = NULL;
|
||||||
}
|
}
|
||||||
back = (struct player *)lp->queue.q_back;
|
back = (struct player *)lp->queue.q_back;
|
||||||
|
@ -152,6 +152,16 @@ getplayer(natid cnum)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time_t
|
||||||
|
player_io_deadline(struct player *pl, int write)
|
||||||
|
{
|
||||||
|
if (pl->may_sleep < (write ? PLAYER_SLEEP_FREELY : PLAYER_SLEEP_ON_INPUT))
|
||||||
|
return 0;
|
||||||
|
if (pl->state != PS_PLAYING)
|
||||||
|
return pl->curup + login_grace_time;
|
||||||
|
return pl->curup + minutes(max_idle);
|
||||||
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
void
|
void
|
||||||
player_accept(void *unused)
|
player_accept(void *unused)
|
||||||
|
|
|
@ -88,7 +88,7 @@ player_login(void *ud)
|
||||||
pr_id(player, C_INIT, "Empire server ready\n");
|
pr_id(player, C_INIT, "Empire server ready\n");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
deadline = player->curup + minutes(max_idle);
|
deadline = player_io_deadline(player, 0);
|
||||||
if (io_outputwaiting(player->iop)) {
|
if (io_outputwaiting(player->iop)) {
|
||||||
if (io_output(player->iop, deadline) <= 0)
|
if (io_output(player->iop, deadline) <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
|
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "journal.h"
|
#include "journal.h"
|
||||||
#include "optlist.h"
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
|
||||||
|
@ -81,20 +80,15 @@ recvclient(char *cmd, int size)
|
||||||
* Flush all queued output before potentially sleeping in
|
* Flush all queued output before potentially sleeping in
|
||||||
* io_input(), to make sure player sees the prompt.
|
* io_input(), to make sure player sees the prompt.
|
||||||
*/
|
*/
|
||||||
deadline = player->curup + minutes(max_idle);
|
deadline = player_io_deadline(player, 0);
|
||||||
if (player->may_sleep < PLAYER_SLEEP_ON_INPUT)
|
|
||||||
deadline = 0;
|
|
||||||
while (io_output(player->iop, deadline) > 0)
|
while (io_output(player->iop, deadline) > 0)
|
||||||
;
|
;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to receive some input. Need to check player->may_sleep
|
* Try to receive some input. Need to recompute deadline;
|
||||||
* again; command abortion during io_output() might have
|
* command abortion during io_output() might have changed it.
|
||||||
* changed it.
|
|
||||||
*/
|
*/
|
||||||
deadline = player->curup + minutes(max_idle);
|
deadline = player_io_deadline(player, 0);
|
||||||
if (player->may_sleep < PLAYER_SLEEP_ON_INPUT)
|
|
||||||
deadline = 0;
|
|
||||||
res = io_input(player->iop, deadline);
|
res = io_input(player->iop, deadline);
|
||||||
if (res > 0)
|
if (res > 0)
|
||||||
;
|
;
|
||||||
|
|
|
@ -58,7 +58,6 @@
|
||||||
#include "journal.h"
|
#include "journal.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "nat.h"
|
#include "nat.h"
|
||||||
#include "optlist.h"
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
|
@ -332,11 +331,8 @@ outid(struct player *pl, int n)
|
||||||
static void
|
static void
|
||||||
player_output_some(void)
|
player_output_some(void)
|
||||||
{
|
{
|
||||||
time_t deadline;
|
time_t deadline = player_io_deadline(player, 1);
|
||||||
|
|
||||||
deadline = player->curup + minutes(max_idle);
|
|
||||||
if (player->may_sleep != PLAYER_SLEEP_FREELY)
|
|
||||||
deadline = 0;
|
|
||||||
while (io_output_if_queue_long(player->iop, deadline) > 0)
|
while (io_output_if_queue_long(player->iop, deadline) > 0)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue