| 893 | static qjsgo_mutex_t g_timeout_states_mu = QJSGO_MUTEX_INITIALIZER; |
| 894 | |
| 895 | static int isExecuteTimeoutExceeded(JSRuntime *rt) { |
| 896 | time_t start = 0; |
| 897 | time_t timeout = 0; |
| 898 | int found = 0; |
| 899 | |
| 900 | qjsgo_mutex_lock(&g_timeout_states_mu); |
| 901 | TimeoutStateEntry *current = g_timeout_states; |
| 902 | while (current) { |
| 903 | if (current->rt == rt && current->state != NULL) { |
| 904 | start = current->state->start; |
| 905 | timeout = current->state->timeout; |
| 906 | found = 1; |
| 907 | break; |
| 908 | } |
| 909 | current = current->next; |
| 910 | } |
| 911 | qjsgo_mutex_unlock(&g_timeout_states_mu); |
| 912 | |
| 913 | if (!found || timeout <= 0) { |
| 914 | return 0; |
| 915 | } |
| 916 | |
| 917 | return (time(NULL) - start) > timeout; |
| 918 | } |
| 919 | static TimeoutStruct *takeTimeoutState(JSRuntime *rt) { |
| 920 | qjsgo_mutex_lock(&g_timeout_states_mu); |
| 921 | |