Implements an asynchronous socket connector with retries

The typical usage of the API is as such:

 1. The client creates an async connector instance by calling async_socket_connector_new
    routine, supplying there address of the socket to connect, and a callback
    to invoke on connection events.
 2. The client then proceeds with calling async_socket_connector_connect that
    would initiate connection attempts.

 The main job on the client side falls on the client's callback routine that
 serves the connection events. Once connection has been initiated, the connector
 will invoke that callback to report current connection status.

 In general, there are three connection events passed to the callback:
 1. Success.
 2. Failure.
 3. Retry.

 Typically, when client's callback is called for successful connection, the
 client will pull connected socket's FD from the connector, and then this FD
 will be used by the client for I/O on the connected socket. If socket's FD
 is pulled by the client, it must return ASC_CB_KEEP from the callback.

 When client's callback is invoked with an error (ASC_CONNECTION_FAILED event),
 the client has an opportunity to review the error (available in 'errno'), and
 either abort the connection by returning ASC_CB_ABORT, or schedule a retry
 by returning ASC_CB_RETRY from the callback. If client returns ASC_CB_ABORT
 from the callback, the connector will stop connection attempts, and will
 self-destruct. If ASC_CB_RETRY is returned from the callback, the connector
 will retry connection attempt after timeout that was set by the caller in the
 call to async_socket_connector_new routine.

 When client's callback is invoked with ASC_CONNECTION_RETRY, the client has an
 opportunity to cancel further connection attempts by returning ASC_CB_ABORT,
 or it can allow another connection attempt by returning ASC_CB_RETRY.

 The client has no control over the lifespan of initialized connector instance.
 It always self-destructs after client's cllback returns with a status other
 than ASC_CB_RETRY.

