Changeset 5619:16fe78ec277c in roaraudio


Ignore:
Timestamp:
08/09/12 00:01:15 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Implemented watchdog (Closes: #291)

Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5618 r5619  
    44        * Converted roard's protocol-irc plugin to CPI (Closes: #295) 
    55        * Updated protocol magic numbers (See: #262) 
     6        * Implemented watchdog (Closes: #291) 
    67 
    78v. 1.0beta4 - Mon Aug 06 2012 16:43 CEST 
  • include/libroar/libroar.h

    r5517 r5619  
    188188#include "asyncctl.h" 
    189189#include "kstore.h" 
     190#include "watchdog.h" 
    190191 
    191192// some basic macros: 
     
    245246 ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE, 
    246247#define ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE ROAR_FATAL_ERROR_MEMORY_DOUBLE_FREE 
     248 ROAR_FATAL_ERROR_WATCHDOG, 
     249#define ROAR_FATAL_ERROR_WATCHDOG ROAR_FATAL_ERROR_WATCHDOG 
    247250 
    248251 ROAR_FATAL_ERROR_EOL 
  • include/libroar/roarfeatures.h

    r5609 r5619  
    6565#define ROAR_FT_FEATURE_COMMON_PROTO /* see #257 */ 
    6666#define ROAR_FT_FEATURE_SELECTOR_HANDLING /* see #285 */ 
     67#define ROAR_FT_FEATURE_WATCHDOG /* see #291 */ 
    6768 
    6869// libroar2 features: 
  • libroar/Makefile

    r5529 r5619  
    1111PASSWORD=passwordapi.o pinentry.o sshaskpass.o 
    1212CRYPTO=crypto.o random.o $(HASHES) crc.o 
    13 OBJS=libroar.o config.o debug.o error.o basic.o stream.o client.o simple.o auth.o socket.o ctl.o buffer.o meta.o file.o acl.o cdrom.o $(PASSWORD) $(VIO) stack.o slp.o nnode.o roardl.o plugincontainer.o roarx11.o beep.o proto.o env.o keyval.o vs.o ltm.o notify.o notify_proxy.o asyncctl.o enumdev.o serverinfo.o $(CRYPTO) authfile.o caps.o roarfloat.o base64.o trap.o memmgr.o time.o kstore.o uuid.o 
     13OBJS=libroar.o config.o debug.o error.o basic.o stream.o client.o simple.o auth.o socket.o ctl.o buffer.o meta.o file.o acl.o cdrom.o $(PASSWORD) $(VIO) stack.o slp.o nnode.o roardl.o plugincontainer.o roarx11.o beep.o proto.o env.o keyval.o vs.o ltm.o notify.o notify_proxy.o asyncctl.o enumdev.o serverinfo.o $(CRYPTO) authfile.o caps.o roarfloat.o base64.o trap.o memmgr.o time.o kstore.o uuid.o watchdog.o 
    1414 
    1515#DEFINES        = -DDEBUG 
  • libroar/basic.c

    r5608 r5619  
    9191  return -1; 
    9292 } else if ( r == 0 ) { // we are the child 
     93  roar_watchdog_stop(); 
     94 
    9395  close(socks[0]); 
    9496 
     
    113115  // we are still alive? 
    114116  ROAR_ERR("_start_server(*): alive after exec(), that's bad!"); 
    115   _exit(1); 
     117  ROAR_U_EXIT(1); 
    116118 } else { // we are the parent 
    117119  close(socks[1]); 
  • libroar/cdrom.c

    r5381 r5619  
    3636#include "libroar.h" 
    3737 
    38 #define ROAR_CDROM_ERROR_NORETURN(format, args...) ROAR_ERR(format, ## args); _exit(3) 
     38#define ROAR_CDROM_ERROR_NORETURN(format, args...) ROAR_ERR(format, ## args); ROAR_U_EXIT(3) 
    3939 
    4040#if BYTE_ORDER == BIG_ENDIAN 
  • libroar/libroar.c

    r5390 r5619  
    107107 struct timespec left; 
    108108 
    109  if ( t > (uint_least32_t)1000000 ) { 
     109 if ( t >= (uint_least32_t)1000000 ) { 
    110110  tv.tv_sec  = t/(uint_least32_t)1000000; 
    111111  t         -= tv.tv_sec*(uint_least32_t)1000000; 
     
    321321    errname = "Memory double freed"; 
    322322   break; 
     323  case ROAR_FATAL_ERROR_WATCHDOG: 
     324    errname = "Watchdog Timeout"; 
     325   break; 
    323326  default: 
    324327    errname = "<unknown error code, BAD>"; 
     
    332335#endif 
    333336 abort(); 
     337#ifdef ROAR_HAVE_U_EXIT 
     338 ROAR_U_EXIT(1); 
     339#endif 
    334340 
    335341 while(1); 
  • libroar/pinentry.c

    r5381 r5619  
    9999   break; 
    100100  case 0: 
     101    roar_watchdog_stop(); 
     102 
    101103    close(in[0]); 
    102104    close(out[1]); 
     
    105107 
    106108    if ( dup2(out[0], ROAR_STDIN) == -1 ) 
    107      _exit(1); 
     109     ROAR_U_EXIT(1); 
    108110 
    109111    if ( dup2(in[1], ROAR_STDOUT) == -1 ) 
    110      _exit(1); 
     112     ROAR_U_EXIT(1); 
    111113 
    112114    execlp(ROAR_HAVE_BIN_PINENTRY, "RoarAudio", "--display", display, "--ttytype", term, "--ttyname", tty, NULL); 
    113115 
    114     _exit(1); 
     116    ROAR_U_EXIT(1); 
    115117   break; 
    116118 } 
  • libroar/socket.c

    r5554 r5619  
    11761176  return -1; 
    11771177 } else if ( r == 0 ) { // we are the child 
     1178  roar_watchdog_stop(); 
     1179 
    11781180  close(socks[0]); 
    11791181 
     
    11891191  // we are still alive? 
    11901192  ROAR_ERR("roar_socket_open_ssh(*): alive after exec(), that's bad!"); 
    1191   _exit(1); 
     1193  ROAR_U_EXIT(1); 
    11921194 } else { // we are the parent 
    11931195  close(socks[1]); 
  • libroar/vio_cmd.c

    r5405 r5619  
    172172   break; 
    173173  case 0: 
     174    roar_watchdog_stop(); 
     175 
    174176    close(in[0]); 
    175177    close(out[1]); 
     
    178180 
    179181    if ( dup2(out[0], ROAR_STDIN) == -1 ) 
    180      _exit(1); 
     182     ROAR_U_EXIT(1); 
    181183 
    182184    if ( dup2(in[1], ROAR_STDOUT) == -1 ) 
    183      _exit(1); 
     185     ROAR_U_EXIT(1); 
    184186 
    185187    execlp("/bin/sh", "/bin/sh", "-c", child->cmd, (_LIBROAR_GOOD_CAST char*)NULL); 
    186188 
    187     _exit(1); 
     189    ROAR_U_EXIT(1); 
    188190   break; 
    189191 } 
  • roard/lib.c

    r5586 r5619  
    3434 ROAR_WARN("lib_run_bg(cmd='%s', ...): This function should never be called. Contact devels."); 
    3535 
    36  child = fork(); 
     36 child = roar_fork(NULL); 
    3737 
    3838 if ( child == -1 ) { 
     
    4747 
    4848 // we are the child. 
    49  // first we need to close a lot of open files! 
     49 
     50 // first stop the watchdog. 
     51 roar_watchdog_stop(); 
     52 
     53 // then we need to close a lot of open files! 
    5054 
    5155 // before we do this we need to keep backups of our handles: 
  • roard/loop.c

    r5586 r5619  
    6262 
    6363  ROAR_DBG("main_loop(*): looping..."); 
     64 
     65  roar_watchdog_trigger(); 
    6466 
    6567#ifdef ROAR_SUPPORT_LISTEN 
  • roard/roard.c

    r5592 r5619  
    224224        "                         give multible times for being more realtime\n" 
    225225        " --memlock LEVEL       - Set default memory locking level to LEVEL\n" 
     226        " --watchdog            - Enable watchdog\n" 
     227        " --watchdog-time TIME  - Set watchdog time to TIME (in ms)\n" 
    226228#ifdef ROAR_HAVE_CHROOT 
    227229        " --chroot DIR          - chroots to the given dir\n" 
     
    14281430 int    daemon       = 0; 
    14291431#endif 
     1432 int_least32_t watchdog_time = 0; // -1: default, 0: disabled, > 0: user set time. 
    14301433 int    realtime     = 0; 
    14311434 int    sysclocksync = 0; 
     
    17001703   _CKHAVEARGS(1); 
    17011704   g_config->memlock_level = memlock_str2level(argv[++i]); 
     1705  } else if ( strcmp(k, "--watchdog") == 0 ) { 
     1706   if ( watchdog_time == 0 ) 
     1707    watchdog_time = -1; 
     1708  } else if ( strcmp(k, "--watchdog-time") == 0 ) { 
     1709   _CKHAVEARGS(1); 
     1710    watchdog_time = atoi(argv[++i]); 
    17021711  } else if ( strcmp(k, "--chroot") == 0 ) { 
    17031712   _CKHAVEARGS(1); 
     
    25812590  close(ROAR_STDERR); 
    25822591 
    2583   if ( fork() ) 
     2592  if ( roar_fork(NULL) ) 
    25842593   ROAR_U_EXIT(0); 
    25852594 
     
    25912600 } 
    25922601#endif 
     2602 
     2603 if ( watchdog_time ) { 
     2604  if ( watchdog_time == -1 ) 
     2605   watchdog_time = 5000; 
     2606  roar_watchdog_start(ROAR_WATCHDOG_CONF_DEFAULTS, watchdog_time, NULL); 
     2607 } 
    25932608 
    25942609#if defined(ROAR_HAVE_SETUID) && defined(ROAR_HAVE_IO_POSIX) 
Note: See TracChangeset for help on using the changeset viewer.