PennMUSH Community

Changeset 952

Show
Ignore:
Timestamp:
06/17/07 17:45:09 (1 year ago)
Author:
shawnw
Message:

#7315: KEEPALIVE flag

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/devel/CHANGES.182

    r931 r952  
    1717Version 1.8.2 patchevel 6                       ???  ??, 2007 
    1818 
     19Minor changes: 
     20  * KEEPALIVE flag makes the server send a telnet NOP after 
     21    a short period of inactivity; helps prevent timeouts from 
     22    NAT/router devices with a short timeout. [MUX] 
     23 
    1924Fixes: 
    2025  * Fixed assorted small memory leaks. [SW] 
     26  * Fixed handling of telnet NOPs sent by clients. [SW] 
    2127 
    2228Version 1.8.2 patchlevel 5                      June 13, 2007 
  • 1.8.3/branches/devel/game/mushcnf.dst

    r790 r952  
    214214# the internet, and don't deal well with persistant connections like 
    215215# mushes use. This option will make the server automatically send a 
    216 # 'Are you still there?' query every few minutes to keep the 
     216# TCP-level 'Are you still there?' query every few minutes to keep the 
    217217# connection active. 
    218218# NOTE: This doesn't work on all OSes, but does on the most popular 
    219 # ones for mush hosting such as linux. 
     219# ones for mush hosting such as linux. Other options include the KEEPALIVE 
     220# flag and the IDLE command. 
    220221keepalive_timeout 5m 
    221222 
  • 1.8.3/branches/devel/game/txt/hlp/pennflag.hlp

    r802 r952  
    5151  d - Destroy_Ok        e - Enter_Ok            g - Gagged 
    5252  h - Halt              i - Orphan              j - Jury_Ok              
    53   l - Light             m - Myopic, Mistrust    n - No_Command           
    54   o - On-Vacation       p - Puppet, Paranoid    r - Royalty              
    55   s - Suspect           t - Transparent         u - Uninspected          
    56   v - Verbose           w - No_Warn             x - Terse, Cloudy        
    57   ? - Unregistered      ^ - Listen_Parent       ~ - Noaccents 
    58   " - NoSpoof 
     53  k - Keepalive         l - Light               m - Myopic, Mistrust 
     54  n - No_Command        o - On-Vacation         p - Puppet, Paranoid 
     55  r - Royalty           s - Suspect             t - Transparent 
     56  u - Uninspected       v - Verbose             w - No_Warn 
     57  x - Terse, Cloudy     ? - Unregistered        ^ - Listen_Parent 
     58  ~ - Noaccents         " - NoSpoof 
    5959----------------------------------------------------------------------- 
    6060Some flags may not be enabled on some MUSHes. @flag/list will show 
     
    402402  When a room is set JUMP_OK, then that room can be teleported into 
    403403  by anyone. See @teleport. 
     404& KEEPALIVE 
     405  Flag: KEEPALIVE (players) 
     406 
     407  When this flag is set on a player with a telnet-capable connection, 
     408  a telnet NOP (no-operation) is sent after there's been no activity 
     409  on the connection for a minute, to generate socket activity without 
     410  generating any output. In a way, it's the opposite of the IDLE 
     411  command. IDLE is sent by clients to keep a connection open, while 
     412  KEEPALIVE tells the server to send a message. Both are intended for 
     413  use by people going through home router/NAT appliances with short 
     414  inactivity timeouts. 
     415 
     416See also: IDLE, terminfo() 
    404417& LIGHT 
    405418  Flag:  LIGHT (all types) 
  • 1.8.3/branches/devel/hdrs/mushtype.h

    r905 r952  
    129129  unsigned char *raw_input;     /**< Pointer to start of next raw input */ 
    130130  unsigned char *raw_input_at;  /**< Pointer to position in raw input */ 
    131   long connected_at;    /**< Time of connection */ 
    132   long last_time;       /**< Time of last activity */ 
     131  time_t connected_at;    /**< Time of connection */ 
     132  time_t last_time;       /**< Time of last activity */ 
    133133  int quota;            /**< Quota of commands allowed */ 
    134134  int cmds;             /**< Number of commands sent */ 
  • 1.8.3/branches/devel/hdrs/switches.h

    r950 r952  
    154154#define SWITCH_YES 151 
    155155#define SWITCH_ZONE 152 
    156 #endif /* SWITCHES_H */ 
     156#endif                          /* SWITCHES_H */ 
  • 1.8.3/branches/devel/src/bsd.c

    r945 r952  
    17891789    } 
    17901790    break; 
    1791   case NOP:                    /* No-op */ 
     1791  case NOP: 
     1792    /* No-op */ 
    17921793    if (*q >= qend) 
    17931794      return -1; 
     
    17951796    fprintf(stderr, "Got IAC NOP\n"); 
    17961797#endif 
     1798    *q++; 
    17971799    break; 
    17981800  case AYT:                    /* Are you there? */ 
     
    26272629    if (d->player == player) { 
    26282630      numd++; 
    2629       if (now - d->last_time > 60) 
     2631      if (difftime(now, d->last_time) > 60.0) 
    26302632        in = d; 
    26312633    } 
     
    40864088{ 
    40874089  DESC *d, *nextd; 
    4088   time_t now, idle, idle_for, unconnected_idle
    4089   if (!INACTIVITY_LIMIT && !UNCONNECTED_LIMIT) 
    4090     return; 
     4090  time_t now
     4091  int idle, idle_for, unconnected_idle; 
     4092 
    40914093  now = mudtime; 
    40924094  idle = INACTIVITY_LIMIT ? INACTIVITY_LIMIT : INT_MAX; 
     
    40944096  for (d = descriptor_list; d; d = nextd) { 
    40954097    nextd = d->next; 
    4096     idle_for = now - d->last_time; 
     4098    idle_for = (int) difftime(now, d->last_time); 
     4099 
    40974100    /* If they've been connected for 60 seconds without getting a telnet-option 
    40984101       back, the client probably doesn't understand them */ 
    4099     if ((d->conn_flags & CONN_TELNET_QUERY) && idle_for > 60) 
     4102    if (d->conn_flags & CONN_TELNET_QUERY 
     4103        && difftime(now, d->connected_at) >= 60.0) 
    41004104      d->conn_flags &= ~CONN_TELNET_QUERY; 
     4105 
     4106    /* If they've been idle for 60 seconds and are set KEEPALIVE and using 
     4107       a telnet-aware client, send a NOP */ 
     4108    if (d->conn_flags & CONN_TELNET && idle_for >= 60 
     4109        && IS(d->player, TYPE_PLAYER, "KEEPALIVE")) { 
     4110      const uint8_t nopmsg[2] = { IAC, NOP }; 
     4111      queue_newwrite(d, nopmsg, 2); 
     4112      process_output(d); 
     4113    } 
     4114 
    41014115    if ((d->connected) ? (idle_for > idle) : (idle_for > unconnected_idle)) { 
    41024116 
  • 1.8.3/branches/devel/src/csrimalloc.c

    r945 r952  
    970970#ifdef CSRI_TRACE 
    971971/* Tracing malloc definitions - helps find leaks */ 
    972 univptr_t trace__malloc 
    973 _((size_t nbytes, const char *fname, int linenum)); 
    974 univptr_t trace__calloc 
    975 _((size_t nelem, size_t elsize, const char *fname, int linenum)); 
    976 univptr_t trace__realloc 
    977 _((univptr_t cp, size_t nbytes, const char *fname, int linenum)); 
    978     univptr_t trace__valloc _((size_t size, const char *fname, int linenum)); 
    979 univptr_t trace__memalign 
    980 _((size_t alignment, size_t size, const char *fname, int linenum)); 
    981     univptr_t trace__emalloc _((size_t nbytes, const char *fname, int linenum)); 
     972    univptr_t 
     973      trace__malloc 
     974    _((size_t nbytes, const char *fname, int linenum)); 
     975    univptr_t 
     976      trace__calloc 
     977    _((size_t nelem, size_t elsize, const char *fname, int linenum)); 
     978    univptr_t 
     979      trace__realloc 
     980    _((univptr_t cp, size_t nbytes, const char *fname, int linenum)); 
     981    univptr_t trace__valloc 
     982    _((size_t size, const char *fname, int linenum)); 
     983    univptr_t 
     984      trace__memalign 
     985    _((size_t alignment, size_t size, const char *fname, int linenum)); 
     986    univptr_t trace__emalloc 
     987    _((size_t nbytes, const char *fname, int linenum)); 
    982988univptr_t 
    983989  trace__ecalloc _((size_t nelem, size_t sz, const char *fname, int linenum)); 
     990univptr_t trace__erealloc 
     991_((univptr_t ptr, size_t nbytes, const char *fname, int linenum)); 
     992    char *trace__strdup _((const char *s, const char *fname, int linenum)); 
     993    char *trace__strsave _((const char *s, const char *fname, int linenum)); 
     994    void 
     995     trace__free _((univptr_t cp, const char *fname, int linenum)); 
     996    void 
     997     trace__cfree _((univptr_t cp, const char *fname, int linenum)); 
     998#else                           /* CSRI_TRACE */ 
    984999    univptr_t 
    985       trace__erealloc 
    986     _((univptr_t ptr, size_t nbytes, const char *fname, int linenum)); 
    987     char * 
    988       trace__strdup 
    989     _((const char *s, const char *fname, int linenum)); 
    990     char * 
    991       trace__strsave 
    992     _((const char *s, const char *fname, int linenum)); 
     1000      malloc 
     1001    _((size_t nbytes)); 
     1002    univptr_t 
     1003      calloc 
     1004    _((size_t nelem, size_t elsize)); 
     1005    univptr_t 
     1006      realloc 
     1007    _((univptr_t cp, size_t nbytes)); 
     1008    univptr_t 
     1009      valloc 
     1010    _((size_t size)); 
     1011    univptr_t 
     1012      memalign 
     1013    _((size_t alignment, size_t size)); 
     1014    univptr_t 
     1015      emalloc 
     1016    _((size_t nbytes)); 
     1017    univptr_t 
     1018      ecalloc 
     1019    _((size_t nelem, size_t sz)); 
     1020    univptr_t 
     1021      erealloc 
     1022    _((univptr_t ptr, size_t nbytes)); 
     1023    Free_t free 
     1024    _((univptr_t cp)); 
     1025    Free_t cfree 
     1026    _((univptr_t cp)); 
     1027#endif                          /* CSRI_TRACE */ 
     1028 
     1029    int 
     1030      __m_botch 
     1031    _((const char *s1, const char *s2, univptr_t p, 
     1032       int is_end_ptr, const char *filename, int linenumber)); 
    9931033    void 
    994     trace__fre
    995     _((univptr_t cp, const char *fname, int linenum)); 
     1034    __m_prnod
     1035    _((SPBLK * spblk)); 
    9961036    void 
    997     trace__cfree 
    998     _((univptr_t cp, const char *fname, int linenum)); 
    999 #else                           /* CSRI_TRACE */ 
    1000 univptr_t malloc 
    1001 _((size_t nbytes)); 
    1002 univptr_t calloc 
    1003 _((size_t nelem, size_t elsize)); 
    1004 univptr_t realloc 
    1005 _((univptr_t cp, size_t nbytes)); 
    1006 univptr_t valloc 
    1007 _((size_t size)); 
    1008 univptr_t memalign 
    1009 _((size_t alignment, size_t size)); 
    1010 univptr_t emalloc 
    1011 _((size_t nbytes)); 
    1012 univptr_t ecalloc 
    1013 _((size_t nelem, size_t sz)); 
    1014 univptr_t erealloc 
    1015 _((univptr_t ptr, size_t nbytes)); 
    1016     Free_t free _((univptr_t cp)); 
    1017     Free_t cfree _((univptr_t cp)); 
    1018 #endif                          /* CSRI_TRACE */ 
    1019  
    1020     int 
    1021      __m_botch 
    1022       _((const char *s1, const char *s2, univptr_t p, 
    1023          int is_end_ptr, const char *filename, int linenumber)); 
    1024     void 
    1025      __m_prnode _((SPBLK * spblk)); 
    1026     void 
    1027      mal_contents _((FILE * fp)); 
     1037    mal_contents 
     1038    _((FILE * fp)); 
    10281039#ifdef CSRI_DEBUG 
    10291040    void 
    1030      mal_debug _((int level)); 
     1041    mal_debug 
     1042    _((int level)); 
    10311043    int 
    1032      mal_verify _((int fullcheck)); 
     1044    mal_verify 
     1045    _((int fullcheck)); 
    10331046#endif 
    10341047    void 
    1035      mal_dumpleaktrace _((FILE * fp)); 
     1048    mal_dumpleaktrace 
     1049    _((FILE * fp)); 
    10361050    void 
    1037      mal_heapdump _((FILE * fp)); 
     1051    mal_heapdump 
     1052    _((FILE * fp)); 
    10381053    void 
    1039      mal_leaktrace _((int value)); 
     1054    mal_leaktrace 
     1055    _((int value)); 
    10401056    void 
    1041      mal_sbrkset _((int n)); 
     1057    mal_sbrkset 
     1058    _((int n)); 
    10421059    void 
    1043      mal_slopset _((int n)); 
     1060    mal_slopset 
     1061    _((int n)); 
    10441062#ifdef CSRI_PROFILESIZES 
    10451063    void 
    1046      mal_statsdump _((FILE * fp)); 
     1064    mal_statsdump 
     1065    _((FILE * fp)); 
    10471066#endif 
    10481067    void 
    1049      mal_trace _((int value)); 
     1068    mal_trace 
     1069    _((int value)); 
    10501070    void 
    1051      mal_mmap _((char *fname)); 
     1071    mal_mmap 
     1072    _((char *fname)); 
    10521073 
    10531074#ifdef CSRI_TRACE 
  • 1.8.3/branches/devel/src/flags.c

    r950 r952  
    145145  {"GOING_TWICE", '\0', NOTYPE, GOING_TWICE, F_INTERNAL | F_DARK, 
    146146   F_INTERNAL | F_DARK}, 
     147  {"KEEPALIVE", 'k', TYPE_PLAYER, 0, F_ANY, F_ANY}, 
    147148  {NULL, '\0', 0, 0, 0, 0} 
    148149}; 
     
    861862 
    862863  if (n->tab == &ptab_flag) { 
     864    add_flag("KEEPALIVE", 'k', TYPE_PLAYER, F_ANY, F_ANY); 
    863865    add_flag("MISTRUST", 'm', TYPE_THING | TYPE_EXIT | TYPE_ROOM, F_INHERIT, 
    864866             F_INHERIT); 
  • 1.8.3/branches/devel/src/mysocket.c

    r905 r952  
    375375 
    376376  /* And set the ping time to something reasonable instead of the 
    377      default 2 hours. Linux, NetBSD and o thers use TCP_KEEPIDLE to do 
     377     default 2 hours. Linux and possibly others use TCP_KEEPIDLE to do 
    378378     this. OS X and possibly others use TCP_KEEPALIVE. */ 
    379379#if defined(TCP_KEEPIDLE)