Change-Id: I39b0057013e45ee10d1ef98905b8a5210656a26c
4 files changed
tree: 76ac88d6ffcbcf951686e7c8bae24b551bc13762
  1. android/
  2. audio/
  3. block/
  4. distrib/
  5. docs/
  6. elff/
  7. fpu/
  8. gdb-xml/
  9. hw/
  10. images/
  11. memcheck/
  12. pc-bios/
  13. proxy/
  14. slirp/
  15. slirp-android/
  16. target-arm/
  17. target-i386/
  18. tcg/
  19. telephony/
  20. .gitignore
  21. a.out.h
  22. acl.c
  23. acl.h
  24. aes.c
  25. aes.h
  26. aio-android.c
  27. aio.c
  28. alpha.ld
  29. android-configure.sh
  30. android-rebuild.sh
  31. android-trace.h
  32. android-trace_common.h
  33. Android.mk
  34. arch_init.c
  35. arch_init.h
  36. arm-dis.c
  37. arm-semi.c
  38. arm.ld
  39. async.c
  40. balloon.h
  41. block.c
  42. block.h
  43. block_int.h
  44. blockdev.c
  45. blockdev.h
  46. bswap.h
  47. bt-host.c
  48. bt-host.h
  49. bt-vhci.c
  50. buffered_file.c
  51. buffered_file.h
  52. cache-utils.c
  53. cache-utils.h
  54. cbuffer.c
  55. cbuffer.h
  56. Changelog
  57. CHANGES.TXT
  58. charpipe.c
  59. charpipe.h
  60. CleanSpec.mk
  61. compatfd.c
  62. compatfd.h
  63. console.c
  64. console.h
  65. COPYING
  66. COPYING.LIB
  67. cpu-all.h
  68. cpu-common.h
  69. cpu-defs.h
  70. cpu-exec.c
  71. cpus.c
  72. cpus.h
  73. curses.c
  74. curses_keys.h
  75. cutils.c
  76. d3des.c
  77. d3des.h
  78. def-helper.h
  79. device_tree.c
  80. device_tree.h
  81. dis-asm.h
  82. disas.c
  83. disas.h
  84. dma-helpers.c
  85. dma.h
  86. dyngen-exec.h
  87. dynlink-static.c
  88. dynlink.h
  89. elf.h
  90. elf_ops.h
  91. envlist.c
  92. envlist.h
  93. exec-all.h
  94. exec.c
  95. feature_to_c.sh
  96. gdbstub.c
  97. gdbstub.h
  98. gen-charmap.py
  99. gen-icount.h
  100. gen-skin.py
  101. hax.h
  102. host-defs.h
  103. host-utils.c
  104. host-utils.h
  105. hostregs_helper.h
  106. hpet.h
  107. hxtool
  108. i386-dis.c
  109. i386-vl.ld
  110. i386.ld
  111. ia64.ld
  112. input.c
  113. INSTALL
  114. iohandler.c
  115. iolooper-select.c
  116. iolooper.h
  117. ioport-user.c
  118. ioport.c
  119. ioport.h
  120. json-lexer.c
  121. json-lexer.h
  122. json-parser.c
  123. json-parser.h
  124. json-streamer.c
  125. json-streamer.h
  126. keymaps.c
  127. keymaps.h
  128. kqemu.c
  129. kqemu.h
  130. kvm-all.c
  131. kvm-android.c
  132. kvm-android.h
  133. kvm.h
  134. LICENSE
  135. linux_keycodes.h
  136. loader.c
  137. loadpng.c
  138. m68k.ld
  139. Makefile
  140. Makefile.android
  141. Makefile.common
  142. Makefile.target
  143. migration-dummy-android.c
  144. migration-exec.c
  145. migration-tcp-android.c
  146. migration-tcp.c
  147. migration.c
  148. migration.h
  149. module.c
  150. module.h
  151. MODULE_LICENSE_GPL
  152. monitor-android.h
  153. monitor.c
  154. monitor.h
  155. net-android.c
  156. net-checksum.c
  157. net.c
  158. net.h
  159. NOTICE
  160. notify.c
  161. notify.h
  162. offset_layout.py
  163. os-posix.c
  164. os-win32.c
  165. osdep.c
  166. osdep.h
  167. oslib-posix.c
  168. oslib-win32.c
  169. path.c
  170. poison.h
  171. posix-aio-compat.c
  172. ppc-dis.c
  173. ppc.ld
  174. qbool.c
  175. qbool.h
  176. qdict.c
  177. qdict.h
  178. qemu-aio.h
  179. qemu-barrier.h
  180. qemu-char.c
  181. qemu-char.h
  182. qemu-common.h
  183. qemu-config.c
  184. qemu-config.h
  185. qemu-error.c
  186. qemu-error.h
  187. qemu-io.c
  188. qemu-lock.h
  189. qemu-log.h
  190. qemu-malloc.c
  191. qemu-monitor.hx
  192. qemu-objects.h
  193. qemu-option.c
  194. qemu-option.h
  195. qemu-options.h
  196. qemu-options.hx
  197. qemu-os-posix.h
  198. qemu-os-win32.h
  199. qemu-queue.h
  200. qemu-sockets-android.c
  201. qemu-sockets.c
  202. qemu-thread.c
  203. qemu-thread.h
  204. qemu-timer-common.c
  205. qemu-timer.c
  206. qemu-timer.h
  207. qemu_debug.h
  208. qemu_file.h
  209. qemu_socket.h
  210. qemu_timers.h
  211. qerror.c
  212. qerror.h
  213. qfloat.c
  214. qfloat.h
  215. qint.c
  216. qint.h
  217. qjson.c
  218. qjson.h
  219. qlist.c
  220. qlist.h
  221. qobject.h
  222. qstring.c
  223. qstring.h
  224. readline.c
  225. readline.h
  226. README
  227. savevm.c
  228. sdl_keysym.h
  229. shaper.c
  230. shaper.h
  231. sockets.c
  232. sockets.h
  233. softmmu-semi.h
  234. softmmu_defs.h
  235. softmmu_exec.h
  236. softmmu_header.h
  237. softmmu_outside_jit.c
  238. softmmu_outside_jit.h
  239. softmmu_template.h
  240. sparc.ld
  241. sys-tree.h
  242. sysemu.h
  243. tap-win32.c
  244. targphys.h
  245. tcpdump.c
  246. tcpdump.h
  247. thunk.c
  248. thunk.h
  249. trace.c
  250. trace.h
  251. trace_common.h
  252. translate-all.c
  253. translate-op.c
  254. translate.make
  255. uboot_image.h
  256. usb-dummy-android.c
  257. usb-linux.c
  258. user-events-qemu.c
  259. user-events.h
  260. varint.c
  261. varint.h
  262. vgafont.h
  263. vl-android-ui.c
  264. vl-android.c
  265. vl.c
  266. vnc-android.c
  267. vnc-tls.h
  268. vnc.c
  269. vnc.h
  270. vnc_keysym.h
  271. vnchextile.h
  272. x86_64.ld