History log of /system/core/libcutils/abort_socket.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
111bfcefc3cf0f14ad607a56fcf5d076131833a9 22-May-2009 Nick Pelly <npelly@google.com> Fix bug where ECONNABORTED would have always occured on asocket_write.

Use POLLOUT for writes. Duh.
/system/core/libcutils/abort_socket.c
92a7541bce0f8ed7649dcbadd83b27d71e4f391f 20-May-2009 Nick Pelly <npelly@google.com> Helper to perform abortable blocking operations on a socket:
asocket_connect()
asocket_accept()
asocket_read()
asocket_write()
These calls are similar to the regular syscalls, but can be aborted with:
asocket_abort()

Calling close() on a regular POSIX socket does not abort blocked syscalls on
that socket in other threads.

After calling asocket_abort() the socket cannot be reused.

Call asocket_destory() *after* all threads have finished with the socket to
finish closing the socket and free the asocket structure.

The helper is implemented by setting the socket non-blocking to initiate
syscalls connect(), accept(), read(), write(), then using a blocking poll()
on both the primary socket and a local pipe. This makes the poll() abortable
by writing a byte to the local pipe in asocket_abort().

asocket_create() sets the fd to non-blocking mode. It must not be changed to
blocking mode.

Using asocket will triple the number of file descriptors required per
socket, due to the local pipe. It may be possible to use a global pipe per
process rather than per socket, but we have not been able to come up with a
race-free implementation yet.

All functions except asocket_init() and asocket_destroy() are thread safe.
/system/core/libcutils/abort_socket.c