PennMUSH Community

Changeset 1187

Show
Ignore:
Timestamp:
01/02/08 06:49:03 (8 months ago)
Author:
shawnw
Message:

#7525: Basic inotify based file tracking.

Files:

Legend:

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

    r1186 r1187  
    55chronological order (most recent first) 
    66 
    7 [SW] is Shawn Wagner, a PennMUSH developer (aka Raevnos) 
     7[SW] is Shawn Wagner, a PennMUSH developer (aka Raevnos), also 
     8 responsible for most unattributed changes. 
    89[EEH] is Ervin Hearn III, a PennMUSH developer (aka Noltar) 
    910[GM] is Greg Millam, a PennMUSH developer (aka Walker) 
     
    2223 * Compile with -mdynamic-no-pic on powerpc OS X, resulting in a smaller 
    2324   binary. 
     25 * On newer Linux systems, detect when various indexed and cached files 
     26   are changed and automatically reload them instead of waiting for a  
     27   @readcache. 
     28 
     29Fixes: 
     30 * Fixes from 1.8.2p9 
    2431 
    2532Version 1.8.3 patchlevel 6                      Jan 01, 2008 
     
    7784 * Fixed some minor bugs detected by running under valgrind. 
    7885 * OpenBSD configuration fixes. 
     86 * Fixes from 1.8.2p8 
    7987 
    8088Version 1.8.3 patchlevel 5                      October 6, 2007 
  • 1.8.3/branches/devel/config.h.in

    r1143 r1187  
    7272 
    7373#undef HAVE_SYS_SELECT_H 
     74 
     75#undef HAVE_SYS_INOTIFY_H 
    7476 
    7577/* C99ish headers. The first two are really really nice to have. */ 
     
    303305#undef HAVE_FCNTL 
    304306 
     307#undef HAVE_INOTIFY_INIT 
     308 
     309#ifdef HAVE_INOTIFY_INIT 
     310#define HAVE_INOTIFY 
     311#endif 
     312 
    305313/* Variables and defines */ 
    306314 
  • 1.8.3/branches/devel/configure

    r1186 r1187  
    74957495 
    74967496 
    7497 for ac_header in poll.h sys/epoll.h sys/select.h 
     7497 
     7498for ac_header in poll.h sys/epoll.h sys/select.h sys/inotify.h 
    74987499do 
    74997500as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 
     
    1481414815 
    1481514816 
    14816 for ac_func in fcntl pselect poll ppoll pollts kqueue epoll_ctl 
     14817 
     14818for ac_func in fcntl pselect poll ppoll pollts kqueue epoll_ctl inotify_init 
    1481714819do 
    1481814820as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` 
  • 1.8.3/branches/devel/configure.in

    r1186 r1187  
    117117AC_CHECK_HEADER(sys/types.h, [AC_DEFINE(I_SYS_TYPES)]) 
    118118AC_CHECK_HEADERS([sys/un.h ieeefp.h sys/resource.h sys/event.h sys/uio.h]) 
    119 AC_CHECK_HEADERS([poll.h sys/epoll.h sys/select.h]) 
     119AC_CHECK_HEADERS([poll.h sys/epoll.h sys/select.h sys/inotify.h]) 
    120120### C language support 
    121121# Only need to check C99 and GNU extensions 
     
    209209AC_CHECK_FUNCS([cbrt log2 getuid geteuid seteuid getpriority setpriority]) 
    210210AC_CHECK_FUNCS([socketpair sigaction sigprocmask imaxdiv valloc writev]) 
    211 AC_CHECK_FUNCS([fcntl pselect poll ppoll pollts kqueue epoll_ctl]) 
     211AC_CHECK_FUNCS([fcntl pselect poll ppoll pollts kqueue epoll_ctl inotify_init]) 
    212212 
    213213AC_FUNC_SNPRINTF 
  • 1.8.3/branches/devel/game/txt/connect.txt

    r258 r1187  
    99Use the WHO command to find out who is online currently. 
    1010----------------------------------------------------------------------------- 
    11 Yell at your local god to personalize this file! 
    1211 
  • 1.8.3/branches/devel/game/txt/hlp/pennv182.hlp

    r1177 r1187  
     1& 1.8.2p9 
     2Version 1.8.2 patchlevel 9                     ??? ??, 2008 
     3 
     4Functions: 
     5 * The undocumented (And unusable) orpowers() and andpowers() functions 
     6   were removed. 
     7 
     8Documentation: 
     9 * andlpowers() and orlpowers() were missing help files. Reported by 
     10   Parusso. 
     11 
    112& 1.8.2p8 
    213Version 1.8.2 patchlevel 8                     Jan 01, 2008 
  • 1.8.3/branches/devel/game/txt/hlp/pennv183.hlp

    r1166 r1187  
    1 & 1.8.3p6 
     1& 1.8.3p7 
    22& changes 
    33This is a list of changes in this patchlevel which are probably of 
     
    1212be read in 'help patchlevels'. 
    1313 
     14Version 1.8.3 patchlevel 7                      ??? ??, 2008 
     15 
     16Minor changes: 
     17 * If compiling with a recent enough version of gcc to support the 
     18   -fstack-protector option to detect buffer overruns, use it. 
     19 * Compile with -mdynamic-no-pic on powerpc OS X, resulting in a smaller 
     20   binary. 
     21 * On newer Linux systems, detect when various indexed and cached files 
     22   are changed and automatically reload them instead of waiting for a  
     23   @readcache. 
     24 
     25Fixes: 
     26 * Fixes from 1.8.2p9 
     27 
     28& 1.8.3p6 
    1429Version 1.8.3 patchlevel 6                      Jan 01, 2008 
    1530 
     
    6681 * Fixed some minor bugs detected by running under valgrind. 
    6782 * OpenBSD configuration fixes. 
     83 * Fixes from 1.8.2p8 
    6884 
    6985& 1.8.3p5 
  • 1.8.3/branches/devel/game/txt/hlp/pennvOLD.hlp

    r1166 r1187  
    44184418type 'help <version>p<patchlevel>'. For example, 'help 1.7.2p3' 
    44194419 
    4420 1.8.3: 0, 1, 2, 3, 4, 5, 6 
    4421 1.8.2: 0, 1, 2, 3, 4, 5, 6, 7, 8 
     44201.8.3: 0, 1, 2, 3, 4, 5, 6, 7 
     44211.8.2: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 
    442244221.8.1: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 
    442344231.8.0: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 
  • 1.8.3/branches/devel/src/bsd.c

    r1159 r1187  
    8383#include <locale.h> 
    8484#include <setjmp.h> 
     85#ifdef HAVE_SYS_INOTIFY_H 
     86#include <sys/inotify.h> 
     87#endif 
    8588 
    8689#include "conf.h" 
     
    103106#include "mysocket.h" 
    104107#include "ident.h" 
     108#include "htab.h" 
     109#include "help.h" 
    105110 
    106111#ifndef WIN32 
     
    383388static char **saved_argv = NULL; 
    384389 
     390#ifdef HAVE_INOTIFY 
     391int file_watch_init(void); 
     392void file_watch_event(int); 
     393#endif 
     394 
    385395#ifndef BOOLEXP_DEBUGGING 
    386396#ifdef WIN32SERVICES 
     
    868878#endif 
    869879  unsigned long input_ready, output_ready; 
     880#ifdef HAVE_INOTIFY 
     881  int notify_fd = -1; 
     882#endif 
    870883 
    871884  if (!restarting) { 
     
    892905  do_rawlog(LT_ERR, "%d file descriptors available.", avail_descriptors); 
    893906  do_rawlog(LT_ERR, "RESTART FINISHED."); 
     907 
     908#ifdef HAVE_INOTIFY 
     909  notify_fd = file_watch_init(); 
     910#endif 
    894911 
    895912  our_gettimeofday(&then); 
     
    10021019        FD_SET(d->descriptor, &output_set); 
    10031020    } 
     1021 
     1022#ifdef HAVE_INOTIFY 
     1023    if (notify_fd >= 0) 
     1024      FD_SET(notify_fd, &input_set); 
     1025#endif 
    10041026 
    10051027    found = select(maxd, &input_set, &output_set, (fd_set *) 0, &timeout); 
     
    10871109      } 
    10881110#endif 
     1111#endif 
     1112#ifdef HAVE_INOTIFY 
     1113      if (notify_fd >= 0 && FD_ISSET(notify_fd, &input_set)) 
     1114    file_watch_event(notify_fd); 
    10891115#endif 
    10901116      for (d = descriptor_list; d; d = dnext) { 
     
    46944720  exit(1);                      /* Shouldn't ever get here, but just in case... */ 
    46954721} 
     4722 
     4723 
     4724#ifdef HAVE_INOTIFY 
     4725/* File modification watching code. Linux-specific for now.  
     4726 * Future directions include: kqueue() for BSD, fam for linux, irix, others? 
     4727 * 
     4728 * The idea to watch help.txt and motd.txt and friends to avoid having 
     4729 * to do a manual @readcache. Rather than figuring out which exact 
     4730 * file was changed, just re-read them all on modification of 
     4731 * any. That will probably change in the future. 
     4732 */ 
     4733 
     4734extern HASHTAB help_files; 
     4735 
     4736static void 
     4737watch_files(int fd) 
     4738{ 
     4739  int n; 
     4740  help_file *h; 
     4741 
     4742#define WATCH(name) do { \ 
     4743    if (inotify_add_watch(fd, (name), IN_MODIFY | IN_DELETE_SELF) < 0) \ 
     4744      do_rawlog(LT_TRACE, "file_watch_init:inotify_add_watch(\"%s\"): %s", \ 
     4745        (name), strerror(errno)); \ 
     4746  } while (0); 
     4747       
     4748  for (n = 0; n < 2; n++) { 
     4749    WATCH(options.connect_file[n]); 
     4750    WATCH(options.motd_file[n]); 
     4751    WATCH(options.wizmotd_file[n]); 
     4752    WATCH(options.register_file[n]); 
     4753    WATCH(options.quit_file[n]); 
     4754    WATCH(options.down_file[n]); 
     4755    WATCH(options.full_file[n]); 
     4756    WATCH(options.guest_file[n]); 
     4757  } 
     4758   
     4759  for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files))  
     4760    WATCH(h->file); 
     4761 
     4762#undef WATCH 
     4763} 
     4764 
     4765/** Start monitoring various useful files for changes.  
     4766 * \return descriptor of the notification service, or -1 on error 
     4767 */ 
     4768int 
     4769file_watch_init(void) 
     4770{ 
     4771  int fd = inotify_init(); 
     4772  
     4773 if (fd < 0) { 
     4774    penn_perror("file_watch_init:inotify_init"); 
     4775    return -1; 
     4776  } 
     4777 
     4778  if (fd >= maxd) 
     4779    maxd = fd + 1; 
     4780 
     4781  watch_files(fd); 
     4782 
     4783  make_nonblocking(fd); 
     4784 
     4785  return fd; 
     4786} 
     4787 
     4788/** Test for modified files and re-read them if indicated.  
     4789 * \param fd the notification monitorh descriptor 
     4790 */ 
     4791void 
     4792file_watch_event(int fd) 
     4793{ 
     4794  struct inotify_event ev; 
     4795 
     4796  while (read(fd, &ev, sizeof ev) > 0) { 
     4797    if (ev.mask != IN_IGNORED) { 
     4798      do_rawlog(LT_TRACE, 
     4799        "Reloading help indexes and cached files after detecting a change."); 
     4800      fcache_load(NOTHING); 
     4801      help_reindex(NOTHING); 
     4802      watch_files(fd); 
     4803    } 
     4804  } 
     4805} 
     4806 
     4807#endif 
  • 1.8.3/branches/devel/src/conf.c

    r1150 r1187  
    16971697#endif 
    16981698 
    1699   notify(player, T(" BSD sockets networking in use.")); 
    1700  
    17011699#ifdef HAS_GETDATE 
    17021700  notify(player, T(" Extended convtime() is supported.")); 
     
    17111709#endif 
    17121710 
    1713 
     1711#ifdef HAVE_INOTIFY 
     1712  notify(player, 
     1713     T(" Changed help files will be automatically reindexed.")); 
     1714#endif 
     1715 
     1716 
     1717 
     1718