Changeset fc21df8068e684f6a73263e74d440c9ba045ffb0
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r09ef902
|
rfc21df8
|
|
| 30 | 30 | #include "studio_internal.h" |
| 31 | 31 | #include "loader.h" |
| | 32 | #include "../common/time.h" |
| 32 | 33 | |
| 33 | 34 | struct ladish_command_start_studio |
| … |
… |
|
| 36 | 37 | uint64_t deadline; |
| 37 | 38 | }; |
| 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 | | } |
| 48 | 39 | |
| 49 | 40 | #define cmd_ptr ((struct ladish_command_start_studio *)context) |
| … |
… |
|
| 84 | 75 | } |
| 85 | 76 | |
| 86 | | cmd_ptr->deadline = get_current_microseconds(); |
| | 77 | cmd_ptr->deadline = ladish_get_current_microseconds(); |
| 87 | 78 | if (cmd_ptr->deadline != 0) |
| 88 | 79 | { |
| … |
… |
|
| 98 | 89 | ASSERT(!ladish_environment_get(&g_studio.env_store, ladish_environment_jack_server_started)); /* someone else consumed the state change? */ |
| 99 | 90 | |
| 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) |
| 101 | 92 | { |
| 102 | 93 | log_error("Starting JACK server succeded, but 'started' signal was not received within 5 seconds."); |
-
|
r58be088
|
rfc21df8
|
|
| 3 | 3 | * LADI Session Handler (ladish) |
| 4 | 4 | * |
| 5 | | * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name> |
| | 5 | * Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name> |
| 6 | 6 | * |
| 7 | 7 | ************************************************************************** |
| … |
… |
|
| 30 | 30 | #include "studio_internal.h" |
| 31 | 31 | #include "loader.h" |
| | 32 | #include "../common/time.h" |
| 32 | 33 | |
| 33 | 34 | #define STOP_STATE_WAITING_FOR_JACK_CLIENTS_DISAPPEAR 1 |
| … |
… |
|
| 38 | 39 | { |
| 39 | 40 | struct ladish_command command; |
| 40 | | int stop_waits; |
| | 41 | uint64_t deadline; |
| 41 | 42 | unsigned int stop_state; |
| 42 | 43 | }; |
| … |
… |
|
| 103 | 104 | /* Reproducable with yoshimi-0.0.45 */ |
| 104 | 105 | |
| 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 | |
| 106 | 112 | return true; |
| 107 | 113 | } |
| … |
… |
|
| 110 | 116 | ASSERT(cmd_ptr->stop_state == STOP_STATE_WAITING_FOR_JACK_SERVER_STOP); |
| 111 | 117 | |
| 112 | | if (cmd_ptr->stop_waits > 0) |
| | 118 | if (cmd_ptr->deadline != 0) |
| 113 | 119 | { |
| 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) |
| 121 | 121 | { |
| 122 | 122 | ladish_environment_reset_stealth(&g_studio.env_store, ladish_environment_jack_server_started); |
| … |
… |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | | if (cmd_ptr->stop_waits == 1) |
| | 126 | if (ladish_get_current_microseconds() >= cmd_ptr->deadline) |
| 127 | 127 | { |
| 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; |
| 129 | 130 | return false; |
| 130 | 131 | } |
| 131 | 132 | |
| 132 | | cmd_ptr->stop_waits--; |
| 133 | | usleep(1000); |
| 134 | 133 | return true; |
| 135 | 134 | } |
| … |
… |
|
| 175 | 174 | |
| 176 | 175 | cmd_ptr->command.run = run; |
| 177 | | cmd_ptr->stop_waits = -1; |
| | 176 | cmd_ptr->deadline = 0; |
| 178 | 177 | |
| 179 | 178 | if (!ladish_cqueue_add_command(queue_ptr, &cmd_ptr->command)) |
-
|
r44cdd31
|
rfc21df8
|
|
| 247 | 247 | daemon.source.append(os.path.join("dbus", source)) |
| 248 | 248 | |
| 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)) |
| 250 | 254 | |
| 251 | 255 | # process name.arnaudov.nedko.ladish.service.in -> name.arnaudov.nedko.ladish.service |