static inline bool _acquire_fork(void) { if (fork_state != FS_NONE) { return false; } fork_state = FS_ACQUIRING; _wait_for(&lock, &all_locks_released, &locked_thread_count, 0, fork_friendly_acquire_timeout); if (locked_thread_count) { fork_state = FS_LOCKS_PARTIALLY_DISABLED; _wait_for(&lock, &all_locks_released, &locked_thread_count, 0, NO_TIMEOUT); } fork_state = FS_FORKING; return true; }
static inline void _acquire_lock(void) { #if DEBUG_FORK_LOCKS /*fld_add_acquire_time_point(locked_thread_count);*/ #endif if (!thread_lock_count) { if (fork_state != FS_NONE && fork_state != FS_ACQUIRING) { _wait_for(&lock, &fork_state_changed, &fork_state, FS_NONE, NO_TIMEOUT); } } if (++thread_lock_count == 1) { ++locked_thread_count; #if DEBUG_FORK_LOCKS fld_thread_has_acquired_locks(); #endif } /*fld_write_int(thread_lock_count);*/ }
bool PubSubClient::_send_reliably(MQTT::Message* msg) { MQTT::message_type r_type = msg->response_type(); if (msg->need_packet_id()) msg->set_packet_id(_next_packet_id()); uint16_t pid = msg->packet_id(); uint8_t retries = 0; send: msg->send(*_client); lastOutActivity = millis(); if (r_type == MQTT::None) return true; if (!_wait_for(r_type, pid)) { if (retries < _max_retries) { retries++; goto send; } return false; } return true; }