Changeset 1195
- Timestamp:
- 01/03/08 02:43:46 (1 year ago)
- Files:
-
- 1.8.3/branches/devel/config.h.in (modified) (1 diff)
- 1.8.3/branches/devel/configure (modified) (2 diffs)
- 1.8.3/branches/devel/configure.in (modified) (2 diffs)
- 1.8.3/branches/devel/game/restart (modified) (1 diff)
- 1.8.3/branches/devel/src/bsd.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/devel/config.h.in
r1187 r1195 74 74 75 75 #undef HAVE_SYS_INOTIFY_H 76 77 #undef HAVE_FAM_H 78 79 #undef HAVE_LIBFAM 76 80 77 81 /* C99ish headers. The first two are really really nice to have. */ 1.8.3/branches/devel/configure
r1187 r1195 7496 7496 7497 7497 7498 for ac_header in poll.h sys/epoll.h sys/select.h sys/inotify.h 7498 7499 for ac_header in poll.h sys/epoll.h sys/select.h sys/inotify.h fam.h 7499 7500 do 7500 7501 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` … … 11850 11851 fi 11851 11852 11853 11854 11855 { echo "$as_me:$LINENO: checking for FAMOpen in -lfam" >&5 11856 echo $ECHO_N "checking for FAMOpen in -lfam... $ECHO_C" >&6; } 11857 if test "${ac_cv_lib_fam_FAMOpen+set}" = set; then 11858 echo $ECHO_N "(cached) $ECHO_C" >&6 11859 else 11860 ac_check_lib_save_LIBS=$LIBS 11861 LIBS="-lfam $LIBS" 11862 cat >conftest.$ac_ext <<_ACEOF 11863 /* confdefs.h. */ 11864 _ACEOF 11865 cat confdefs.h >>conftest.$ac_ext 11866 cat >>conftest.$ac_ext <<_ACEOF 11867 /* end confdefs.h. */ 11868 11869 /* Override any GCC internal prototype to avoid an error. 11870 Use char because int might match the return type of a GCC 11871 builtin and then its argument prototype would still apply. */ 11872 #ifdef __cplusplus 11873 extern "C" 11874 #endif 11875 char FAMOpen (); 11876 int 11877 main () 11878 { 11879 return FAMOpen (); 11880 ; 11881 return 0; 11882 } 11883 _ACEOF 11884 rm -f conftest.$ac_objext conftest$ac_exeext 11885 if { (ac_try="$ac_link" 11886 case "(($ac_try" in 11887 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 11888 *) ac_try_echo=$ac_try;; 11889 esac 11890 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 11891 (eval "$ac_link") 2>conftest.er1 11892 ac_status=$? 11893 grep -v '^ *+' conftest.er1 >conftest.err 11894 rm -f conftest.er1 11895 cat conftest.err >&5 11896 echo "$as_me:$LINENO: \$? = $ac_status" >&5 11897 (exit $ac_status); } && { 11898 test -z "$ac_c_werror_flag" || 11899 test ! -s conftest.err 11900 } && test -s conftest$ac_exeext && 11901 $as_test_x conftest$ac_exeext; then 11902 ac_cv_lib_fam_FAMOpen=yes 11903 else 11904 echo "$as_me: failed program was:" >&5 11905 sed 's/^/| /' conftest.$ac_ext >&5 11906 11907 ac_cv_lib_fam_FAMOpen=no 11908 fi 11909 11910 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ 11911 conftest$ac_exeext conftest.$ac_ext 11912 LIBS=$ac_check_lib_save_LIBS 11913 fi 11914 { echo "$as_me:$LINENO: result: $ac_cv_lib_fam_FAMOpen" >&5 11915 echo "${ECHO_T}$ac_cv_lib_fam_FAMOpen" >&6; } 11916 if test $ac_cv_lib_fam_FAMOpen = yes; then 11917 cat >>confdefs.h <<_ACEOF 11918 #define HAVE_LIBFAM 1 11919 _ACEOF 11920 11921 LIBS="-lfam $LIBS" 11922 11923 fi 11852 11924 11853 11925 1.8.3/branches/devel/configure.in
r1187 r1195 117 117 AC_CHECK_HEADER(sys/types.h, [AC_DEFINE(I_SYS_TYPES)]) 118 118 AC_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 sys/inotify.h ])119 AC_CHECK_HEADERS([poll.h sys/epoll.h sys/select.h sys/inotify.h fam.h]) 120 120 ### C language support 121 121 # Only need to check C99 and GNU extensions … … 156 156 AC_CHECK_LIB(crypt, crypt) 157 157 LIB_SOCKET_NSL 158 AC_CHECK_LIB(fam, FAMOpen) 158 159 159 160 # with_ssl=set 1.8.3/branches/devel/game/restart
r954 r1195 155 155 export DATEMSK 156 156 157 export GAMEDIR 158 157 159 LC_ALL=$LANG LANG=$LANG ./netmush $@ $GAMEDIR/$CONF_FILE & 1.8.3/branches/devel/src/bsd.c
r1194 r1195 85 85 #ifdef HAVE_SYS_INOTIFY_H 86 86 #include <sys/inotify.h> 87 #endif 88 #ifdef HAVE_FAM_H 89 #include <fam.h> 87 90 #endif 88 91 … … 388 391 static char **saved_argv = NULL; 389 392 390 #ifdef HAVE_INOTIFY391 393 int file_watch_init(void); 392 394 void file_watch_event(int); 393 #endif394 395 395 396 #ifndef BOOLEXP_DEBUGGING … … 878 879 #endif 879 880 unsigned long input_ready, output_ready; 880 #ifdef HAVE_INOTIFY881 881 int notify_fd = -1; 882 #endif883 882 884 883 if (!restarting) { … … 906 905 do_rawlog(LT_ERR, "RESTART FINISHED."); 907 906 908 #ifdef HAVE_INOTIFY909 907 notify_fd = file_watch_init(); 910 #endif911 908 912 909 our_gettimeofday(&then); … … 1020 1017 } 1021 1018 1022 #ifdef HAVE_INOTIFY1023 1019 if (notify_fd >= 0) 1024 1020 FD_SET(notify_fd, &input_set); 1025 #endif1026 1021 1027 1022 found = select(maxd, &input_set, &output_set, (fd_set *) 0, &timeout); … … 1110 1105 #endif 1111 1106 #endif 1112 #ifdef HAVE_INOTIFY 1107 1113 1108 if (notify_fd >= 0 && FD_ISSET(notify_fd, &input_set)) 1114 1109 file_watch_event(notify_fd); 1115 #endif 1110 1116 1111 for (d = descriptor_list; d; d = dnext) { 1117 1112 dnext = d->next; … … 4722 4717 4723 4718 4724 #ifdef HAVE_INOTIFY4725 4719 /* File modification watching code. Linux-specific for now. 4726 4720 * Future directions include: kqueue() for BSD, fam for linux, irix, others? … … 4735 4729 4736 4730 static void 4737 watch_files(int fd) 4731 reload_files(void) 4732 { 4733 do_rawlog(LT_TRACE, 4734 "Reloading help indexes and cached files after detecting a change."); 4735 fcache_load(NOTHING); 4736 help_reindex(NOTHING); 4737 } 4738 4739 #ifdef HAVE_INOTIFY 4740 /* Linux 2.6 and greater inotify() file monitoring interface */ 4741 4742 static void 4743 watch_files_in(int fd) 4738 4744 { 4739 4745 int n; … … 4747 4753 } while (0) 4748 4754 4749 4750 4755 do_rawlog(LT_TRACE, 4751 4756 "'No such file or directory' errors immediately following are probably harmless."); … … 4767 4772 } 4768 4773 4769 /** Start monitoring various useful files for changes. 4770 * \return descriptor of the notification service, or -1 on error 4771 */ 4772 int 4773 file_watch_init(void) 4774 static int 4775 file_watch_init_in(void) 4774 4776 { 4775 4777 int fd = inotify_init(); 4776 4778 4777 4779 if (fd < 0) { 4778 4780 penn_perror("file_watch_init:inotify_init"); … … 4783 4785 maxd = fd + 1; 4784 4786 4785 watch_files (fd);4787 watch_files_in(fd); 4786 4788 4787 4789 make_nonblocking(fd); … … 4790 4792 } 4791 4793 4792 /** Test for modified files and re-read them if indicated. 4793 * \param fd the notification monitorh descriptor 4794 */ 4795 void 4796 file_watch_event(int fd) 4794 static void 4795 file_watch_event_in(int fd) 4797 4796 { 4798 4797 struct inotify_event ev; … … 4801 4800 do_rawlog(LT_TRACE, "Got event. Flags: 0x%x", ev.mask); 4802 4801 if (ev.mask != IN_IGNORED) { 4803 do_rawlog(LT_TRACE, 4804 "Reloading help indexes and cached files after detecting a change."); 4805 fcache_load(NOTHING); 4806 help_reindex(NOTHING); 4807 watch_files(fd); 4808 } 4809 } 4810 } 4811 4812 #endif 4802 reload_files(); 4803 watch_files_in(fd); 4804 } 4805 } 4806 } 4807 4808 #elif defined(HAVE_LIBFAM) 4809 /* libfam monitoring interface */ 4810 4811 static FAMConnection famc; 4812 4813 static int 4814 file_watch_init_fam(void) 4815 { 4816 int n; 4817 help_file *h; 4818 FAMRequest famr; 4819 const char *gamedir; 4820 4821 memset(&famc, 0, sizeof famc); 4822 4823 gamedir = getenv("GAMEDIR"); 4824 if (!gamedir) { 4825 do_rawlog(LT_TRACE, 4826 "file_watch_init: Unable to get GAMEDIR environment variable."); 4827 return -1; 4828 } 4829 4830 if (FAMOpen(&famc) < 0) { 4831 do_rawlog(LT_TRACE, "file_watch_init: FAMOpen: %s", FamErrlist[FAMErrno]); 4832 return -1; 4833 } 4834 4835 #define WATCH(name) do { \ 4836 const char *fullname = tprintf("%s/%s", gamedir, (name)); \ 4837 do_rawlog(LT_TRACE, "Watching %s", fullname); \ 4838 if (FAMMonitorFile(&famc, fullname, &famr, NULL) < 0) \ 4839 do_rawlog(LT_TRACE, "file_watch_init:FAMMonitorFile(\"%s\"): %s", \ 4840 (name), FamErrlist[FAMErrno]); \ 4841 } while (0) 4842 4843 do_rawlog(LT_TRACE, 4844 "'No such file or directory' errors immediately following are probably harmless."); 4845 for (n = 0; n < 2; n++) { 4846 WATCH(options.connect_file[n]); 4847 WATCH(options.motd_file[n]); 4848 WATCH(options.wizmotd_file[n]); 4849 WATCH(options.register_file[n]); 4850 WATCH(options.quit_file[n]); 4851 WATCH(options.down_file[n]); 4852 WATCH(options.full_file[n]); 4853 WATCH(options.guest_file[n]); 4854 } 4855 4856 for (h = hash_firstentry(&help_files); h; h = hash_nextentry(&help_files)) 4857 WATCH(h->file); 4858 4859 #undef WATCH 4860 4861 return FAMCONNECTION_GETFD(&famc); 4862 } 4863 4864 static void 4865 file_watch_event_fam(void) 4866 { 4867 do_rawlog(LT_TRACE, "In file_watch_event_fam()"); 4868 4869 while (FAMPending(&famc)) { 4870 FAMEvent famev; 4871 4872 memset(&famev, 0, sizeof famev); 4873 4874 if (FAMNextEvent(&famc, &famev) < 0) { 4875 do_rawlog(LT_TRACE, "file_watch_event: FAMNextEvent: %s", 4876 FamErrlist[FAMErrno]); 4877 break; 4878 } 4879 4880 do_rawlog(LT_TRACE, "Code is: %d for %s", famev.code, famev.filename); 4881 4882 switch (famev.code) { 4883 case FAMChanged: 4884 case FAMDeleted: 4885 reload_files(); 4886 break; 4887 default: 4888 break; 4889 } 4890 } 4891 } 4892 4893 #endif 4894 4895 /** Start monitoring various useful files for changes. 4896 * \return descriptor of the notification service, or -1 on error 4897 */ 4898 int 4899 file_watch_init(void) 4900 { 4901 #ifdef HAVE_INOTIFY 4902 return file_watch_init_in(); 4903 #elif defined(HAVE_LIBFAM) 4904 return file_watch_init_fam(); 4905 #else 4906 return -1; 4907 #endif 4908 } 4909 4910 /** Test for modified files and re-read them if indicated. 4911 * \param fd the notification monitorh descriptor 4912 */ 4913 void 4914 file_watch_event(int fd __attribute__((__unused__))) 4915 { 4916 #ifdef HAVE_INOTIFY 4917 file_watch_event_in(fd); 4918 #elif defined(HAVE_LIBFAM) 4919 file_watch_event_fam(); 4920 #endif 4921 return; 4922 }
