pw_software_update: Fix recursive lock acquisition

A recent change (I278f16834e95a4020bd7b8586f1878a475b82d60) added a lock
acquisition to BundledUpdateService::SetTransferred, because the
SET_ERROR macro requires the internal lock. However, it calls
NotifyTransferSucceeded, which also acquires the lock. This means that
any calls to SetTransferred deadlock on a recursive acquisition.

This commit fixes the issue by moving the outer lock acquisition into
the if statement that calls SET_ERROR, which is mutually exclusive with
the call to NotifyTransferSucceeded.

Tested: The SetTransferred RPC method no longer hangs.
Change-Id: I0ee7994fa5e093a05e349876406d0a2bd89fc3e7
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/112170
Pigweed-Auto-Submit: Eli Lipsitz <elipsitz@google.com>
Reviewed-by: Ali Zhang <alizhang@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
1 file changed
tree: 0c0cef45efa5b82f8d102ed0cb5ad099a36c2433
  1. .allstar/
  2. .vscode/
  3. build_overrides/
  4. docker/
  5. docs/
  6. pw_allocator/
  7. pw_analog/
  8. pw_android_toolchain/
  9. pw_arduino_build/
  10. pw_assert/
  11. pw_assert_basic/
  12. pw_assert_log/
  13. pw_assert_tokenized/
  14. pw_assert_zephyr/
  15. pw_base64/
  16. pw_bloat/
  17. pw_blob_store/
  18. pw_bluetooth/
  19. pw_bluetooth_hci/
  20. pw_boot/
  21. pw_boot_cortex_m/
  22. pw_build/
  23. pw_build_info/
  24. pw_build_mcuxpresso/
  25. pw_bytes/
  26. pw_checksum/
  27. pw_chrono/
  28. pw_chrono_embos/
  29. pw_chrono_freertos/
  30. pw_chrono_stl/
  31. pw_chrono_threadx/
  32. pw_chrono_zephyr/
  33. pw_cli/
  34. pw_compilation_testing/
  35. pw_console/
  36. pw_containers/
  37. pw_cpu_exception/
  38. pw_cpu_exception_cortex_m/
  39. pw_crypto/
  40. pw_digital_io/
  41. pw_docgen/
  42. pw_doctor/
  43. pw_env_setup/
  44. pw_file/
  45. pw_function/
  46. pw_fuzzer/
  47. pw_hdlc/
  48. pw_hex_dump/
  49. pw_i2c/
  50. pw_i2c_mcuxpresso/
  51. pw_ide/
  52. pw_interrupt/
  53. pw_interrupt_cortex_m/
  54. pw_interrupt_zephyr/
  55. pw_kvs/
  56. pw_libc/
  57. pw_log/
  58. pw_log_android/
  59. pw_log_basic/
  60. pw_log_null/
  61. pw_log_rpc/
  62. pw_log_string/
  63. pw_log_tokenized/
  64. pw_log_zephyr/
  65. pw_malloc/
  66. pw_malloc_freelist/
  67. pw_metric/
  68. pw_minimal_cpp_stdlib/
  69. pw_module/
  70. pw_multisink/
  71. pw_package/
  72. pw_persistent_ram/
  73. pw_polyfill/
  74. pw_preprocessor/
  75. pw_presubmit/
  76. pw_protobuf/
  77. pw_protobuf_compiler/
  78. pw_random/
  79. pw_result/
  80. pw_ring_buffer/
  81. pw_router/
  82. pw_rpc/
  83. pw_rust/
  84. pw_snapshot/
  85. pw_software_update/
  86. pw_span/
  87. pw_spi/
  88. pw_status/
  89. pw_stm32cube_build/
  90. pw_stream/
  91. pw_string/
  92. pw_symbolizer/
  93. pw_sync/
  94. pw_sync_baremetal/
  95. pw_sync_embos/
  96. pw_sync_freertos/
  97. pw_sync_stl/
  98. pw_sync_threadx/
  99. pw_sync_zephyr/
  100. pw_sys_io/
  101. pw_sys_io_arduino/
  102. pw_sys_io_baremetal_lm3s6965evb/
  103. pw_sys_io_baremetal_stm32f429/
  104. pw_sys_io_emcraft_sf2/
  105. pw_sys_io_mcuxpresso/
  106. pw_sys_io_stdio/
  107. pw_sys_io_stm32cube/
  108. pw_sys_io_zephyr/
  109. pw_system/
  110. pw_target_runner/
  111. pw_thread/
  112. pw_thread_embos/
  113. pw_thread_freertos/
  114. pw_thread_stl/
  115. pw_thread_threadx/
  116. pw_tls_client/
  117. pw_tls_client_boringssl/
  118. pw_tls_client_mbedtls/
  119. pw_tokenizer/
  120. pw_tool/
  121. pw_toolchain/
  122. pw_trace/
  123. pw_trace_tokenized/
  124. pw_transfer/
  125. pw_unit_test/
  126. pw_varint/
  127. pw_watch/
  128. pw_web/
  129. pw_work_queue/
  130. targets/
  131. third_party/
  132. ts/
  133. zephyr/
  134. .bazelignore
  135. .bazelrc
  136. .clang-format
  137. .clang-tidy
  138. .eslintrc.json
  139. .gitattributes
  140. .gitignore
  141. .gn
  142. .prettierrc.js
  143. .pw_ide.yaml
  144. .pylintrc
  145. activate.bat
  146. Android.bp
  147. AUTHORS
  148. bootstrap.bat
  149. bootstrap.sh
  150. BUILD.bazel
  151. BUILD.gn
  152. BUILDCONFIG.gn
  153. CMakeLists.txt
  154. jest.config.ts
  155. Kconfig.zephyr
  156. LICENSE
  157. modules.gni
  158. OWNERS
  159. package-lock.json
  160. package.json
  161. PIGWEED_MODULES
  162. PW_PLUGINS
  163. README.md
  164. rollup.config.js
  165. tsconfig.json
  166. WORKSPACE
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links