AU: HttpFetcher: Fix segfault with multi fetcher and small transfers

When a proxy resolver resolves proxies, it calls into HttpFetcher w/
the results, which then kicks off a transfer (by executing a member
variable callback of HttpFetcher). After HttpFetcher calls that
callback, it sets the callback to NULL.

When using MultiHttpFetcher, the same HttpFetcher is used multiple
times. If we have a very small transfer, what can happen is this.

Time goes down, callstack grows to the right:

First transfer proxies resolved
++ HttpFetcher called, calls a callback
+++ Transfer begins
++++ Transfer ends
+++++ MultiFetcher told transfer ends
++++++ MultiFetcher starts new transfer
+++++++ HttpFetcher installs a new callback member var
++ HttpFetcher zeros out callback member var

Second transfer proxies resolved
++ HttpFetcher member var is NULL - CRASH

To fix this issue, HttpFetcher makes a local copy of the callback
pointer, then sets the member variable to NULL, then calls the
callback.

(On a side note, it is CLs and bugs like these that make me wonder if
maybe we should have used Chrome's threading model rather than going
single threaded and async.)

Also, fix a comment in MultiHttpFetcher

Change-Id: Ib87c1e75211bc56cecea7f7298576371184d586c

BUG=chromium-os:13388
TEST=unittests

Review URL: http://codereview.chromium.org/6693047
2 files changed
tree: 5db4029ad1d2684d824ba77e2fbf1a1631d70f68
  1. .gitignore
  2. action.h
  3. action_mock.h
  4. action_pipe.h
  5. action_pipe_unittest.cc
  6. action_processor.cc
  7. action_processor.h
  8. action_processor_mock.h
  9. action_processor_unittest.cc
  10. action_unittest.cc
  11. buffered_file_writer.cc
  12. buffered_file_writer.h
  13. buffered_file_writer_unittest.cc
  14. bzip.cc
  15. bzip.h
  16. bzip_extent_writer.cc
  17. bzip_extent_writer.h
  18. bzip_extent_writer_unittest.cc
  19. chrome_browser_proxy_resolver.cc
  20. chrome_browser_proxy_resolver.h
  21. chrome_browser_proxy_resolver_unittest.cc
  22. chrome_proxy_resolver.cc
  23. chrome_proxy_resolver.h
  24. chrome_proxy_resolver_unittest.cc
  25. cycle_breaker.cc
  26. cycle_breaker.h
  27. cycle_breaker_unittest.cc
  28. dbus_constants.h
  29. dbus_interface.h
  30. dbus_service.cc
  31. dbus_service.h
  32. decompressing_file_writer.cc
  33. decompressing_file_writer.h
  34. decompressing_file_writer_unittest.cc
  35. delta_diff_generator.cc
  36. delta_diff_generator.h
  37. delta_diff_generator_unittest.cc
  38. delta_performer.cc
  39. delta_performer.h
  40. delta_performer_unittest.cc
  41. download_action.cc
  42. download_action.h
  43. download_action_unittest.cc
  44. extent_mapper.cc
  45. extent_mapper.h
  46. extent_mapper_unittest.cc
  47. extent_ranges.cc
  48. extent_ranges.h
  49. extent_ranges_unittest.cc
  50. extent_writer.cc
  51. extent_writer.h
  52. extent_writer_unittest.cc
  53. file_writer.cc
  54. file_writer.h
  55. file_writer_mock.h
  56. file_writer_unittest.cc
  57. filesystem_copier_action.cc
  58. filesystem_copier_action.h
  59. filesystem_copier_action_unittest.cc
  60. filesystem_iterator.cc
  61. filesystem_iterator.h
  62. filesystem_iterator_unittest.cc
  63. flimflam_proxy.cc
  64. flimflam_proxy.h
  65. flimflam_proxy_unittest.cc
  66. full_update_generator.cc
  67. full_update_generator.h
  68. full_update_generator_unittest.cc
  69. gen_coverage_html.sh
  70. generate_delta_main.cc
  71. graph_types.h
  72. graph_utils.cc
  73. graph_utils.h
  74. graph_utils_unittest.cc
  75. gzip.cc
  76. gzip.h
  77. http_fetcher.cc
  78. http_fetcher.h
  79. http_fetcher_unittest.cc
  80. inherit-review-settings-ok
  81. install_plan.h
  82. integration_unittest.cc
  83. libcurl_http_fetcher.cc
  84. libcurl_http_fetcher.h
  85. LICENSE
  86. local_coverage_rate.sh
  87. main.cc
  88. marshal.list
  89. metadata.cc
  90. metadata.h
  91. metadata_unittest.cc
  92. mock_dbus_interface.h
  93. mock_file_writer.h
  94. mock_http_fetcher.cc
  95. mock_http_fetcher.h
  96. multi_range_http_fetcher.cc
  97. multi_range_http_fetcher.h
  98. omaha_hash_calculator.cc
  99. omaha_hash_calculator.h
  100. omaha_hash_calculator_unittest.cc
  101. omaha_request_action.cc
  102. omaha_request_action.h
  103. omaha_request_action_unittest.cc
  104. omaha_request_params.cc
  105. omaha_request_params.h
  106. omaha_request_params_unittest.cc
  107. omaha_response_handler_action.cc
  108. omaha_response_handler_action.h
  109. omaha_response_handler_action_unittest.cc
  110. org.chromium.UpdateEngine.service
  111. payload_signer.cc
  112. payload_signer.h
  113. payload_signer_unittest.cc
  114. postinstall_runner_action.cc
  115. postinstall_runner_action.h
  116. postinstall_runner_action_unittest.cc
  117. prefs.cc
  118. prefs.h
  119. prefs_interface.h
  120. prefs_mock.h
  121. prefs_unittest.cc
  122. proxy_resolver.cc
  123. proxy_resolver.h
  124. SConstruct
  125. setup_dev_packages
  126. simple_key_value_store.cc
  127. simple_key_value_store.h
  128. simple_key_value_store_unittest.cc
  129. split_file_writer.cc
  130. split_file_writer.h
  131. split_file_writer_unittest.cc
  132. subprocess.cc
  133. subprocess.h
  134. subprocess_unittest.cc
  135. tarjan.cc
  136. tarjan.h
  137. tarjan_unittest.cc
  138. terminator.cc
  139. terminator.h
  140. terminator_unittest.cc
  141. test_http_server.cc
  142. test_utils.cc
  143. test_utils.h
  144. testrunner.cc
  145. topological_sort.cc
  146. topological_sort.h
  147. topological_sort_unittest.cc
  148. unittest_key.pem
  149. update_attempter.cc
  150. update_attempter.h
  151. update_attempter_mock.h
  152. update_attempter_unittest.cc
  153. update_check_scheduler.cc
  154. update_check_scheduler.h
  155. update_check_scheduler_unittest.cc
  156. update_engine.xml
  157. update_engine_client.cc
  158. update_metadata.proto
  159. UpdateEngine.conf
  160. utils.cc
  161. utils.h
  162. utils_unittest.cc
  163. WATCHLISTS
  164. zip_unittest.cc