Changeset fc21df8068e684f6a73263e74d440c9ba045ffb0

Show
Ignore:
Timestamp:
03/06/10 02:17:51 (5 months ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
eee9239f0ce95575624ed911defebd628a458891
Parents:
09ef9023bca7d8c58c93e3e13e8cd9ad6b110c4b
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-03-06T02:17:51Z+0200
Message:

daemon: better implementation of server stop timeout workaround

  • current time check is more precise
  • waits during command executions are suboptimal because they block the main loop
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • daemon/cmd_start_studio.c

    r09ef902 rfc21df8  
    3030#include "studio_internal.h" 
    3131#include "loader.h" 
     32#include "../common/time.h" 
    3233 
    3334struct ladish_command_start_studio 
     
    3637  uint64_t deadline; 
    3738}; 
    38  
    39 static uint64_t get_current_microseconds(void) 
    40 { 
    41   struct timeval time; 
    42  
    43   if (gettimeofday(&time, NULL) != 0) 
    44     return 0; 
    45  
    46   return (uint64_t)time.tv_sec * 1000000 + (uint64_t)time.tv_usec; 
    47 } 
    4839 
    4940#define cmd_ptr ((struct ladish_command_start_studio *)context) 
     
    8475    } 
    8576 
    86     cmd_ptr->deadline = get_current_microseconds(); 
     77    cmd_ptr->deadline = ladish_get_current_microseconds(); 
    8778    if (cmd_ptr->deadline != 0) 
    8879    { 
     
    9889      ASSERT(!ladish_environment_get(&g_studio.env_store, ladish_environment_jack_server_started)); /* someone else consumed the state change? */ 
    9990 
    100       if (cmd_ptr->deadline != 0 && get_current_microseconds() >= cmd_ptr->deadline) 
     91      if (cmd_ptr->deadline != 0 && ladish_get_current_microseconds() >= cmd_ptr->deadline) 
    10192      { 
    10293        log_error("Starting JACK server succeded, but 'started' signal was not received within 5 seconds."); 
  • daemon/cmd_stop_studio.c

    r58be088 rfc21df8  
    33 * LADI Session Handler (ladish) 
    44 * 
    5  * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name> 
     5 * Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name> 
    66 * 
    77 ************************************************************************** 
     
    3030#include "studio_internal.h" 
    3131#include "loader.h" 
     32#include "../common/time.h" 
    3233 
    3334#define STOP_STATE_WAITING_FOR_JACK_CLIENTS_DISAPPEAR   1 
     
    3839{ 
    3940  struct ladish_command command; 
    40   int stop_waits; 
     41  uint64_t deadline; 
    4142  unsigned int stop_state; 
    4243}; 
     
    103104        /* Reproducable with yoshimi-0.0.45 */ 
    104105 
    105         cmd_ptr->stop_waits = 5000; 
     106        cmd_ptr->deadline = ladish_get_current_microseconds(); 
     107        if (cmd_ptr->deadline != 0) 
     108        { 
     109          cmd_ptr->deadline += 5000000; 
     110        } 
     111 
    106112        return true; 
    107113      } 
     
    110116    ASSERT(cmd_ptr->stop_state == STOP_STATE_WAITING_FOR_JACK_SERVER_STOP); 
    111117 
    112     if (cmd_ptr->stop_waits > 0) 
     118    if (cmd_ptr->deadline != 0) 
    113119    { 
    114       if (!jack_proxy_is_started(&jack_server_started)) 
    115       { 
    116         log_error("jack_proxy_is_started() failed."); 
    117         return false; 
    118       } 
    119  
    120       if (!jack_server_started) 
     120      if (jack_proxy_is_started(&jack_server_started) && !jack_server_started) 
    121121      { 
    122122        ladish_environment_reset_stealth(&g_studio.env_store, ladish_environment_jack_server_started); 
     
    124124      } 
    125125 
    126       if (cmd_ptr->stop_waits == 1) 
     126      if (ladish_get_current_microseconds() >= cmd_ptr->deadline) 
    127127      { 
    128         log_error("JACK server stop wait after stop request expired."); 
     128        log_error("JACK server stop wait after stop request expired (5 seconds)."); 
     129        cmd_ptr->command.state = LADISH_COMMAND_STATE_DONE; 
    129130        return false; 
    130131      } 
    131132 
    132       cmd_ptr->stop_waits--; 
    133       usleep(1000); 
    134133      return true; 
    135134    } 
     
    175174 
    176175  cmd_ptr->command.run = run; 
    177   cmd_ptr->stop_waits = -1; 
     176  cmd_ptr->deadline = 0; 
    178177 
    179178  if (!ladish_cqueue_add_command(queue_ptr, &cmd_ptr->command)) 
  • wscript

    r44cdd31 rfc21df8  
    247247        daemon.source.append(os.path.join("dbus", source)) 
    248248 
    249     daemon.source.append(os.path.join("common", "safety.c")) 
     249    for source in [ 
     250        'safety.c', 
     251        'time.c', 
     252        ]: 
     253        daemon.source.append(os.path.join("common", source)) 
    250254 
    251255    # process name.arnaudov.nedko.ladish.service.in -> name.arnaudov.nedko.ladish.service